2001-08-15 00:25:47 +02:00
|
|
|
|
#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<EFBFBD>nslit", -1 },
|
|
|
|
|
{ "de_DE.UTF-8", "TRANSLIT", "translit", 0 },
|
|
|
|
|
{ "de_DE.ISO-8859-1", "<EFBFBD>", "<EFBFBD>", 1 }
|
|
|
|
|
};
|
|
|
|
|
#define ntests (sizeof (tests) / sizeof (tests[0]))
|
|
|
|
|
|
|
|
|
|
|
2014-11-05 10:54:08 +01:00
|
|
|
|
static int
|
|
|
|
|
do_test (void)
|
2001-08-15 00:25:47 +02:00
|
|
|
|
{
|
2002-09-25 05:26:16 +02:00
|
|
|
|
size_t cnt;
|
2001-08-15 00:25:47 +02:00
|
|
|
|
int result = 0;
|
2002-08-28 10:44:07 +02:00
|
|
|
|
locale_t loc = newlocale (1 << LC_ALL, "C", NULL);
|
2001-08-15 00:25:47 +02:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-28 10:44:07 +02:00
|
|
|
|
printf ("\nstrcasecmp_l (\"%s\", \"%s\", loc)\n",
|
2001-08-15 00:25:47 +02:00
|
|
|
|
tests[cnt].str1, tests[cnt].str2);
|
|
|
|
|
|
2002-08-28 10:44:07 +02:00
|
|
|
|
r = strcasecmp_l (tests[cnt].str1, tests[cnt].str2, loc);
|
2001-08-15 00:25:47 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
2014-11-05 10:54:08 +01:00
|
|
|
|
|
|
|
|
|
#define TEST_FUNCTION do_test ()
|
|
|
|
|
#include "../test-skeleton.c"
|