(UINT8_C, UINT16_C): Don't append 'U', since C99 requires the result
[glibc/history.git] / localedata / tests-mbwc / tst_mbstowcs.c
blob878df6a960a21ec4cee427526fa4d40712e6b52c
1 /*
2 MBSTOWCS: size_t mbstowcs (wchar_t *ws, char *s, size_t n)
3 */
5 #define TST_FUNCTION mbstowcs
7 #include "tsp_common.c"
8 #include "dat_mbstowcs.c"
10 int
11 tst_mbstowcs (FILE * fp, int debug_flg)
13 TST_DECL_VARS (size_t);
14 char w_flg, s_flg;
15 const char *s;
16 size_t n;
17 wchar_t ws[WCSSIZE], *ws_ex, *wp;
18 int err, i;
20 TST_DO_TEST (mbstowcs)
22 TST_HEAD_LOCALE (mbstowcs, S_MBSTOWCS);
23 TST_DO_REC (mbstowcs)
25 if (mbstowcs (NULL, "", 0) != 0)
27 err_count++;
28 Result (C_FAILURE, S_MBSTOWCS, CASE_3,
29 "Initialization failed - skipping this test case.");
30 continue;
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;
40 if (s_flg == 0)
41 s = NULL;
42 else
43 s = TST_INPUT_SEQ (mbstowcs).s;
46 wp = (wchar_t *) ((w_flg == 0) ? NULL : ws);
48 TST_CLEAR_ERRNO;
49 ret = mbstowcs (wp, s, n);
50 TST_SAVE_ERRNO;
52 if (debug_flg)
54 fprintf (stderr, "mbstowcs: ret = %zd\n", ret);
57 TST_IF_RETURN (S_MBSTOWCS)
61 if (s == NULL || wp == NULL || ret == (size_t) - 1)
63 continue;
66 ws_ex = TST_EXPECT_SEQ (mbstowcs).ws;
68 for (err = 0, i = 0; i < ret; i++)
70 if (debug_flg)
72 fprintf (stderr,
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])
80 err++;
81 err_count++;
82 Result (C_FAILURE, S_MBSTOWCS, CASE_4,
83 "the converted wc string has "
84 "different value from an expected string");
85 break;
89 if (!err)
91 Result (C_SUCCESS, S_MBSTOWCS, CASE_4, MS_PASSED);
97 return err_count;