summary refs log tree commit diff
path: root/localedata
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-14 22:25:47 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-14 22:25:47 +0000
commit1b46e4a5a24d5049ef90cf16a6a851bf796b5782 (patch)
tree8c053df53d065fdd34eb625bea5dcb46ad9123a1 /localedata
parent908b8bbc06e067927f54d58f884c354e786d5e9d (diff)
downloadglibc-1b46e4a5a24d5049ef90cf16a6a851bf796b5782.tar.gz
glibc-1b46e4a5a24d5049ef90cf16a6a851bf796b5782.tar.xz
glibc-1b46e4a5a24d5049ef90cf16a6a851bf796b5782.zip
Test of __strcasecmp_l.
Diffstat (limited to 'localedata')
-rw-r--r--localedata/tst-xlocale1.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/localedata/tst-xlocale1.c b/localedata/tst-xlocale1.c
new file mode 100644
index 0000000000..bfe978f485
--- /dev/null
+++ b/localedata/tst-xlocale1.c
@@ -0,0 +1,75 @@
+#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]))
+
+
+int
+main (void)
+{
+  int 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 ("\n__strcasecmp_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;
+}