7 static int do_test (const char *loc
);
15 result
= do_test ("C");
16 result
|= do_test ("de_DE.ISO-8859-1");
17 result
|= do_test ("de_DE.UTF-8");
18 result
|= do_test ("ja_JP.EUC-JP");
34 { L
"%[abc]", L
"%l[abc]", L
"aabbccddaabb", "aabbcc", L
"aabbcc", 0 },
35 { L
"%[^def]", L
"%l[^def]", L
"aabbccddaabb", "aabbcc", L
"aabbcc", 0 },
36 { L
"%[^abc]", L
"%l[^abc]", L
"aabbccddaabb", "", L
"", 0 },
37 { L
"%[a-c]", L
"%l[a-c]", L
"aabbccddaabb", "aabbcc", L
"aabbcc", 1 },
38 { L
"%[^d-f]", L
"%l[^d-f]", L
"aabbccddaabb", "aabbcc", L
"aabbcc", 1 },
39 { L
"%[^a-c]", L
"%l[^a-c]", L
"aabbccddaabb", "", L
"", 1 },
40 { L
"%[^a-c]", L
"%l[^a-c]", L
"bbccddaabb", "", L
"", 1 }
45 do_test (const char *loc
)
50 if (setlocale (LC_ALL
, loc
) == NULL
)
52 printf ("cannot set locale \"%s\": %m\n", loc
);
56 printf ("\nnew locale: \"%s\"\n", loc
);
58 for (n
= 0; n
< sizeof (tests
) / sizeof (tests
[0]); ++n
)
63 if (tests
[n
].only_C_locale
&& strcmp (loc
, "C") != 0)
66 if (swscanf (tests
[n
].arg
, tests
[n
].fmt
, buf
) != 1)
68 printf ("swscanf (\"%S\", \"%S\", ...) failed\n",
69 tests
[n
].arg
, tests
[n
].fmt
);
72 else if (strcmp (buf
, tests
[n
].res
) != 0)
74 printf ("swscanf (\"%S\", \"%S\", ...) return \"%s\", expected \"%s\"\n",
75 tests
[n
].arg
, tests
[n
].fmt
, buf
, tests
[n
].res
);
79 printf ("swscanf (\"%S\", \"%S\", ...) OK\n",
80 tests
[n
].arg
, tests
[n
].fmt
);
82 if (swscanf (tests
[n
].arg
, tests
[n
].wfmt
, wbuf
) != 1)
84 printf ("swscanf (\"%S\", \"%S\", ...) failed\n",
85 tests
[n
].arg
, tests
[n
].wfmt
);
88 else if (wcscmp (wbuf
, tests
[n
].wres
) != 0)
90 printf ("swscanf (\"%S\", \"%S\", ...) return \"%S\", expected \"%S\"\n",
91 tests
[n
].arg
, tests
[n
].wfmt
, wbuf
, tests
[n
].wres
);
95 printf ("swscanf (\"%S\", \"%S\", ...) OK\n",
96 tests
[n
].arg
, tests
[n
].wfmt
);