2.9
[glibc/nacl-glibc.git] / localedata / tests-mbwc / dat_wcstombs.c
bloba6dd0ec662820f66025b6bb1d1050af38433fc08
1 /*
2 * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
4 * FILE: dat_wcstombs.c
6 * WCSTOMBS: size_t wcstombs (char *s, const wchar_t *ws, size_t n)
7 */
11 * CAUTION:
12 * Do not use a value 0x01 for string data. The test program
13 * uses it.
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
35 termination. */
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
40 termination. */
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
45 termination. */
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, "" },
77 { .is_last = 1 }
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
96 termination. */
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
101 termination. */
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
106 termination. */
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, "" },
138 { .is_last = 1 }
142 { Twcstombs, TST_LOC_eucJP },
145 /* #01 : Any chars including a null char should not be stored in s. */
146 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 0 },
147 /*expect*/ { 0,1,0, "" },
149 /* #02 : Only one chars should be stored in s. No null termination. */
150 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 2 },
151 /*expect*/ { 0,1,2, "\244\242" },
153 /* #03 : Only two chars should be stored in s. No null termination. */
154 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 4 },
155 /*expect*/ { 0,1,4, "\244\242\244\244" },
157 /* #04 : Only three chars should be stored in s. No null
158 termination. */
159 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 6 },
160 /*expect*/ { 0,1,6, "\244\242\244\244\216\263" },
162 /* #05 : Only three chars should be stored in s with a null
163 termination. */
164 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 7 },
165 /*expect*/ { 0,1,6, "\244\242\244\244\216\263" },
167 /* #06 : Only three chars should be stored in s with a null
168 termination. */
169 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 8 },
170 /*expect*/ { 0,1,6, "\244\242\244\244\216\263" },
172 /* #07 : Invalid mb sequence. No chars should be stored in s. */
173 { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2 },
174 /*expect*/ { EILSEQ,1,-1, "" },
176 /* #08 : s is a null pointer, no chars should be stored in s. */
177 { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 0 },
178 /*expect*/ { 0,1,6, "" },
180 /* #09 : s is a null pointer, no chars should be stored in s. */
181 { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 1 },
182 /*expect*/ { 0,1,6, "" },
184 /* #10 : s is a null pointer, no chars should be stored in s. */
185 { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 8 },
186 /*expect*/ { 0,1,6, "" },
188 /* #11 : s is a null pointer. No chars should be stored in s. */
189 { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5 },
190 /*expect*/ { EILSEQ,1,(size_t)-1, "" },
192 /* #12 : ws is a null wc string, no chars should be stored in s. */
193 { /*input.*/ { 1,1, { 0x0000 }, 5 },
194 /*expect*/ { 0,1,0, "" },
196 /* #13 : s is a null pointer, no chars should be stored in s. */
197 { /*input.*/ { 0,1, { 0x0000 }, 5 },
198 /*expect*/ { 0,1,0, "" },
200 { .is_last = 1 }
204 { Twcstombs, TST_LOC_end }