|
1 /* |
|
2 * Copyright (c) 2009 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 |
|
20 #undef G_DISABLE_ASSERT |
|
21 #undef G_LOG_DOMAIN |
|
22 |
|
23 |
|
24 #include <stdio.h> |
|
25 #include <string.h> |
|
26 #include <glib.h> |
|
27 #include <fcntl.h> |
|
28 #include <goption.h> |
|
29 |
|
30 #ifdef __SYMBIAN32__ |
|
31 #include "mrt2_glib2_test.h" |
|
32 #endif /*__SYMBIAN32__*/ |
|
33 |
|
34 #define C2P(c) ((gpointer) ((long) (c))) |
|
35 #define GINT_TO_POINTER(i) ((gpointer) (i)) |
|
36 #define GPOINTER_TO_INT(p) ((gint) (p)) |
|
37 #define TESTPASS 1 |
|
38 #define TESTFAIL 0 |
|
39 |
|
40 //Test for tg_unichar_type |
|
41 void tg_unichar_type() |
|
42 { |
|
43 g_assert (g_unichar_type (0x41) == G_UNICODE_UPPERCASE_LETTER); |
|
44 g_assert (g_unichar_type (0x63) == G_UNICODE_LOWERCASE_LETTER); |
|
45 g_assert (g_unichar_type (0x30) == G_UNICODE_DECIMAL_NUMBER); |
|
46 g_assert (g_unichar_type (0x2d) == G_UNICODE_DASH_PUNCTUATION); |
|
47 g_assert (g_unichar_type (0x24) == G_UNICODE_CURRENCY_SYMBOL); |
|
48 } |
|
49 |
|
50 //Test for tg_unichar_break_type |
|
51 void tg_unichar_break_type() |
|
52 { |
|
53 |
|
54 g_assert (g_unichar_break_type (0x0d) == G_UNICODE_BREAK_CARRIAGE_RETURN); |
|
55 g_assert (g_unichar_break_type (0x0a) == G_UNICODE_BREAK_LINE_FEED); |
|
56 g_assert (g_unichar_break_type (0x20) == G_UNICODE_BREAK_SPACE); |
|
57 g_assert (g_unichar_break_type (0x2d) == G_UNICODE_BREAK_HYPHEN); |
|
58 g_assert (g_unichar_break_type (0x21) == G_UNICODE_BREAK_EXCLAMATION); |
|
59 g_assert (g_unichar_break_type (0x31) == G_UNICODE_BREAK_NUMERIC); |
|
60 } |
|
61 |
|
62 //Test for g_unichar_get_mirror_char |
|
63 void tg_unichar_get_mirror_char() |
|
64 { |
|
65 gunichar* res = (gunichar*)malloc (sizeof (gunichar)); |
|
66 g_assert (g_unichar_get_mirror_char (0x28,res)); |
|
67 g_assert (g_unichar_get_mirror_char (0x5b,res)); |
|
68 g_assert (g_unichar_get_mirror_char (0x3c,res)); |
|
69 g_assert (!g_unichar_get_mirror_char (0x10,res)); |
|
70 free (res); |
|
71 } |
|
72 |
|
73 |
|
74 //Test for g_unichar_isdefined |
|
75 void tg_unichar_isdefined() |
|
76 { |
|
77 g_assert (g_unichar_isdefined (0x5a)); //Valid |
|
78 g_assert (!g_unichar_isdefined (0xFFFF)); //Invalid |
|
79 } |
|
80 |
|
81 //Test for g_unichar_istitle |
|
82 void tg_unichar_istitle() |
|
83 { |
|
84 g_assert(g_unichar_istitle(0x01C5)); //LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON |
|
85 g_assert(g_unichar_istitle(0x01C8)); //LATIN CAPITAL LETTER L WITH SMALL LETTER J |
|
86 g_assert(g_unichar_istitle(0x01CB)); //LATIN CAPITAL LETTER N WITH SMALL LETTER J |
|
87 g_assert(g_unichar_istitle(0x01F2)); //LATIN CAPITAL LETTER D WITH SMALL LETTER Z |
|
88 |
|
89 } |
|
90 |
|
91 //Test for g_unichar_iswide |
|
92 void tg_unichar_iswide() |
|
93 { |
|
94 char ip1 = 'a'; |
|
95 wchar_t ip2 = 0x1101; |
|
96 g_assert(!g_unichar_iswide(ip1)); |
|
97 g_assert(g_unichar_iswide(ip2)); |
|
98 } |
|
99 |
|
100 //Test for g_unichar_totitle |
|
101 void tg_unichar_totitle() |
|
102 { |
|
103 g_assert(g_unichar_totitle('A')==65); |
|
104 g_assert(g_unichar_totitle('a')==65); |
|
105 } |
|
106 |
|
107 void tg_unicode_canonical_ordering() |
|
108 { |
|
109 unsigned int ip[] = |
|
110 { |
|
111 0x24,0x28,0x69,0x2c,0x34,0x4a,0x5d |
|
112 }; |
|
113 g_unicode_canonical_ordering (ip ,7); |
|
114 } |
|
115 |
|
116 int main (int argc,char *argv[]) |
|
117 { |
|
118 |
|
119 #ifdef __SYMBIAN32__ |
|
120 |
|
121 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); |
|
122 #endif /*__SYMBIAN32__*/ |
|
123 |
|
124 tg_unichar_type(); |
|
125 tg_unichar_break_type(); |
|
126 tg_unichar_get_mirror_char(); |
|
127 tg_unichar_isdefined(); |
|
128 tg_unichar_istitle(); |
|
129 tg_unichar_iswide(); |
|
130 tg_unichar_totitle(); |
|
131 tg_unicode_canonical_ordering(); |
|
132 #ifdef __SYMBIAN32__ |
|
133 testResultXml("tunichar"); |
|
134 #endif /* EMULATOR */ |
|
135 return 0; |
|
136 } |