Blame localedata/tst-xlocale1.c

Packit 6c4009
#include <locale.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <string.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
static struct
Packit 6c4009
{
Packit 6c4009
  const char *locale;
Packit 6c4009
  const char *str1;
Packit 6c4009
  const char *str2;
Packit 6c4009
  int result;
Packit 6c4009
} tests[] =
Packit 6c4009
  {
Packit 6c4009
    { "C", "TRANSLIT", "translit", 0 },
Packit 6c4009
    { "de_DE.ISO-8859-1", "TRANSLIT", "translit", 0 },
Packit 6c4009
    { "de_DE.ISO-8859-1", "TRANSLIT", "trÄnslit", -1 },
Packit 6c4009
    { "de_DE.UTF-8", "TRANSLIT", "translit", 0 },
Packit 6c4009
    { "de_DE.ISO-8859-1", "ä", "Ä", 1 }
Packit 6c4009
  };
Packit 6c4009
#define ntests (sizeof (tests) / sizeof (tests[0]))
Packit 6c4009
Packit 6c4009
Packit 6c4009
static int
Packit 6c4009
do_test (void)
Packit 6c4009
{
Packit 6c4009
  size_t cnt;
Packit 6c4009
  int result = 0;
Packit 6c4009
  locale_t loc = newlocale (1 << LC_ALL, "C", NULL);
Packit 6c4009
Packit 6c4009
  for (cnt = 0; cnt < ntests; ++cnt)
Packit 6c4009
    {
Packit 6c4009
      int r;
Packit 6c4009
Packit 6c4009
      if (setlocale (LC_ALL, tests[cnt].locale) == NULL)
Packit 6c4009
	{
Packit 6c4009
	  printf ("cannot set locale \"%s\": %m\n", tests[cnt].locale);
Packit 6c4009
	  result = 1;
Packit 6c4009
	  continue;
Packit 6c4009
	}
Packit 6c4009
Packit 6c4009
      printf ("\nstrcasecmp_l (\"%s\", \"%s\", loc)\n",
Packit 6c4009
	      tests[cnt].str1, tests[cnt].str2);
Packit 6c4009
Packit 6c4009
      r = strcasecmp_l (tests[cnt].str1, tests[cnt].str2, loc);
Packit 6c4009
      if (tests[cnt].result == 0)
Packit 6c4009
	{
Packit 6c4009
	  if (r != 0)
Packit 6c4009
	    {
Packit 6c4009
	      printf ("\"%s\" and \"%s\" expected to be the same, result %d\n",
Packit 6c4009
		      tests[cnt].str1, tests[cnt].str2, r);
Packit 6c4009
	      result = 1;
Packit 6c4009
	    }
Packit 6c4009
	}
Packit 6c4009
      else if (tests[cnt].result < 0)
Packit 6c4009
	{
Packit 6c4009
	  if (r >= 0)
Packit 6c4009
	    {
Packit 6c4009
	      printf ("\"%s\" expected to be smaller than \"%s\", result %d\n",
Packit 6c4009
		      tests[cnt].str1, tests[cnt].str2, r);
Packit 6c4009
	      result = 1;
Packit 6c4009
	    }
Packit 6c4009
	}
Packit 6c4009
      else
Packit 6c4009
	{
Packit 6c4009
	  if (r <= 0)
Packit 6c4009
	    {
Packit 6c4009
	      printf ("\"%s\" expected to be larger than \"%s\", result %d\n",
Packit 6c4009
		      tests[cnt].str1, tests[cnt].str2, r);
Packit 6c4009
	      result = 1;
Packit 6c4009
	    }
Packit 6c4009
	}
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  return result;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#define TEST_FUNCTION do_test ()
Packit 6c4009
#include "../test-skeleton.c"