1 #undef G_DISABLE_ASSERT
10 int main (int argc, char **argv)
20 char *current_locale = setlocale (LC_CTYPE, NULL);
23 g_test_init (&argc, &argv, NULL);
25 filename = g_test_build_filename (G_TEST_DIST, "casemap.txt", NULL);
27 infile = fopen (filename, "r");
30 fprintf (stderr, "Failed to open %s\n", filename );
34 while (fgets (buffer, sizeof(buffer), infile))
39 strings = g_strsplit (buffer, "\t", -1);
46 if (strcmp (locale, current_locale) != 0)
48 setlocale (LC_CTYPE, locale);
49 current_locale = setlocale (LC_CTYPE, NULL);
51 if (strncmp (current_locale, locale, 2) != 0)
53 fprintf (stderr, "Cannot set locale to %s, skipping\n", locale);
60 /* gen-casemap-txt.pl uses an empty string when a single character
61 * doesn't have an equivalent in a particular case; since that behavior
62 * is nonsense for multicharacter strings, it would make more sense
63 * to put the expected result .. the original character unchanged. But
64 * for now, we just work around it here and take the empty string to mean
68 convert = g_utf8_strup (test, -1);
69 expected = strings[4][0] ? strings[4] : test;
70 if (strcmp (convert, expected) != 0)
72 fprintf (stderr, "Failure: toupper(%s) == %s, should have been %s\n",
73 test, convert, expected);
78 convert = g_utf8_strdown (test, -1);
79 expected = strings[2][0] ? strings[2] : test;
80 if (strcmp (convert, expected) != 0)
82 fprintf (stderr, "Failure: tolower(%s) == %s, should have been %s\n",
83 test, convert, expected);
95 filename = g_test_build_filename (G_TEST_DIST, "casefold.txt", NULL);
97 infile = fopen (filename, "r");
100 fprintf (stderr, "Failed to open %s\n", filename );
105 while (fgets (buffer, sizeof(buffer), infile))
107 if (buffer[0] == '#')
110 buffer[strlen(buffer) - 1] = '\0';
111 strings = g_strsplit (buffer, "\t", -1);
115 convert = g_utf8_casefold (test, -1);
116 if (strcmp (convert, strings[1]) != 0)
118 fprintf (stderr, "Failure: casefold(%s) == '%s', should have been '%s'\n",
119 test, convert, strings[1]);
124 g_strfreev (strings);