|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #undef G_DISABLE_ASSERT |
|
20 #undef G_LOG_DOMAIN |
|
21 |
|
22 |
|
23 #include <stdio.h> |
|
24 #include <string.h> |
|
25 #include <glib.h> |
|
26 #include <fcntl.h> |
|
27 #include <goption.h> |
|
28 |
|
29 #ifdef SYMBIAN |
|
30 #include "mrt2_glib2_test.h" |
|
31 #endif /*SYMBIAN*/ |
|
32 |
|
33 #define C2P(c) ((gpointer) ((long) (c))) |
|
34 #define GINT_TO_POINTER(i) ((gpointer) (i)) |
|
35 #define GPOINTER_TO_INT(p) ((gint) (p)) |
|
36 #define TESTPASS 1 |
|
37 #define TESTFAIL 0 |
|
38 |
|
39 //Test for tg_unichar_type |
|
40 void tg_unichar_type() |
|
41 { |
|
42 g_assert (g_unichar_type (0x41) == G_UNICODE_UPPERCASE_LETTER); |
|
43 g_assert (g_unichar_type (0x63) == G_UNICODE_LOWERCASE_LETTER); |
|
44 g_assert (g_unichar_type (0x30) == G_UNICODE_DECIMAL_NUMBER); |
|
45 g_assert (g_unichar_type (0x2d) == G_UNICODE_DASH_PUNCTUATION); |
|
46 g_assert (g_unichar_type (0x24) == G_UNICODE_CURRENCY_SYMBOL); |
|
47 } |
|
48 |
|
49 //Test for tg_unichar_break_type |
|
50 void tg_unichar_break_type() |
|
51 { |
|
52 |
|
53 g_assert (g_unichar_break_type (0x0d) == G_UNICODE_BREAK_CARRIAGE_RETURN); |
|
54 g_assert (g_unichar_break_type (0x0a) == G_UNICODE_BREAK_LINE_FEED); |
|
55 g_assert (g_unichar_break_type (0x20) == G_UNICODE_BREAK_SPACE); |
|
56 g_assert (g_unichar_break_type (0x2d) == G_UNICODE_BREAK_HYPHEN); |
|
57 g_assert (g_unichar_break_type (0x21) == G_UNICODE_BREAK_EXCLAMATION); |
|
58 g_assert (g_unichar_break_type (0x31) == G_UNICODE_BREAK_NUMERIC); |
|
59 } |
|
60 |
|
61 //Test for g_unichar_get_mirror_char |
|
62 void tg_unichar_get_mirror_char() |
|
63 { |
|
64 gunichar* res = (gunichar*)malloc (sizeof (gunichar)); |
|
65 g_assert (g_unichar_get_mirror_char (0x28,res)); |
|
66 g_assert (g_unichar_get_mirror_char (0x5b,res)); |
|
67 g_assert (g_unichar_get_mirror_char (0x3c,res)); |
|
68 g_assert (!g_unichar_get_mirror_char (0x10,res)); |
|
69 free (res); |
|
70 } |
|
71 |
|
72 |
|
73 //Test for g_unichar_isdefined |
|
74 void tg_unichar_isdefined() |
|
75 { |
|
76 g_assert (g_unichar_isdefined (0x5a)); //Valid |
|
77 g_assert (!g_unichar_isdefined (0xFFFF)); //Invalid |
|
78 } |
|
79 |
|
80 //Test for g_unichar_istitle |
|
81 void tg_unichar_istitle() |
|
82 { |
|
83 g_assert(g_unichar_istitle(0x01C5)); //LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON |
|
84 g_assert(g_unichar_istitle(0x01C8)); //LATIN CAPITAL LETTER L WITH SMALL LETTER J |
|
85 g_assert(g_unichar_istitle(0x01CB)); //LATIN CAPITAL LETTER N WITH SMALL LETTER J |
|
86 g_assert(g_unichar_istitle(0x01F2)); //LATIN CAPITAL LETTER D WITH SMALL LETTER Z |
|
87 |
|
88 } |
|
89 |
|
90 //Test for g_unichar_iswide |
|
91 void tg_unichar_iswide() |
|
92 { |
|
93 char ip1 = 'a'; |
|
94 wchar_t ip2 = 0x1101; |
|
95 g_assert(!g_unichar_iswide(ip1)); |
|
96 g_assert(g_unichar_iswide(ip2)); |
|
97 } |
|
98 |
|
99 //Test for g_unichar_totitle |
|
100 void tg_unichar_totitle() |
|
101 { |
|
102 g_assert(g_unichar_totitle('A')==65); |
|
103 g_assert(g_unichar_totitle('a')==65); |
|
104 } |
|
105 |
|
106 void tg_unicode_canonical_ordering() |
|
107 { |
|
108 unsigned int ip[] = |
|
109 { |
|
110 0x24,0x28,0x69,0x2c,0x34,0x4a,0x5d |
|
111 }; |
|
112 g_unicode_canonical_ordering (ip ,7); |
|
113 } |
|
114 |
|
115 int main (int argc,char *argv[]) |
|
116 { |
|
117 |
|
118 #ifdef SYMBIAN |
|
119 |
|
120 g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL); |
|
121 #endif /*SYMBIAN*/ |
|
122 |
|
123 tg_unichar_type(); |
|
124 tg_unichar_break_type(); |
|
125 tg_unichar_get_mirror_char(); |
|
126 tg_unichar_isdefined(); |
|
127 tg_unichar_istitle(); |
|
128 tg_unichar_iswide(); |
|
129 tg_unichar_totitle(); |
|
130 tg_unicode_canonical_ordering(); |
|
131 #ifdef SYMBIAN |
|
132 testResultXml("tunichar"); |
|
133 #endif /* EMULATOR */ |
|
134 return 0; |
|
135 } |