diff options
author | Zack Weinberg <zackw@panix.com> | 2017-06-08 15:39:03 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2017-06-08 15:39:03 -0400 |
commit | 5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch) | |
tree | 4470480d904b65cf14ca524f96f79eca818c3eaf /REORG.TODO/localedata/tst-xlocale1.c | |
parent | 199fc19d3aaaf57944ef036e15904febe877fc93 (diff) | |
download | glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.gz glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.xz glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.zip |
Prepare for radical source tree reorganization. zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage directory, REORG.TODO, except for files that will certainly still exist in their current form at top level when we're done (COPYING, COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which are moved to the new directory OldChangeLogs, instead), and the generated file INSTALL (which is just deleted; in the new order, there will be no generated files checked into version control).
Diffstat (limited to 'REORG.TODO/localedata/tst-xlocale1.c')
-rw-r--r-- | REORG.TODO/localedata/tst-xlocale1.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/REORG.TODO/localedata/tst-xlocale1.c b/REORG.TODO/localedata/tst-xlocale1.c new file mode 100644 index 0000000000..9f545a02c3 --- /dev/null +++ b/REORG.TODO/localedata/tst-xlocale1.c @@ -0,0 +1,78 @@ +#include <locale.h> +#include <stdio.h> +#include <string.h> + + +static struct +{ + const char *locale; + const char *str1; + const char *str2; + int result; +} tests[] = + { + { "C", "TRANSLIT", "translit", 0 }, + { "de_DE.ISO-8859-1", "TRANSLIT", "translit", 0 }, + { "de_DE.ISO-8859-1", "TRANSLIT", "trÄnslit", -1 }, + { "de_DE.UTF-8", "TRANSLIT", "translit", 0 }, + { "de_DE.ISO-8859-1", "ä", "Ä", 1 } + }; +#define ntests (sizeof (tests) / sizeof (tests[0])) + + +static int +do_test (void) +{ + size_t cnt; + int result = 0; + locale_t loc = newlocale (1 << LC_ALL, "C", NULL); + + for (cnt = 0; cnt < ntests; ++cnt) + { + int r; + + if (setlocale (LC_ALL, tests[cnt].locale) == NULL) + { + printf ("cannot set locale \"%s\": %m\n", tests[cnt].locale); + result = 1; + continue; + } + + printf ("\nstrcasecmp_l (\"%s\", \"%s\", loc)\n", + tests[cnt].str1, tests[cnt].str2); + + r = strcasecmp_l (tests[cnt].str1, tests[cnt].str2, loc); + if (tests[cnt].result == 0) + { + if (r != 0) + { + printf ("\"%s\" and \"%s\" expected to be the same, result %d\n", + tests[cnt].str1, tests[cnt].str2, r); + result = 1; + } + } + else if (tests[cnt].result < 0) + { + if (r >= 0) + { + printf ("\"%s\" expected to be smaller than \"%s\", result %d\n", + tests[cnt].str1, tests[cnt].str2, r); + result = 1; + } + } + else + { + if (r <= 0) + { + printf ("\"%s\" expected to be larger than \"%s\", result %d\n", + tests[cnt].str1, tests[cnt].str2, r); + result = 1; + } + } + } + + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" |