2 MBSRTOWCS: size_t mbsrtowcs (wchar_t *ws, const char **s, size_t n,
6 #define TST_FUNCTION mbsrtowcs
8 #include "tsp_common.c"
9 #include "dat_mbsrtowcs.c"
12 tst_mbsrtowcs (FILE * fp
, int debug_flg
)
14 TST_DECL_VARS (size_t);
19 static mbstate_t t
= { 0 };
21 wchar_t ws
[WCSSIZE
], *ws_ex
, *wp
;
24 TST_DO_TEST (mbsrtowcs
)
26 TST_HEAD_LOCALE (mbsrtowcs
, S_MBSRTOWCS
);
27 TST_DO_REC (mbsrtowcs
)
30 if (mbsrtowcs (NULL
, &s
, 0, &t
) != 0)
33 Result (C_FAILURE
, S_MBSRTOWCS
, CASE_3
,
34 "Initialization failed - skipping this test case.");
38 TST_DO_SEQ (MBSRTOWCS_SEQNUM
)
40 TST_GET_ERRET_SEQ (mbsrtowcs
);
41 w_flg
= TST_INPUT_SEQ (mbsrtowcs
).w_flg
;
42 p
= s
= TST_INPUT_SEQ (mbsrtowcs
).s
;
43 n
= TST_INPUT_SEQ (mbsrtowcs
).n
;
44 t_flg
= TST_INPUT_SEQ (mbsrtowcs
).t_flg
;
45 t_ini
= TST_INPUT_SEQ (mbsrtowcs
).t_init
;
46 wp
= (w_flg
== 0) ? NULL
: ws
;
48 if (n
== USE_MBCURMAX
)
53 pt
= (t_flg
== 0) ? NULL
: &t
;
57 memset (&t
, 0, sizeof (t
));
61 ret
= mbsrtowcs (wp
, &p
, n
, pt
);
66 fprintf (stderr
, "mbsrtowcs: [ %d ] : ret = %zd\n", rec
+ 1, ret
);
69 TST_IF_RETURN (S_MBSRTOWCS
)
73 if (wp
== NULL
|| ret
== (size_t) - 1 || ret
== (size_t) - 2)
78 ws_ex
= TST_EXPECT_SEQ (mbsrtowcs
).ws
;
79 for (err
= 0, i
= 0; i
< ret
; i
++)
84 "mbsrtowcs: ws[%d] => 0x%lx : 0x%lx <= ws_ex[%d]\n",
85 i
, (unsigned long int) ws
[i
],
86 (unsigned long int) ws_ex
[i
], i
);
89 if (ws
[i
] != ws_ex
[i
])
93 Result (C_FAILURE
, S_MBSRTOWCS
, CASE_4
,
94 "the converted wc string has "
95 "different value from an expected string");
102 Result (C_SUCCESS
, S_MBSRTOWCS
, CASE_4
, MS_PASSED
);