powerpc: Fix ifuncmain6pie failure with GCC 4.9
[platform/upstream/glibc.git] / string / tst-strxfrm2.c
1 #include <locale.h>
2 #include <stdio.h>
3 #include <string.h>
4
5 static int
6 do_test (void)
7 {
8   int res = 0;
9
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)
15     {
16       puts ("C locale l3 test failed");
17       res = 1;
18     }
19
20   size_t l4 = strxfrm (buf, "ab", l1 + 1);
21   if (l4 < l1 + 1 && strlen (buf) != l4)
22     {
23       puts ("C locale l4 test failed");
24       res = 1;
25     }
26
27   buf[l1] = 'Z';
28   size_t l5 = strxfrm (buf, "ab", l1);
29   if (buf[l1] != 'Z')
30     {
31       puts ("C locale l5 test failed");
32       res = 1;
33     }
34
35   if (l1 != l2 || l1 != l3 || l1 != l4 || l1 != l5)
36     {
37       puts ("C locale retval test failed");
38       res = 1;
39     }
40
41   if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
42     {
43       puts ("setlocale failed");
44       res = 1;
45     }
46   else
47     {
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)
52         {
53           puts ("UTF-8 locale l3 test failed");
54           res = 1;
55         }
56
57       l4 = strxfrm (buf, "ab", l1 + 1);
58       if (l4 < l1 + 1 && strlen (buf) != l4)
59         {
60           puts ("UTF-8 locale l4 test failed");
61           res = 1;
62         }
63
64       buf[l1] = 'Z';
65       l5 = strxfrm (buf, "ab", l1);
66       if (buf[l1] != 'Z')
67         {
68           puts ("UTF-8 locale l5 test failed");
69           res = 1;
70         }
71
72       if (l1 != l2 || l1 != l3 || l1 != l4 || l1 != l5)
73         {
74           puts ("UTF-8 locale retval test failed");
75           res = 1;
76         }
77     }
78
79   return res;
80 }
81
82 #define TEST_FUNCTION do_test ()
83 #include "../test-skeleton.c"