2 MBSTOWCS: size_t mbstowcs (wchar_t *ws, char *s, size_t n)
5 #define TST_FUNCTION mbstowcs
7 #include "tsp_common.c"
8 #include "dat_mbstowcs.c"
11 tst_mbstowcs (FILE * fp
, int debug_flg
)
13 TST_DECL_VARS (size_t);
17 wchar_t ws
[WCSSIZE
], *ws_ex
, *wp
;
20 TST_DO_TEST (mbstowcs
)
22 TST_HEAD_LOCALE (mbstowcs
, S_MBSTOWCS
);
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 (MBSTOWCS_SEQNUM
)
35 TST_GET_ERRET_SEQ (mbstowcs
);
36 w_flg
= TST_INPUT_SEQ (mbstowcs
).w_flg
;
37 s_flg
= TST_INPUT_SEQ (mbstowcs
).s_flg
;
38 n
= TST_INPUT_SEQ (mbstowcs
).n
;
43 s
= TST_INPUT_SEQ (mbstowcs
).s
;
46 wp
= (wchar_t *) ((w_flg
== 0) ? NULL
: ws
);
49 ret
= mbstowcs (wp
, s
, n
);
54 fprintf (stderr
, "mbstowcs: ret = %zd\n", ret
);
57 TST_IF_RETURN (S_MBSTOWCS
)
61 if (s
== NULL
|| wp
== NULL
|| ret
== (size_t) - 1)
66 ws_ex
= TST_EXPECT_SEQ (mbstowcs
).ws
;
68 for (err
= 0, i
= 0; i
< ret
; i
++)
73 "mbstowcs: ws[%d] => 0x%lx : 0x%lx <= ws_ex[%d]\n",
74 i
, (unsigned long int) ws
[i
],
75 (unsigned long int) ws_ex
[i
], i
);
78 if (ws
[i
] != ws_ex
[i
])
82 Result (C_FAILURE
, S_MBSTOWCS
, CASE_4
,
83 "the converted wc string has "
84 "different value from an expected string");
91 Result (C_SUCCESS
, S_MBSTOWCS
, CASE_4
, MS_PASSED
);