2 * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
6 * WCSTOMBS: size_t wcstombs (char *s, const wchar_t *ws, size_t n)
12 * Do not use a value 0x01 for string data. The test program
18 TST_WCSTOMBS tst_wcstombs_loc
[] = {
20 { Twcstombs
, TST_LOC_de
},
22 /* #01 : Any chars including a null char should not be stored in s. */
23 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 0 },
24 /*expect*/ { 0,1,0, "" },
26 /* #02 : Only one chars should be stored in s. No null termination. */
27 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 1 },
28 /*expect*/ { 0,1,1, "Ä" },
30 /* #03 : Only two chars should be stored in s. No null termination. */
31 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 2 },
32 /*expect*/ { 0,1,2, "ÄÖ" },
34 /* #04 : Only three chars should be stored in s. No null
36 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 3 },
37 /*expect*/ { 0,1,3, "ÄÖÜ" },
39 /* #05 : Only three chars should be stored in s with a null
41 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 4 },
42 /*expect*/ { 0,1,3, "ÄÖÜ" },
44 /* #06 : Only three chars should be stored in s with a null
46 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 5 },
47 /*expect*/ { 0,1,3, "ÄÖÜ" },
49 /* #07 : Invalid mb sequence. No chars should be stored in s. */
50 { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2 },
51 /*expect*/ { EILSEQ
,1,(size_t)-1, "" },
53 /* #08 : s is a null pointer, no chars should be stored in s. */
54 { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 0 },
55 /*expect*/ { 0,1,3, "" },
57 /* #09 : s is a null pointer, no chars should be stored in s. */
58 { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 1 },
59 /*expect*/ { 0,1,3, "" },
61 /* #10 : s is a null pointer, no chars should be stored in s. */
62 { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 5 },
63 /*expect*/ { 0,1,3, "" },
65 /* #11 : s is a null pointer. No chars should be stored in s. */
66 { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5 },
67 /*expect*/ { EILSEQ
,1,(size_t)-1, "" },
69 /* #12 : ws is a null wc string, no chars should be stored in s. */
70 { /*input.*/ { 1,1, { 0x0000 }, 5 },
71 /*expect*/ { 0,1,0, "" },
73 /* #13 : s is a null pointer, no chars should be stored in s. */
74 { /*input.*/ { 0,1, { 0x0000 }, 5 },
75 /*expect*/ { 0,1,0, "" },
81 { Twcstombs
, TST_LOC_enUS
},
83 /* #01 : Any chars including a null char should not be stored in s. */
84 { /*input.*/ { 1,1, { 0x00C4,0x0042,0x0043,0x0000 }, 0 },
85 /*expect*/ { 0,1,0, "" },
87 /* #02 : Only one chars should be stored in s. No null termination. */
88 { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 1 },
89 /*expect*/ { 0,1,1, "A" },
91 /* #03 : Only two chars should be stored in s. No null termination. */
92 { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 2 },
93 /*expect*/ { 0,1,2, "AB" },
95 /* #04 : Only three chars should be stored in s. No null
97 { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 3 },
98 /*expect*/ { 0,1,3, "ABC" },
100 /* #05 : Only three chars should be stored in s with a null
102 { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 4 },
103 /*expect*/ { 0,1,3, "ABC" },
105 /* #06 : Only three chars should be stored in s with a null
107 { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 5 },
108 /*expect*/ { 0,1,3, "ABC" },
110 /* #07 : Invalid mb sequence. No chars should be stored in s. */
111 { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2 },
112 /*expect*/ { EILSEQ
,1,(size_t)-1, "" },
114 /* #08 : s is a null pointer, no chars should be stored in s. */
115 { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 0 },
116 /*expect*/ { 0,1,3, "" },
118 /* #09 : s is a null pointer, no chars should be stored in s. */
119 { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 1 },
120 /*expect*/ { 0,1,3, "" },
122 /* #10 : s is a null pointer, no chars should be stored in s. */
123 { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 5 },
124 /*expect*/ { 0,1,3, "" },
126 /* #11 : s is a null pointer. No chars should be stored in s. */
127 { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5 },
128 /*expect*/ { EILSEQ
,1,(size_t)-1, "" },
130 /* #12 : ws is a null wc string, no chars should be stored in s. */
131 { /*input.*/ { 1,1, { 0x0000 }, 5, },
132 /*expect*/ { 0,1,0, "" },
134 /* #13 : s is a null pointer, no chars should be stored in s. */
135 { /*input.*/ { 0,1, { 0x0000 }, 5 },
136 /*expect*/ { 0,1,0, "" },
143 { Twcstombs
, TST_LOC_eucJP
},
146 /* #01 : Any chars including a null char should not be stored in s. */
147 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 0 },
148 /*expect*/ { 0,1,0, "" },
150 /* #02 : Only one chars should be stored in s. No null termination. */
151 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 2 },
152 /*expect*/ { 0,1,2, "\244\242" },
154 /* #03 : Only two chars should be stored in s. No null termination. */
155 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 4 },
156 /*expect*/ { 0,1,4, "\244\242\244\244" },
158 /* #04 : Only three chars should be stored in s. No null
160 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 6 },
161 /*expect*/ { 0,1,6, "\244\242\244\244\216\263" },
163 /* #05 : Only three chars should be stored in s with a null
165 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 7 },
166 /*expect*/ { 0,1,6, "\244\242\244\244\216\263" },
168 /* #06 : Only three chars should be stored in s with a null
170 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 8 },
171 /*expect*/ { 0,1,6, "\244\242\244\244\216\263" },
173 /* #07 : Invalid mb sequence. No chars should be stored in s. */
174 { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2 },
175 /*expect*/ { EILSEQ
,1,-1, "" },
177 /* #08 : s is a null pointer, no chars should be stored in s. */
178 { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 0 },
179 /*expect*/ { 0,1,6, "" },
181 /* #09 : s is a null pointer, no chars should be stored in s. */
182 { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 1 },
183 /*expect*/ { 0,1,6, "" },
185 /* #10 : s is a null pointer, no chars should be stored in s. */
186 { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 8 },
187 /*expect*/ { 0,1,6, "" },
189 /* #11 : s is a null pointer. No chars should be stored in s. */
190 { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5 },
191 /*expect*/ { EILSEQ
,1,(size_t)-1, "" },
193 /* #12 : ws is a null wc string, no chars should be stored in s. */
194 { /*input.*/ { 1,1, { 0x0000 }, 5 },
195 /*expect*/ { 0,1,0, "" },
197 /* #13 : s is a null pointer, no chars should be stored in s. */
198 { /*input.*/ { 0,1, { 0x0000 }, 5 },
199 /*expect*/ { 0,1,0, "" },
206 { Twcstombs
, TST_LOC_ja_UTF8
},
209 /* #01 : Any chars including a null char should not be stored in s. */
210 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 0 },
211 /*expect*/ { 0,1,0, "" },
213 /* #02 : Only one chars should be stored in s. No null termination. */
214 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 3 },
215 /*expect*/ { 0,1,3, "\343\201\202" },
217 /* #03 : Only two chars should be stored in s. No null termination. */
218 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 6 },
219 /*expect*/ { 0,1,6, "\343\201\202\343\201\204" },
221 /* #04 : Only three chars should be stored in s. No null
223 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 9 },
224 /*expect*/ { 0,1,9, "\343\201\202\343\201\204\357\275\263" },
226 /* #05 : Only three chars should be stored in s with a null
228 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 10 },
229 /*expect*/ { 0,1,9, "\343\201\202\343\201\204\357\275\263" },
231 /* #06 : Only three chars should be stored in s with a null
233 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 11 },
234 /*expect*/ { 0,1,9, "\343\201\202\343\201\204\357\275\263" },
236 /* #07 : Invalid mb sequence. No chars should be stored in s. */
237 { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2 },
238 /*expect*/ { EILSEQ
,1,-1, "" },
240 /* #08 : s is a null pointer, no chars should be stored in s. */
241 { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 0 },
242 /*expect*/ { 0,1,9, "" },
244 /* #09 : s is a null pointer, no chars should be stored in s. */
245 { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 1 },
246 /*expect*/ { 0,1,9, "" },
248 /* #10 : s is a null pointer, no chars should be stored in s. */
249 { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 8 },
250 /*expect*/ { 0,1,9, "" },
252 /* #11 : s is a null pointer. No chars should be stored in s. */
253 { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5 },
254 /*expect*/ { EILSEQ
,1,(size_t)-1, "" },
256 /* #12 : ws is a null wc string, no chars should be stored in s. */
257 { /*input.*/ { 1,1, { 0x0000 }, 5 },
258 /*expect*/ { 0,1,0, "" },
260 /* #13 : s is a null pointer, no chars should be stored in s. */
261 { /*input.*/ { 0,1, { 0x0000 }, 5 },
262 /*expect*/ { 0,1,0, "" },
269 { Twcstombs
, TST_LOC_end
}