1 #undef G_DISABLE_ASSERT
10 int main (int argc, char **argv)
21 char *current_locale = setlocale (LC_CTYPE, NULL);
24 if (g_getenv ("G_TEST_DATA"))
25 srcdir = g_getenv ("G_TEST_DATA");
29 filename = g_strconcat (srcdir, G_DIR_SEPARATOR_S, "casemap.txt", NULL);
31 infile = fopen (filename, "r");
34 fprintf (stderr, "Failed to open %s\n", filename );
38 while (fgets (buffer, sizeof(buffer), infile))
43 strings = g_strsplit (buffer, "\t", -1);
50 if (strcmp (locale, current_locale) != 0)
52 setlocale (LC_CTYPE, locale);
53 current_locale = setlocale (LC_CTYPE, NULL);
55 if (strncmp (current_locale, locale, 2) != 0)
57 fprintf (stderr, "Cannot set locale to %s, skipping\n", locale);
64 /* gen-casemap-txt.pl uses an empty string when a single character
65 * doesn't have an equivalent in a particular case; since that behavior
66 * is nonsense for multicharacter strings, it would make more sense
67 * to put the expected result .. the original character unchanged. But
68 * for now, we just work around it here and take the empty string to mean
72 convert = g_utf8_strup (test, -1);
73 expected = strings[4][0] ? strings[4] : test;
74 if (strcmp (convert, expected) != 0)
76 fprintf (stderr, "Failure: toupper(%s) == %s, should have been %s\n",
77 test, convert, expected);
82 convert = g_utf8_strdown (test, -1);
83 expected = strings[2][0] ? strings[2] : test;
84 if (strcmp (convert, expected) != 0)
86 fprintf (stderr, "Failure: tolower(%s) == %s, should have been %s\n",
87 test, convert, expected);
99 filename = g_strconcat (srcdir, G_DIR_SEPARATOR_S, "casefold.txt", NULL);
101 infile = fopen (filename, "r");
104 fprintf (stderr, "Failed to open %s\n", filename );
109 while (fgets (buffer, sizeof(buffer), infile))
111 if (buffer[0] == '#')
114 buffer[strlen(buffer) - 1] = '\0';
115 strings = g_strsplit (buffer, "\t", -1);
119 convert = g_utf8_casefold (test, -1);
120 if (strcmp (convert, strings[1]) != 0)
122 fprintf (stderr, "Failure: casefold(%s) == '%s', should have been '%s'\n",
123 test, convert, strings[1]);
128 g_strfreev (strings);