2 WCSRTOMBS: size_t wcsrtombs (char *s, const wchar_t **ws, size_t n,
6 #define TST_FUNCTION wcsrtombs
8 #include "tsp_common.c"
9 #include "dat_wcsrtombs.c"
14 tst_wcsrtombs (FILE * fp
, int debug_flg
)
16 TST_DECL_VARS (size_t);
18 const wchar_t *ws
, *wp
;
19 char s
[MBSSIZE
], *s_in
;
21 static mbstate_t t
= { 0 };
26 TST_DO_TEST (wcsrtombs
)
28 TST_HEAD_LOCALE (wcsrtombs
, S_WCSRTOMBS
);
29 TST_DO_REC (wcsrtombs
)
31 TST_GET_ERRET (wcsrtombs
);
32 memset (s
, MARK_VAL
, MBSSIZE
);
34 s_flg
= TST_INPUT (wcsrtombs
).s_flg
;
35 s_in
= (s_flg
== 1) ? s
: (char *) NULL
;
36 wp
= ws
= TST_INPUT (wcsrtombs
).ws
;
37 n
= TST_INPUT (wcsrtombs
).n
;
38 t_flg
= TST_INPUT (wcsrtombs
).t_flg
;
39 t_ini
= TST_INPUT (wcsrtombs
).t_init
;
40 pt
= (t_flg
== 0) ? NULL
: &t
;
44 memset (&t
, 0, sizeof (t
));
48 ret
= wcsrtombs (s_in
, &wp
, n
, pt
);
53 fprintf (stderr
, "wcsrtombs: ret = %zu\n", ret
);
56 TST_IF_RETURN (S_WCSRTOMBS
)
60 if (s_in
!= NULL
&& ret
!= (size_t) - 1)
62 /* No definition for s, when error occurs. */
63 s_ex
= TST_EXPECT (wcsrtombs
).s
;
65 for (err
= 0, i
= 0; i
<= ret
&& i
< MBSSIZE
; i
++)
70 " : s[%d] = 0x%hx <-> 0x%hx = s_ex[%d]\n", i
,
74 if (i
== ret
&& ret
== n
) /* no null termination */
78 Result (C_SUCCESS
, S_WCSRTOMBS
, CASE_4
, MS_PASSED
);
83 Result (C_FAILURE
, S_WCSRTOMBS
, CASE_4
,
84 "should not be null terminated "
85 "(it may be a null char), but it is");
91 if (i
== ret
&& ret
< n
) /* null termination */
95 Result (C_SUCCESS
, S_WCSRTOMBS
, CASE_5
, MS_PASSED
);
100 Result (C_FAILURE
, S_WCSRTOMBS
, CASE_5
,
101 "should be null terminated, but it is not");
111 Result (C_FAILURE
, S_WCSRTOMBS
, CASE_6
,
112 "converted string is different from an"
120 Result (C_SUCCESS
, S_WCSRTOMBS
, CASE_6
, MS_PASSED
);