2
MBTOWC: int mbtowc (wchar_t *wc, char *s, size_t n)
5
#define TST_FUNCTION mbtowc
7
#include "tsp_common.c"
8
#include "dat_mbtowc.c"
12
tst_mbtowc (FILE * fp, int debug_flg)
18
wchar_t wc, wc_ex, *wp;
22
TST_HEAD_LOCALE (mbtowc, S_MBTOWC);
25
if (mbstowcs (NULL, "", 0) != 0)
28
Result (C_FAILURE, S_MBSTOWCS, CASE_3,
29
"Initialization failed - skipping this test case.");
33
TST_DO_SEQ (MBTOWC_SEQNUM)
35
TST_GET_ERRET_SEQ (mbtowc);
36
w_flg = TST_INPUT_SEQ (mbtowc).w_flg;
37
s_flg = TST_INPUT_SEQ (mbtowc).s_flg;
38
n = TST_INPUT_SEQ (mbtowc).n;
40
if (n == USE_MBCURMAX)
48
s_in = TST_INPUT_SEQ (mbtowc).s;
50
wp = (wchar_t *) ((w_flg == 0) ? NULL : &wc);
52
/* XXX Clear the internal state. We should probably have
54
mbtowc (NULL, NULL, 0);
57
ret = mbtowc (wp, s_in, n);
62
fprintf (stdout, "mbtowc() [ %s : %d ] ret = %d\n", locale,
64
fprintf (stdout, " errno = %d\n",
68
TST_IF_RETURN (S_MBTOWC)
71
{ /* state dependency */
73
{ /* state-dependent */
76
/* Non-zero: state-dependent encoding. */
77
Result (C_SUCCESS, S_MBTOWC, CASE_3, MS_PASSED);
82
Result (C_FAILURE, S_MBTOWC, CASE_3,
83
"should be state-dependent encoding, "
84
"but a return value shows it is "
90
{ /* state-independent */
93
/* Non-zero: state-dependent encoding. */
94
Result (C_SUCCESS, S_MBTOWC, CASE_3, MS_PASSED);
99
Result (C_FAILURE, S_MBTOWC, CASE_3,
100
"should be state-independent encoding, "
101
"but a return value shows it is "
108
if ((wp == NULL || s_in == NULL || s_in[0] == 0) || ret <= 0)
113
wc_ex = TST_EXPECT_SEQ (mbtowc).wc;
117
Result (C_SUCCESS, S_MBTOWC, CASE_4, MS_PASSED);
122
Result (C_FAILURE, S_MBTOWC, CASE_4,
123
"converted wc is different from an expected wc");