ARM: Consolidate with generic unwinder wrapper code
[glibc.git] / string / tst-strxfrm2.c
blobd5a1115338b7c12c483e26b5a37a2fde498fb275
1 #include <locale.h>
2 #include <stdio.h>
3 #include <string.h>
5 static int
6 do_test (void)
8 int res = 0;
10 char buf[20];
11 size_t l1 = strxfrm (NULL, "ab", 0);
12 size_t l2 = strxfrm (buf, "ab", 1);
13 size_t l3 = strxfrm (buf, "ab", sizeof (buf));
14 if (l3 < sizeof (buf) && strlen (buf) != l3)
16 puts ("C locale l3 test failed");
17 res = 1;
20 size_t l4 = strxfrm (buf, "ab", l1 + 1);
21 if (l4 < l1 + 1 && strlen (buf) != l4)
23 puts ("C locale l4 test failed");
24 res = 1;
27 buf[l1] = 'Z';
28 size_t l5 = strxfrm (buf, "ab", l1);
29 if (buf[l1] != 'Z')
31 puts ("C locale l5 test failed");
32 res = 1;
35 if (l1 != l2 || l1 != l3 || l1 != l4 || l1 != l5)
37 puts ("C locale retval test failed");
38 res = 1;
41 if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
43 puts ("setlocale failed");
44 res = 1;
46 else
48 l1 = strxfrm (NULL, "ab", 0);
49 l2 = strxfrm (buf, "ab", 1);
50 l3 = strxfrm (buf, "ab", sizeof (buf));
51 if (l3 < sizeof (buf) && strlen (buf) != l3)
53 puts ("UTF-8 locale l3 test failed");
54 res = 1;
57 l4 = strxfrm (buf, "ab", l1 + 1);
58 if (l4 < l1 + 1 && strlen (buf) != l4)
60 puts ("UTF-8 locale l4 test failed");
61 res = 1;
64 buf[l1] = 'Z';
65 l5 = strxfrm (buf, "ab", l1);
66 if (buf[l1] != 'Z')
68 puts ("UTF-8 locale l5 test failed");
69 res = 1;
72 if (l1 != l2 || l1 != l3 || l1 != l4 || l1 != l5)
74 puts ("UTF-8 locale retval test failed");
75 res = 1;
79 return res;
82 #define TEST_FUNCTION do_test ()
83 #include "../test-skeleton.c"