mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-05 10:38:54 +01:00
.gitlab-ci
build
docs
fuzzing
gio
glib
gmodule
gobject
gthread
m4macros
po
subprojects
tests
collate
gobject
refcount
.gitignore
Makefile.am
assert-msg-test.c
assert-msg-test.gdb
asyncqueue-test.c
atomic-test.c
bit-test.c
casefold.txt
casemap.txt
child-test.c
completion-test.c
cxx-test.cpp
datetime.c
dirname-test.c
env-test.c
file-test.c
gen-casefold-txt.py
gen-casemap-txt.py
gio-test.c
iochannel-test-infile
iochannel-test.c
libmoduletestplugin_a.c
libmoduletestplugin_b.c
mainloop-test.c
mapping-test.c
memchunks.c
meson.build
module-test.c
onceinit.c
qsort-test.c
relation-test.c
run-assert-msg-test.sh
run-collate-tests.sh
slice-color.c
slice-concurrent.c
slice-test.c
slice-threadinit.c
sources.c
spawn-test-win32-gui.c
spawn-test.c
testgdate.c
testgdateparser.c
testglib.c
thread-test.c
threadpool-test.c
timeloop-basic.c
timeloop.c
type-test.c
unicode-caseconv.c
unicode-collate.c
unicode-encoding.c
unicode-normalize.c
utf8.txt
.dir-locals.el
.gitattributes
.gitignore
.gitlab-ci.yml
AUTHORS
CONTRIBUTING.md
COPYING
HACKING
INSTALL.in
Makefile.am
NEWS
NEWS.pre-1-3
README
README.md
README.rationale
README.win32
acglib.m4
acinclude.m4
autogen.sh
check-abis.sh
configure.ac
gio-2.0.pc.in
gio-unix-2.0.pc.in
gio-windows-2.0.pc.in
glib-2.0.pc.in
glib-gettextize.in
glib-tap.mk
glib.doap
glib.mk
glib.supp
gmodule-2.0.pc.in
gmodule-export-2.0.pc.in
gmodule-no-export-2.0.pc.in
gobject-2.0.pc.in
gthread-2.0.pc.in
meson.build
meson_options.txt
msvc_recommended_pragmas.h
sanity_check
tap-driver.sh
tap-test
template-tap.test.in
template.test.in
132 lines
3.0 KiB
C
132 lines
3.0 KiB
C
#undef G_DISABLE_ASSERT
|
|
#undef G_LOG_DOMAIN
|
|
|
|
#include <locale.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <glib.h>
|
|
#include <string.h>
|
|
|
|
int main (int argc, char **argv)
|
|
{
|
|
FILE *infile;
|
|
char buffer[1024];
|
|
char **strings;
|
|
char *filename;
|
|
const char *locale;
|
|
const char *test;
|
|
const char *expected;
|
|
char *convert;
|
|
char *current_locale = setlocale (LC_CTYPE, NULL);
|
|
gint result = 0;
|
|
|
|
g_test_init (&argc, &argv, NULL);
|
|
|
|
filename = g_test_build_filename (G_TEST_DIST, "casemap.txt", NULL);
|
|
|
|
infile = fopen (filename, "r");
|
|
if (!infile)
|
|
{
|
|
fprintf (stderr, "Failed to open %s\n", filename );
|
|
exit (1);
|
|
}
|
|
|
|
while (fgets (buffer, sizeof(buffer), infile))
|
|
{
|
|
if (buffer[0] == '#')
|
|
continue;
|
|
|
|
strings = g_strsplit (buffer, "\t", -1);
|
|
|
|
locale = strings[0];
|
|
|
|
if (!locale[0])
|
|
locale = "C";
|
|
|
|
if (strcmp (locale, current_locale) != 0)
|
|
{
|
|
setlocale (LC_CTYPE, locale);
|
|
current_locale = setlocale (LC_CTYPE, NULL);
|
|
|
|
if (strncmp (current_locale, locale, 2) != 0)
|
|
{
|
|
fprintf (stderr, "Cannot set locale to %s, skipping\n", locale);
|
|
goto next;
|
|
}
|
|
}
|
|
|
|
test = strings[1];
|
|
|
|
/* gen-casemap-txt.py uses an empty string when a single character
|
|
* doesn't have an equivalent in a particular case; since that behavior
|
|
* is nonsense for multicharacter strings, it would make more sense
|
|
* to put the expected result .. the original character unchanged. But
|
|
* for now, we just work around it here and take the empty string to mean
|
|
* "same as original"
|
|
*/
|
|
|
|
convert = g_utf8_strup (test, -1);
|
|
expected = strings[4][0] ? strings[4] : test;
|
|
if (strcmp (convert, expected) != 0)
|
|
{
|
|
fprintf (stderr, "Failure: toupper(%s) == %s, should have been %s\n",
|
|
test, convert, expected);
|
|
result = 1;
|
|
}
|
|
g_free (convert);
|
|
|
|
convert = g_utf8_strdown (test, -1);
|
|
expected = strings[2][0] ? strings[2] : test;
|
|
if (strcmp (convert, expected) != 0)
|
|
{
|
|
fprintf (stderr, "Failure: tolower(%s) == %s, should have been %s\n",
|
|
test, convert, expected);
|
|
result = 1;
|
|
}
|
|
g_free (convert);
|
|
|
|
next:
|
|
g_strfreev (strings);
|
|
}
|
|
|
|
fclose (infile);
|
|
|
|
g_free (filename);
|
|
filename = g_test_build_filename (G_TEST_DIST, "casefold.txt", NULL);
|
|
|
|
infile = fopen (filename, "r");
|
|
if (!infile)
|
|
{
|
|
fprintf (stderr, "Failed to open %s\n", filename );
|
|
g_free (filename);
|
|
exit (1);
|
|
}
|
|
|
|
while (fgets (buffer, sizeof(buffer), infile))
|
|
{
|
|
if (buffer[0] == '#')
|
|
continue;
|
|
|
|
buffer[strlen(buffer) - 1] = '\0';
|
|
strings = g_strsplit (buffer, "\t", -1);
|
|
|
|
test = strings[0];
|
|
|
|
convert = g_utf8_casefold (test, -1);
|
|
if (strcmp (convert, strings[1]) != 0)
|
|
{
|
|
fprintf (stderr, "Failure: casefold(%s) == '%s', should have been '%s'\n",
|
|
test, convert, strings[1]);
|
|
result = 1;
|
|
}
|
|
g_free (convert);
|
|
|
|
g_strfreev (strings);
|
|
}
|
|
|
|
fclose (infile);
|
|
g_free (filename);
|
|
|
|
return result;
|
|
}
|