2.9
[glibc/nacl-glibc.git] / localedata / tests-mbwc / dat_mbtowc.c
blob95edb684d321eec21520412686277432267ba77b
1 /*
2 * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
4 * FILE: dat_mbtowc.c
6 * MBTOWC: int mbtowc (wchar_t *wp, char *s, size_t n);
7 */
9 /* NOTE:
11 * int mbtowc (wchar_t *wp, char *s, size_t n);
13 * where n: a maximum number of bytes
14 * return: the number of bytes
17 * o When you feed a null pointer for a string (s) to the function,
18 * set s_flg=0 instead of putting just a 'NULL' there.
19 * Even if you put a 'NULL', it means a null string as well as "".
21 * o When s is a null pointer, the function checks state dependency.
23 * state-dependent encoding - return NON-zero
24 * state-independent encoding - return 0
26 * If state-dependent encoding is expected, set
28 * s_flg = 0, ret_flg = 0, ret_val = +1
30 * If state-independent encoding is expected, set
32 * s_flg = 0, ret_flg = 0, ret_val = 0
35 * When you set ret_flg=1, the test program simply compares
36 * an actual return value with an expected value. You can
37 * check state-independent case (return value is 0) in that
38 * way, but you can not check state-dependent case. So when
39 * you check state- dependency in this test function:
40 * tst_mbtowc(), set ret_flg=0 always. It's a special case
41 * and the test function takes care of it.
43 * w_flg
44 * | s: (a null string; can't be (char *)NULL)
45 * | |
46 * input. { 1, 0, (char)NULL, MB_LEN_MAX },
47 * |
48 * s_flg=0: makes _s_ a null pointer.
50 * expect { 0,0,0,x, 0x0000 },
51 * | |
52 * | ret_val: 0/+1
53 * ret_flg=0
56 * Test data for State dependent encodings:
58 * mbtowc( NULL, NULL, 0 ); ... first data
59 * mbtowc( &wc, s1, n1 ); ... second data
60 * mbtowc( &wc, s2, n2 ); ... third data
61 * */
63 #include <limits.h>
65 TST_MBTOWC tst_mbtowc_loc [] = {
67 { Tmbtowc, TST_LOC_de },
69 { /*----------------- #01 -----------------*/
72 { 1, 1, "\xfc\xe4\xf6", 1 },
73 { 1, 1, "\xfc\xe4\xf6", 2 },
74 { 1, 1, "\xfc\xe4\xf6", MB_LEN_MAX },
79 { 0, 1, 1, 0x00FC },
80 { 0, 1, 1, 0x00FC },
81 { 0, 1, 1, 0x00FC },
85 { /*----------------- #02 -----------------*/
88 { 1, 1, "\177", MB_LEN_MAX },
89 { 1, 1, "\200", MB_LEN_MAX },
90 { 1, 1, "\201", MB_LEN_MAX },
95 { 0, 1, 1, 0x007F },
96 { 0, 1, 1, 0x0080 },
97 { 0, 1, 1, 0x0081 },
101 { /*----------------- #03 -----------------*/
104 { 1, 1, "", MB_LEN_MAX },
105 { 0, 1, "\xfc\xe4\xf6", 1 },
106 { 0, 1, "\xfc\xe4\xf6", 2 },
111 { 0, 1, 0, 0x0000 },
112 { 0, 1, 1, 0x0000 },
113 { 0, 1, 1, 0x0000 },
117 { /*----------------- #04 -----------------*/
120 { 0, 1, "\xfc\xe4\xf6", MB_LEN_MAX },
121 { 0, 1, "\177", MB_LEN_MAX },
122 { 0, 1, "", MB_LEN_MAX },
127 { 0, 1, 1, 0x0000 },
128 { 0, 1, 1, 0x0000 },
129 { 0, 1, 0, 0x0000 },
133 { /*----------------- #05 -----------------*/
136 { 0, 1, "\xfc\xe4\xf6", MB_LEN_MAX },
137 { 0, 1, "\177", MB_LEN_MAX },
138 { 0, 0, NULL, MB_LEN_MAX },
143 { 0, 1, 1, 0x0000 },
144 { 0, 1, 1, 0x0000 },
145 { 0, 0, 0, 0x0000 },
149 { .is_last = 1 }
153 { Tmbtowc, TST_LOC_enUS },
155 { /*----------------- #01 -----------------*/
158 { 1, 1, "ABC", 1 },
159 { 1, 1, "ABC", 2 },
160 { 1, 1, "ABC", MB_LEN_MAX },
165 { 0, 1, 1, 0x0041 },
166 { 0, 1, 1, 0x0041 },
167 { 0, 1, 1, 0x0041 },
171 { /*----------------- #02 -----------------*/
174 { 1, 1, "\177", MB_LEN_MAX },
175 { 1, 1, "\200", MB_LEN_MAX },
176 { 1, 1, "\201", MB_LEN_MAX },
181 { 0, 1, 1, 0x007F },
182 { EILSEQ, 1, -1, 0x0000 },
183 { EILSEQ, 1, -1, 0x0000 },
187 { /*----------------- #03 -----------------*/
190 { 1, 1, "", MB_LEN_MAX },
191 { 0, 1, "ABC", 1 },
192 { 0, 1, "ABC", 2 },
197 { 0, 1, 0, 0x0000 },
198 { 0, 1, 1, 0x0000 },
199 { 0, 1, 1, 0x0000 },
203 { /*----------------- #04 -----------------*/
206 { 0, 1, "ABC", MB_LEN_MAX },
207 { 0, 1, "\177", MB_LEN_MAX },
208 { 0, 1, "", MB_LEN_MAX },
213 { 0, 1, 1, 0x0000 },
214 { 0, 1, 1, 0x0000 },
215 { 0, 1, 0, 0x0000 },
219 { /*----------------- #05 -----------------*/
222 { 0, 1, "ABC", MB_LEN_MAX },
223 { 0, 1, "\177", MB_LEN_MAX },
224 { 0, 0, NULL, MB_LEN_MAX },
229 { 0, 1, 1, 0x0000 },
230 { 0, 1, 1, 0x0000 },
231 { 0, 0, 0, 0x0000 },
235 { .is_last = 1 }
239 { Tmbtowc, TST_LOC_eucJP },
241 { /*----------------- #01 -----------------*/
244 { 1, 1, "\244\242A", 1 },
245 { 1, 1, "\244\242A", 2 },
246 { 1, 1, "\244\242A", MB_LEN_MAX },
251 #ifdef SHOJI_IS_RIGHT
252 { EILSEQ, 1, -1, 0x0000 },
253 #else
254 /* XXX EILSEQ was introduced in ISO C99. */
255 { 0, 1, -1, 0x0000 },
256 #endif
257 { 0, 1, 2, 0x3042 },
258 { 0, 1, 2, 0x3042 },
262 { /*----------------- #02 -----------------*/
265 { 1, 1, "\177\244\242", MB_LEN_MAX },
266 { 1, 1, "\377\244\242", MB_LEN_MAX },
267 { 1, 1, "\201\244\242", MB_LEN_MAX },
272 { 0, 1, +1, 0x007F },
273 #ifdef SHOJI_IS_RIGHT
274 { EILSEQ, 1, -1, 0x0000 },
275 #else
276 { 0, 1, -1, 0x0000 },
277 #endif
278 { 0, 1, +1, 0x0081 },
282 { /*----------------- #03 -----------------*/
285 { 1, 1, "", MB_LEN_MAX },
286 { 0, 1, "\244\242A", 1 },
287 { 0, 1, "\244\242A", 2 },
292 { 0, 1, 0, 0x0000 },
293 #ifdef SHOJI_IS_RIGHT
294 { EILSEQ, 1, -1, 0x0000 },
295 #else
296 /* XXX EILSEQ was introduced in ISO C99. */
297 { 0, 1, -1, 0x0000 },
298 #endif
299 { 0, 1, 2, 0x0000 },
303 { /*----------------- #04 -----------------*/
306 { 0, 1, "\244\242A", MB_LEN_MAX },
307 { 0, 1, "\177\244\242", MB_LEN_MAX },
308 { 0, 1, "", MB_LEN_MAX },
313 { 0, 1, 2, 0x0000 },
314 { 0, 1, +1, 0x0000 },
315 { 0, 1, 0, 0x0000 },
319 { /*----------------- #05 -----------------*/
322 { 0, 1, "\244\242A", MB_LEN_MAX },
323 { 0, 1, "\177\244\242", MB_LEN_MAX },
324 { 0, 0, NULL, MB_LEN_MAX },
329 { 0, 1, 2, 0x0000 },
330 { 0, 1, +1, 0x0000 },
331 { 0, 0, 0, 0x0000 },
335 { .is_last = 1 }
339 { Tmbtowc, TST_LOC_end }