6 static int do_test(const char *loc
);
14 result
= do_test("C");
15 result
|= do_test("de_DE.ISO-8859-1");
16 result
|= do_test("de_DE.UTF-8");
17 result
|= do_test("ja_JP.EUC-JP");
31 { L
"%[abc]", L
"%l[abc]", L
"aabbccddaabb", 1 ,"aabbcc", L
"aabbcc", 0 },
32 { L
"%[^def]", L
"%l[^def]", L
"aabbccddaabb", 1, "aabbcc", L
"aabbcc", 0 },
33 { L
"%[^abc]", L
"%l[^abc]", L
"aabbccddaabb", 0, "", L
"", 0 },
34 { L
"%[a-c]", L
"%l[a-c]", L
"aabbccddaabb", 1, "aabbcc", L
"aabbcc", 1 },
35 { L
"%[^d-f]", L
"%l[^d-f]", L
"aabbccddaabb", 1, "aabbcc", L
"aabbcc", 1 },
36 { L
"%[^a-c]", L
"%l[^a-c]", L
"aabbccddaabb", 0, "", L
"", 1 },
37 { L
"%[^a-c]", L
"%l[^a-c]", L
"bbccddaabb", 0, "", L
"", 1 }
42 do_test(const char *loc
)
47 if (setlocale(LC_ALL
, loc
) == NULL
) {
48 printf("cannot set locale \"%s\": %m\n", loc
);
52 printf("\nnew locale: \"%s\"\n", loc
);
54 for (n
= 0; n
< sizeof(tests
) / sizeof(tests
[0]); ++n
) {
58 if (tests
[n
].only_C_locale
&& strcmp(loc
, "C") != 0)
61 if (swscanf(tests
[n
].arg
, tests
[n
].fmt
, buf
) != tests
[n
].retval
) {
62 printf("swscanf (\"%S\", \"%S\", ...) failed\n", tests
[n
].arg
,
65 } else if (tests
[n
].retval
!= 0 && strcmp(buf
, tests
[n
].res
) != 0) {
67 "swscanf (\"%S\", \"%S\", ...) return \"%s\", expected \"%s\"\n",
68 tests
[n
].arg
, tests
[n
].fmt
, buf
, tests
[n
].res
);
71 printf("swscanf (\"%S\", \"%S\", ...) OK\n", tests
[n
].arg
,
74 if (swscanf(tests
[n
].arg
, tests
[n
].wfmt
, wbuf
) != tests
[n
].retval
) {
75 printf("swscanf (\"%S\", \"%S\", ...) failed\n", tests
[n
].arg
,
78 } else if (tests
[n
].retval
!= 0 && wcscmp(wbuf
, tests
[n
].wres
) != 0) {
80 "swscanf (\"%S\", \"%S\", ...) return \"%S\", expected \"%S\"\n",
81 tests
[n
].arg
, tests
[n
].wfmt
, wbuf
, tests
[n
].wres
);
84 printf("swscanf (\"%S\", \"%S\", ...) OK\n", tests
[n
].arg
,