First public contribution.
1 /* Portion Copyright © 2008-09 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.*/
2 #undef G_DISABLE_ASSERT
12 #include "mrt2_glib2_test.h"
16 int main (int argc, char **argv)
21 char *srcdir = getenv ("srcdir");
33 char *current_locale = setlocale (LC_CTYPE, NULL);
38 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);
39 g_set_print_handler(mrtPrintHandler);
45 filename = g_strconcat (srcdir, G_DIR_SEPARATOR_S, "casemap.bin", NULL);
47 infile = fopen (filename, "r");
50 g_print("Failed to open %s\n", filename );
51 g_assert(FALSE && "unicode-caseconv failed");
54 testResultXml("unicode-caseconv");
60 while (fgets (buffer, sizeof(buffer), infile))
66 strings = g_strsplit (buffer, "\t", -1);
73 if (strcmp (locale, current_locale) != 0)
75 setlocale (LC_CTYPE, locale);
76 current_locale = setlocale (LC_CTYPE, NULL);
78 if (strncmp (current_locale, locale, 2) != 0)
80 g_print("Cannot set locale to %s, skipping\n", locale);
81 g_assert(FALSE && "unicode-caseconv failed");
88 convert = g_utf8_strup (test, -1);
89 if (strcmp (convert, strings[4]) != 0)
91 g_print("Failure: strup of line %d of casemap.bin toupper(%s) == %s, should have been %s\n",
92 lines,test, convert, strings[4]);
94 //g_assert(FALSE && "unicode-caseconv failed");
99 convert = g_utf8_strdown (test, -1);
100 if (strcmp (convert, strings[2]) != 0)
102 g_print("Failure: strdown of line %d of casemap.bin tolower(%s) == %s, should have been %s\n",
103 lines,test, convert, strings[2]);
104 //g_assert(FALSE && "unicode-caseconv failed");
111 g_strfreev (strings);
118 g_assert(passed && "unicode-caseconv failed");
120 filename = g_strconcat (srcdir, G_DIR_SEPARATOR_S, "casefold.bin", NULL);
122 infile = fopen (filename, "r");
125 g_print("Failed to open %s\n", filename );
126 g_assert(FALSE && "unicode-caseconv failed");
129 testResultXml("unicode-caseconv");
130 #endif /* EMULATOR */
136 while (fgets(buffer, sizeof(buffer), infile))
139 if (buffer[0] == '#')
142 buffer[strlen(buffer) - 1] = '\0';
143 strings = g_strsplit (buffer, "\t", -1);
147 convert = g_utf8_casefold (test, -1);
148 if (strcmp (convert, strings[1]) != 0)
150 g_print("Failure: line %d casefold(%s) == '%s', should have been '%s'\n",
151 lines,test, convert, strings[1]);
152 //g_assert(FALSE && "unicode-caseconv failed");
158 g_strfreev (strings);
163 g_assert(passed && "unicode-caseconv failed");
166 testResultXml("unicode-caseconv");
167 #endif /* EMULATOR */