MIPSr6/math: Use builtin fma and fmaf
[glibc.git] / string / tst-strxfrm2.c
blob12117e80d63494aceda06f5b6dfa27df22776c07
1 #include <locale.h>
2 #include <stdio.h>
3 #include <string.h>
5 int
6 do_test (void)
8 static const char test_locale[] = "de_DE.UTF-8";
10 int res = 0;
12 char buf[20];
13 size_t l1 = strxfrm (NULL, "ab", 0);
14 size_t l2 = strxfrm (buf, "ab", 1);
15 size_t l3 = strxfrm (buf, "ab", sizeof (buf));
16 if (l3 < sizeof (buf) && strlen (buf) != l3)
18 puts ("C locale l3 test failed");
19 res = 1;
22 size_t l4 = strxfrm (buf, "ab", l1 + 1);
23 if (l4 < l1 + 1 && strlen (buf) != l4)
25 puts ("C locale l4 test failed");
26 res = 1;
29 buf[l1] = 'Z';
30 size_t l5 = strxfrm (buf, "ab", l1);
31 if (buf[l1] != 'Z')
33 puts ("C locale l5 test failed");
34 res = 1;
37 if (l1 != l2 || l1 != l3 || l1 != l4 || l1 != l5)
39 puts ("C locale retval test failed");
40 res = 1;
43 if (setlocale (LC_ALL, test_locale) == NULL)
45 printf ("cannot set locale \"%s\"\n", test_locale);
46 res = 1;
48 else
50 l1 = strxfrm (NULL, "ab", 0);
51 l2 = strxfrm (buf, "ab", 1);
52 l3 = strxfrm (buf, "ab", sizeof (buf));
53 if (l3 < sizeof (buf) && strlen (buf) != l3)
55 puts ("UTF-8 locale l3 test failed");
56 res = 1;
59 l4 = strxfrm (buf, "ab", l1 + 1);
60 if (l4 < l1 + 1 && strlen (buf) != l4)
62 puts ("UTF-8 locale l4 test failed");
63 res = 1;
66 buf[l1] = 'Z';
67 l5 = strxfrm (buf, "ab", l1);
68 if (buf[l1] != 'Z')
70 puts ("UTF-8 locale l5 test failed");
71 res = 1;
74 if (l1 != l2 || l1 != l3 || l1 != l4 || l1 != l5)
76 puts ("UTF-8 locale retval test failed");
77 res = 1;
81 return res;
84 #include <support/test-driver.c>