Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 * Description: ?Description
24 #undef G_DISABLE_ASSERT
36 #include "mrt2_glib2_test.h"
39 #define C2P(c) ((gpointer) ((long) (c)))
40 #define GINT_TO_POINTER(i) ((gpointer) (i))
41 #define GPOINTER_TO_INT(p) ((gint) (p))
45 //Test for tg_unichar_type
46 void tg_unichar_type()
48 g_assert (g_unichar_type (0x41) == G_UNICODE_UPPERCASE_LETTER);
49 g_assert (g_unichar_type (0x63) == G_UNICODE_LOWERCASE_LETTER);
50 g_assert (g_unichar_type (0x30) == G_UNICODE_DECIMAL_NUMBER);
51 g_assert (g_unichar_type (0x2d) == G_UNICODE_DASH_PUNCTUATION);
52 g_assert (g_unichar_type (0x24) == G_UNICODE_CURRENCY_SYMBOL);
55 //Test for tg_unichar_break_type
56 void tg_unichar_break_type()
59 g_assert (g_unichar_break_type (0x0d) == G_UNICODE_BREAK_CARRIAGE_RETURN);
60 g_assert (g_unichar_break_type (0x0a) == G_UNICODE_BREAK_LINE_FEED);
61 g_assert (g_unichar_break_type (0x20) == G_UNICODE_BREAK_SPACE);
62 g_assert (g_unichar_break_type (0x2d) == G_UNICODE_BREAK_HYPHEN);
63 g_assert (g_unichar_break_type (0x21) == G_UNICODE_BREAK_EXCLAMATION);
64 g_assert (g_unichar_break_type (0x31) == G_UNICODE_BREAK_NUMERIC);
67 //Test for g_unichar_get_mirror_char
68 void tg_unichar_get_mirror_char()
70 gunichar* res = (gunichar*)malloc (sizeof (gunichar));
71 g_assert (g_unichar_get_mirror_char (0x28,res));
72 g_assert (g_unichar_get_mirror_char (0x5b,res));
73 g_assert (g_unichar_get_mirror_char (0x3c,res));
74 g_assert (!g_unichar_get_mirror_char (0x10,res));
79 //Test for g_unichar_isdefined
80 void tg_unichar_isdefined()
82 g_assert (g_unichar_isdefined (0x5a)); //Valid
83 g_assert (!g_unichar_isdefined (0xFFFF)); //Invalid
86 //Test for g_unichar_istitle
87 void tg_unichar_istitle()
89 g_assert(g_unichar_istitle(0x01C5)); //LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
90 g_assert(g_unichar_istitle(0x01C8)); //LATIN CAPITAL LETTER L WITH SMALL LETTER J
91 g_assert(g_unichar_istitle(0x01CB)); //LATIN CAPITAL LETTER N WITH SMALL LETTER J
92 g_assert(g_unichar_istitle(0x01F2)); //LATIN CAPITAL LETTER D WITH SMALL LETTER Z
96 //Test for g_unichar_iswide
97 void tg_unichar_iswide()
100 wchar_t ip2 = 0x1101;
101 g_assert(!g_unichar_iswide(ip1));
102 g_assert(g_unichar_iswide(ip2));
105 //Test for g_unichar_totitle
106 void tg_unichar_totitle()
108 g_assert(g_unichar_totitle('A')==65);
109 g_assert(g_unichar_totitle('a')==65);
112 void tg_unicode_canonical_ordering()
116 0x24,0x28,0x69,0x2c,0x34,0x4a,0x5d
118 g_unicode_canonical_ordering (ip ,7);
121 int main (int argc,char *argv[])
126 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);
130 tg_unichar_break_type();
131 tg_unichar_get_mirror_char();
132 tg_unichar_isdefined();
133 tg_unichar_istitle();
135 tg_unichar_totitle();
136 tg_unicode_canonical_ordering();
138 testResultXml("tunichar");
139 #endif /* EMULATOR */