* sysdeps/unix/sysv/linux/renameat.c (__atfct_seterrno_2): Correcty
[glibc.git] / libio / tst_swscanf.c
blob372f0fc7d3214dbbfb88e8f7d631edacf913b204
1 #include <stdio.h>
2 #include <string.h>
3 #include <wchar.h>
5 int
6 main (int argc, char *argv[])
8 const wchar_t in[] = L"7 + 35 is 42";
9 size_t n;
10 int a, b, c;
11 int result = 0;
12 char buf1[20];
13 wchar_t wbuf2[20];
14 char buf3[20];
15 char c4;
16 wchar_t wc5;
18 puts ("Test 1");
19 a = b = c = 0;
20 n = swscanf (in, L"%d + %d is %d", &a, &b, &c);
21 if (n != 3 || a + b != c || c != 42)
23 printf ("*** FAILED, n = %Zu, a = %d, b = %d, c = %d\n", n, a, b, c);
24 result = 1;
27 puts ("Test 2");
28 n = swscanf (L"one two three !!", L"%s %S %s %c%C",
29 buf1, wbuf2, buf3, &c4, &wc5);
30 if (n != 5 || strcmp (buf1, "one") != 0 || wcscmp (wbuf2, L"two") != 0
31 || strcmp (buf3, "three") != 0 || c4 != '!' || wc5 != L'!')
33 printf ("*** FAILED, n = %Zu, buf1 = \"%s\", wbuf2 = L\"%S\", buf3 = \"%s\", c4 = '%c', wc5 = L'%C'\n",
34 n, buf1, wbuf2, buf3, c4, (wint_t) wc5);
35 result = 1;
38 return result;