[BZ #5112]
[glibc/pb-stable.git] / stdio-common / bug20.c
blob385f6ffbe169d31dd3273a960dd6c66799bf425f
1 /* BZ #5225 */
2 #include <stdio.h>
3 #include <string.h>
4 #include <wchar.h>
6 static int
7 do_test (void)
9 wchar_t in[] = L"123,abc,321";
10 /* This is the critical part for this test. format must be in
11 read-only memory. */
12 static const wchar_t format[50] = L"%d,%[^,],%d";
13 int out_d1, out_d2;
14 char out_s[50];
15 printf ("in='%ls' format='%ls'\n", in, format);
16 if (swscanf (in, format, &out_d1, out_s, &out_d2) != 3)
18 puts ("swscanf did not return 3");
19 return 1;
21 printf ("in='%ls' format='%ls'\n", in, format);
22 printf ("out_d1=%d out_s='%s' out_d2=%d\n", out_d1, out_s, out_d2);
23 if (out_d1 != 123 || strcmp (out_s, "abc") != 0 || out_d2 != 321)
25 puts ("swscanf did not return the correct values");
26 return 1;
28 return 0;
31 #define TEST_FUNCTION do_test ()
32 #include "../test-skeleton.c"