Update.
[glibc.git] / libio / tst_swscanf.c
blobce56144bb018cf24b4a99712948d4058a1c6dab6
1 #include <stdio.h>
2 #include <wchar.h>
4 int
5 main (int argc, char *argv[])
7 const wchar_t in[] = L"7 + 35 is 42";
8 size_t n;
9 int a, b, c;
10 int result = 0;
11 char buf1[20];
12 wchar_t wbuf2[20];
13 char buf3[20];
14 char c4;
15 wchar_t wc5;
17 puts ("Test 1");
18 a = b = c = 0;
19 n = swscanf (in, L"%d + %d is %d", &a, &b, &c);
20 if (n != 3 || a + b != c || c != 42)
22 printf ("*** FAILED, n = %Zu, a = %d, b = %d, c = %d\n", n, a, b, c);
23 result = 1;
26 puts ("Test 2");
27 n = swscanf (L"one two three !!", L"%s %S %s %c%C",
28 buf1, wbuf2, buf3, &c4, &wc5);
29 if (n != 5 || strcmp (buf1, "one") != 0 || wcscmp (wbuf2, L"two") != 0
30 || strcmp (buf3, "three") != 0 || c4 != '!' || wc5 != L'!')
32 printf ("*** FAILED, n = %Zu, buf1 = \"%s\", wbuf2 = L\"%S\", buf3 = \"%s\", c4 = '%c', wc5 = L'%C'\n",
33 n, buf1, wbuf2, buf3, c4, wc5);
34 result = 1;
37 return result;