2 SWSCANF: int swscanf (const wchar_t *ws, const wchar_t *fmt, ...);
5 #define TST_FUNCTION swscanf
7 #include "tsp_common.c"
8 #include "dat_swscanf.c"
11 tst_swscanf (FILE * fp
, int debug_flg
)
20 char val_s
[MBSSIZE
* 3];
21 wchar_t val_S
[WCSSIZE
* 3], *exp_S
;
26 TST_HEAD_LOCALE (swscanf
, S_SWSCANF
);
29 TST_GET_ERRET (swscanf
);
30 ws
= TST_INPUT (swscanf
).ws
;
31 fmt
= TST_INPUT (swscanf
).fmt
;
32 val_int1
= val_int2
= val_flt
= val_c
= 0;
33 memset (val_s
, 0, sizeof (val_s
));
34 memset (val_S
, 0, sizeof (val_S
));
38 if (TST_INPUT (swscanf
).wch
)
40 ret
= swscanf (ws
, fmt
, val_S
);
45 swscanf (ws
, fmt
, &val_int1
, &val_int2
, &val_flt
, &val_c
, val_s
);
51 { /* seems fprintf doesn't update errno */
52 fprintf (stdout
, "swscanf() [ %s : %d ] ret = %d\n", locale
,
54 fprintf (stdout
, " errno = %d\n",
56 fprintf (stdout
, " collate = %s\n",
57 (setlocale (LC_COLLATE
, NULL
)) ? setlocale (LC_COLLATE
,
60 if (TST_INPUT (swscanf
).wch
)
62 fprintf (stdout
, " val_S[ 0 ] = 0x%lx\n",
63 (unsigned long int) val_S
[0]);
67 fprintf (stdout
, " val_int1 = %d\n",
69 fprintf (stdout
, " val_int2 = %d\n",
71 fprintf (stdout
, " val_flt = %f\n",
73 fprintf (stdout
, " val_c = %c\n",
75 fprintf (stdout
, " val_s = %s\n",
80 TST_IF_RETURN (S_SWSCANF
)
84 if (errno
== 0 && TST_INPUT (swscanf
).wch
)
86 for (exp_S
= TST_EXPECT (swscanf
).val_S
, i
= 0; i
< WCSSIZE
* 3;
89 if (val_S
[i
] == L
'\0' || exp_S
[i
] == L
'\0')
91 if (val_S
[i
] != exp_S
[i
] && TST_INPUT (swscanf
).wch
== 'C')
94 Result (C_FAILURE
, S_SWSCANF
, CASE_4
,
95 "the converted wide-char string is different"
96 " from an expected value.");
101 if (val_S
[i
] != exp_S
[i
])
104 Result (C_FAILURE
, S_SWSCANF
, CASE_4
,
105 "the converted wide-char string is different from"
106 " an expected value.");
111 Result (C_SUCCESS
, S_SWSCANF
, CASE_4
, MS_PASSED
);
116 if (errno
== 0 && !TST_INPUT (swscanf
).wch
)
118 if (val_int1
!= TST_EXPECT (swscanf
).val_int
||
119 val_int2
!= TST_EXPECT (swscanf
).val_uns
||
120 val_flt
!= TST_EXPECT (swscanf
).val_flt
||
121 val_c
!= TST_EXPECT (swscanf
).val_c
||
122 strcmp (val_s
, TST_EXPECT (swscanf
).val_s
))
125 Result (C_FAILURE
, S_SWSCANF
, CASE_3
,
126 "the converted values are different from expected values.");
130 Result (C_SUCCESS
, S_SWSCANF
, CASE_3
, MS_PASSED
);