Updated to fedora-glibc-20090204T2135
[glibc.git] / libio / tst-fgetwc.c
blob9ccfeb15263fc3652c2d6f2401f3edaa45d927f1
1 #include <locale.h>
2 #include <stdio.h>
3 #include <wchar.h>
6 static int
7 do_test (void)
9 if (setlocale (LC_ALL, "de_DE.utf8") == NULL)
11 puts ("setlocale failed");
12 return 1;
15 if (setvbuf (stdin, NULL, _IONBF, 0) != 0)
17 puts ("setvbuf failed");
18 return 1;
21 wchar_t buf[100];
22 size_t nbuf = 0;
23 wint_t c;
24 while ((c = fgetwc (stdin)) != WEOF)
25 buf[nbuf++] = c;
27 if (ferror (stdin))
29 puts ("error on stdin");
30 return 1;
33 const wchar_t expected[] =
35 0x00000439, 0x00000446, 0x00000443, 0x0000043a,
36 0x00000435, 0x0000043d, 0x0000000a, 0x00000071,
37 0x00000077, 0x00000065, 0x00000072, 0x00000074,
38 0x00000079, 0x0000000a
41 if (nbuf != sizeof (expected) / sizeof (expected[0])
42 || wmemcmp (expected, buf, nbuf) != 0)
44 puts ("incorrect result");
45 return 1;
48 return 0;
51 #define TEST_FUNCTION do_test ()
52 #include "../test-skeleton.c"