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");
35 { L
"%[abc]", L
"%l[abc]", L
"aabbccddaabb", 1 ,"aabbcc", L
"aabbcc", 0 },
36 { L
"%[^def]", L
"%l[^def]", L
"aabbccddaabb", 1, "aabbcc", L
"aabbcc", 0 },
37 { L
"%[^abc]", L
"%l[^abc]", L
"aabbccddaabb", 0, "", L
"", 0 },
38 { L
"%[a-c]", L
"%l[a-c]", L
"aabbccddaabb", 1, "aabbcc", L
"aabbcc", 1 },
39 { L
"%[^d-f]", L
"%l[^d-f]", L
"aabbccddaabb", 1, "aabbcc", L
"aabbcc", 1 },
40 { L
"%[^a-c]", L
"%l[^a-c]", L
"aabbccddaabb", 0, "", L
"", 1 },
41 { L
"%[^a-c]", L
"%l[^a-c]", L
"bbccddaabb", 0, "", L
"", 1 }
46 do_test (const char *loc
)
51 if (setlocale (LC_ALL
, loc
) == NULL
)
53 printf ("cannot set locale \"%s\": %m\n", loc
);
57 printf ("\nnew locale: \"%s\"\n", loc
);
59 for (n
= 0; n
< sizeof (tests
) / sizeof (tests
[0]); ++n
)
64 if (tests
[n
].only_C_locale
&& strcmp (loc
, "C") != 0)
67 if (swscanf (tests
[n
].arg
, tests
[n
].fmt
, buf
) != tests
[n
].retval
)
69 printf ("swscanf (\"%S\", \"%S\", ...) failed\n",
70 tests
[n
].arg
, tests
[n
].fmt
);
73 else if (tests
[n
].retval
!= 0 && strcmp (buf
, tests
[n
].res
) != 0)
75 printf ("swscanf (\"%S\", \"%S\", ...) return \"%s\", expected \"%s\"\n",
76 tests
[n
].arg
, tests
[n
].fmt
, buf
, tests
[n
].res
);
80 printf ("swscanf (\"%S\", \"%S\", ...) OK\n",
81 tests
[n
].arg
, tests
[n
].fmt
);
83 if (swscanf (tests
[n
].arg
, tests
[n
].wfmt
, wbuf
) != tests
[n
].retval
)
85 printf ("swscanf (\"%S\", \"%S\", ...) failed\n",
86 tests
[n
].arg
, tests
[n
].wfmt
);
89 else if (tests
[n
].retval
!= 0 && wcscmp (wbuf
, tests
[n
].wres
) != 0)
91 printf ("swscanf (\"%S\", \"%S\", ...) return \"%S\", expected \"%S\"\n",
92 tests
[n
].arg
, tests
[n
].wfmt
, wbuf
, tests
[n
].wres
);
96 printf ("swscanf (\"%S\", \"%S\", ...) OK\n",
97 tests
[n
].arg
, tests
[n
].wfmt
);