summaryrefslogtreecommitdiff
path: root/localedata/tst-xlocale2.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-18 02:46:36 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-18 02:46:36 +0000
commit89f29a0742e0dc8fa764a2dbb09c06e25909dac9 (patch)
tree119775c91d97fb2e9bd7833b251ac39d30577507 /localedata/tst-xlocale2.c
parent0f4b99a643216c5ffea5bc3b2b1ae1d6940ae550 (diff)
Update.
* locale/duplocale.c (__duplocale): Also initialize the special __ctype_* elements.
Diffstat (limited to 'localedata/tst-xlocale2.c')
-rw-r--r--localedata/tst-xlocale2.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/localedata/tst-xlocale2.c b/localedata/tst-xlocale2.c
new file mode 100644
index 0000000000..224cccb12f
--- /dev/null
+++ b/localedata/tst-xlocale2.c
@@ -0,0 +1,64 @@
+#include <ctype.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static int do_test (__locale_t l);
+
+int
+main (void)
+{
+ __locale_t l;
+ __locale_t l2;
+ int result;
+
+ l = __newlocale (1 << LC_ALL, "de_DE.ISO-8859-1", NULL);
+ if (l == NULL)
+ {
+ printf ("__newlocale failed: %m\n");
+ exit (EXIT_FAILURE);
+ }
+ puts ("Running tests of created locale");
+ result = do_test (l);
+
+ l2 = __duplocale (l);
+ if (l2 == NULL)
+ {
+ printf ("__duplocale failed: %m\n");
+ exit (EXIT_FAILURE);
+ }
+ __freelocale (l);
+ puts ("Running tests of duplicated locale");
+ result |= do_test (l2);
+
+ return result;
+}
+
+
+static const char str[] = "0123456789abcdef ABCDEF ghijklmnopqrstuvwxyzäÄöÖüÜ";
+static const char exd[] = "11111111110000000000000000000000000000000000000000";
+static const char exa[] = "00000000001111110111111011111111111111111111111111";
+static const char exx[] = "11111111111111110111111000000000000000000000000000";
+
+
+static int
+do_test (__locale_t l)
+{
+ int result = 0;
+ int n;
+
+#define DO_TEST(TEST, RES) \
+ for (n = 0; n < sizeof (str) - 1; ++n) \
+ if ('0' + (TEST (str[n], l) != 0) != RES[n]) \
+ { \
+ printf ("%s(%c) failed\n", #TEST, str[n]); \
+ result = 1; \
+ }
+
+ DO_TEST (__isdigit_l, exd);
+ DO_TEST (__isalpha_l, exa);
+ DO_TEST (__isxdigit_l, exx);
+
+ return result;
+}