sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: * sl@0: * This library is free software; you can redistribute it and/or sl@0: * modify it under the terms of the GNU Lesser General Public sl@0: * License as published by the Free Software Foundation; either sl@0: * version 2 of the License, or (at your option) any later version. sl@0: * sl@0: * This library is distributed in the hope that it will be useful, sl@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of sl@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU sl@0: * Lesser General Public License for more details. sl@0: * sl@0: * You should have received a copy of the GNU Lesser General Public sl@0: * License along with this library; if not, write to the sl@0: * Free Software Foundation, Inc., 59 Temple Place - Suite 330, sl@0: * Boston, MA 02111-1307, USA. sl@0: * sl@0: * Description: ?Description sl@0: * sl@0: */ sl@0: sl@0: sl@0: #undef G_DISABLE_ASSERT sl@0: #undef G_LOG_DOMAIN sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifdef SYMBIAN sl@0: #include "mrt2_glib2_test.h" sl@0: #endif /*SYMBIAN*/ sl@0: sl@0: #define C2P(c) ((gpointer) ((long) (c))) sl@0: #define GINT_TO_POINTER(i) ((gpointer) (i)) sl@0: #define GPOINTER_TO_INT(p) ((gint) (p)) sl@0: #define TESTPASS 1 sl@0: #define TESTFAIL 0 sl@0: sl@0: //Test for tg_unichar_type sl@0: void tg_unichar_type() sl@0: { sl@0: g_assert (g_unichar_type (0x41) == G_UNICODE_UPPERCASE_LETTER); sl@0: g_assert (g_unichar_type (0x63) == G_UNICODE_LOWERCASE_LETTER); sl@0: g_assert (g_unichar_type (0x30) == G_UNICODE_DECIMAL_NUMBER); sl@0: g_assert (g_unichar_type (0x2d) == G_UNICODE_DASH_PUNCTUATION); sl@0: g_assert (g_unichar_type (0x24) == G_UNICODE_CURRENCY_SYMBOL); sl@0: } sl@0: sl@0: //Test for tg_unichar_break_type sl@0: void tg_unichar_break_type() sl@0: { sl@0: sl@0: g_assert (g_unichar_break_type (0x0d) == G_UNICODE_BREAK_CARRIAGE_RETURN); sl@0: g_assert (g_unichar_break_type (0x0a) == G_UNICODE_BREAK_LINE_FEED); sl@0: g_assert (g_unichar_break_type (0x20) == G_UNICODE_BREAK_SPACE); sl@0: g_assert (g_unichar_break_type (0x2d) == G_UNICODE_BREAK_HYPHEN); sl@0: g_assert (g_unichar_break_type (0x21) == G_UNICODE_BREAK_EXCLAMATION); sl@0: g_assert (g_unichar_break_type (0x31) == G_UNICODE_BREAK_NUMERIC); sl@0: } sl@0: sl@0: //Test for g_unichar_get_mirror_char sl@0: void tg_unichar_get_mirror_char() sl@0: { sl@0: gunichar* res = (gunichar*)malloc (sizeof (gunichar)); sl@0: g_assert (g_unichar_get_mirror_char (0x28,res)); sl@0: g_assert (g_unichar_get_mirror_char (0x5b,res)); sl@0: g_assert (g_unichar_get_mirror_char (0x3c,res)); sl@0: g_assert (!g_unichar_get_mirror_char (0x10,res)); sl@0: free (res); sl@0: } sl@0: sl@0: sl@0: //Test for g_unichar_isdefined sl@0: void tg_unichar_isdefined() sl@0: { sl@0: g_assert (g_unichar_isdefined (0x5a)); //Valid sl@0: g_assert (!g_unichar_isdefined (0xFFFF)); //Invalid sl@0: } sl@0: sl@0: //Test for g_unichar_istitle sl@0: void tg_unichar_istitle() sl@0: { sl@0: g_assert(g_unichar_istitle(0x01C5)); //LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON sl@0: g_assert(g_unichar_istitle(0x01C8)); //LATIN CAPITAL LETTER L WITH SMALL LETTER J sl@0: g_assert(g_unichar_istitle(0x01CB)); //LATIN CAPITAL LETTER N WITH SMALL LETTER J sl@0: g_assert(g_unichar_istitle(0x01F2)); //LATIN CAPITAL LETTER D WITH SMALL LETTER Z sl@0: sl@0: } sl@0: sl@0: //Test for g_unichar_iswide sl@0: void tg_unichar_iswide() sl@0: { sl@0: char ip1 = 'a'; sl@0: wchar_t ip2 = 0x1101; sl@0: g_assert(!g_unichar_iswide(ip1)); sl@0: g_assert(g_unichar_iswide(ip2)); sl@0: } sl@0: sl@0: //Test for g_unichar_totitle sl@0: void tg_unichar_totitle() sl@0: { sl@0: g_assert(g_unichar_totitle('A')==65); sl@0: g_assert(g_unichar_totitle('a')==65); sl@0: } sl@0: sl@0: void tg_unicode_canonical_ordering() sl@0: { sl@0: unsigned int ip[] = sl@0: { sl@0: 0x24,0x28,0x69,0x2c,0x34,0x4a,0x5d sl@0: }; sl@0: g_unicode_canonical_ordering (ip ,7); sl@0: } sl@0: sl@0: int main (int argc,char *argv[]) sl@0: { sl@0: sl@0: #ifdef SYMBIAN sl@0: sl@0: 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); sl@0: #endif /*SYMBIAN*/ sl@0: sl@0: tg_unichar_type(); sl@0: tg_unichar_break_type(); sl@0: tg_unichar_get_mirror_char(); sl@0: tg_unichar_isdefined(); sl@0: tg_unichar_istitle(); sl@0: tg_unichar_iswide(); sl@0: tg_unichar_totitle(); sl@0: tg_unicode_canonical_ordering(); sl@0: #ifdef SYMBIAN sl@0: testResultXml("tunichar"); sl@0: #endif /* EMULATOR */ sl@0: return 0; sl@0: }