1 #include <locale.h>
2 #include <stdio.h>
3 #include <wchar.h>
4 
5 
6 static int
do_test(void)7 do_test (void)
8 {
9   if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
10     {
11       puts ("setlocale failed");
12       return 1;
13     }
14 
15   if (setvbuf (stdin, NULL, _IONBF, 0) != 0)
16     {
17       puts ("setvbuf failed");
18       return 1;
19     }
20 
21   wchar_t buf[100];
22   size_t nbuf = 0;
23   wint_t c;
24   while ((c = fgetwc (stdin)) != WEOF)
25     buf[nbuf++] = c;
26 
27   if (ferror (stdin))
28     {
29       puts ("error on stdin");
30       return 1;
31     }
32 
33   const wchar_t expected[] =
34     {
35       0x00000439, 0x00000446, 0x00000443, 0x0000043a,
36       0x00000435, 0x0000043d, 0x0000000a, 0x00000071,
37       0x00000077, 0x00000065, 0x00000072, 0x00000074,
38       0x00000079, 0x0000000a
39     };
40 
41   if (nbuf != sizeof (expected) / sizeof (expected[0])
42       || wmemcmp (expected, buf, nbuf) != 0)
43     {
44       puts ("incorrect result");
45       return 1;
46     }
47 
48   return 0;
49 }
50 
51 #define TEST_FUNCTION do_test ()
52 #include "../test-skeleton.c"
53