1 /*
2 WCSTOK: wchar_t *wcstok (wchar_t *ws, const wchar_t *dlm, wchar_t **pt);
3 */
4
5
6 #define TST_FUNCTION wcstok
7
8 #include "tsp_common.c"
9 #include "dat_wcstok.c"
10
11 int
tst_wcstok(FILE * fp,int debug_flg)12 tst_wcstok (FILE * fp, int debug_flg)
13 {
14 TST_DECL_VARS (wchar_t *);
15 char w_flg;
16 wchar_t *ws;
17 wchar_t *dt, *pt;
18 wchar_t *ws_ex;
19 int err, i;
20
21 TST_DO_TEST (wcstok)
22 {
23 TST_HEAD_LOCALE (wcstok, S_WCSTOK);
24 TST_DO_REC (wcstok)
25 {
26 TST_DO_SEQ (WCSTOK_SEQNUM)
27 {
28 TST_GET_ERRET_SEQ (wcstok);
29 w_flg = TST_INPUT_SEQ (wcstok).w_flg;
30 ws = (w_flg) ? TST_INPUT_SEQ (wcstok).ws : NULL;
31 dt = TST_INPUT_SEQ (wcstok).dt;
32
33 ret = wcstok (ws, dt, &pt);
34
35 if (debug_flg)
36 {
37 fprintf (stdout, "wcstok() [ %s : %d : %d ] *ret = 0x%lx\n",
38 locale, rec + 1, seq_num + 1, (unsigned long int) *ret);
39 if (pt && *pt)
40 {
41 fprintf (stdout, " *pt = 0x%lx\n",
42 (unsigned long int) *pt);
43 }
44 }
45
46 TST_IF_RETURN (S_WCSTOK)
47 {
48 };
49
50 if (ret != NULL)
51 {
52 ws_ex = TST_EXPECT_SEQ (wcstok).ws;
53
54 /* XXX: REVISIT : insufficient conditions */
55 for (err = 0, i = 0; i < WCSSIZE; i++)
56 {
57 if (ret[i] == L'\0' && ws_ex[i] == L'\0')
58 {
59 break;
60 }
61
62 if (debug_flg)
63 {
64 fprintf (stderr,
65 " ret[%d] = 0x%lx <-> "
66 "0x%lx = ws_ex[%d]\n",
67 i, (unsigned long int) ret[i],
68 (unsigned long int) ws_ex[i], i);
69 }
70
71 if (ret[i] != ws_ex[i])
72 {
73 err++;
74 err_count++;
75 Result (C_FAILURE, S_WCSTOK, CASE_3,
76 "the token is different from an expected string");
77 break;
78 }
79
80 if (ret[i] == L'\0' || ws_ex[i] == L'\0')
81 {
82 break;
83 }
84 }
85
86 if (!err)
87 {
88 Result (C_SUCCESS, S_WCSTOK, CASE_3, MS_PASSED);
89 }
90 }
91 }
92 }
93 }
94
95 return err_count;
96 }
97