1#include <locale.h>
2#include <stdio.h>
3#include <wchar.h>
4
5
6static int
7do_test (void)
8{
9 if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
10 {
11 puts (s: "setlocale failed");
12 return 1;
13 }
14
15 if (setvbuf (stdin, NULL, _IONBF, n: 0) != 0)
16 {
17 puts (s: "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 (s: "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 (s1: expected, s2: buf, n: nbuf) != 0)
43 {
44 puts (s: "incorrect result");
45 return 1;
46 }
47
48 return 0;
49}
50
51#define TEST_FUNCTION do_test ()
52#include "../test-skeleton.c"
53

source code of glibc/libio/tst-fgetwc.c