Updated to fedora-glibc-20090509T2200
[glibc/history.git] / localedata / tests-mbwc / dat_wcsrtombs.c
blobd3148b2a55dd296b8e47042e74ccb2091e8afa51
1 /*
2 * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
4 * FILE: dat_wcsrtombs.c
6 * WCSTOMBS: size_t wcsrtombs (char *s, const wchar_t **ws,
7 * size_t n, mbstate *ps)
8 */
12 * CAUTION:
13 * Do not use a value 0x01 for string data. The test program
14 * uses it.
19 TST_WCSRTOMBS tst_wcsrtombs_loc [] = {
21 { Twcsrtombs, TST_LOC_de },
23 /* #01 : Any chars including a null char should not be stored in s. */
24 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 0, 0, 0},
25 /*expect*/ { 0,1,0, "" },
27 /* #02 : Only one chars should be stored in s. No null termination. */
28 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 1, 0, 0 },
29 /*expect*/ { 0,1,1, "Ä" },
31 /* #03 : Only two chars should be stored in s. No null termination. */
32 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 2, 0, 0 },
33 /*expect*/ { 0,1,2, "ÄÖ" },
35 /* #04 : Only three chars should be stored in s. No null
36 termination. */
37 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 3, 0, 0 },
38 /*expect*/ { 0,1,3, "ÄÖÜ" },
40 /* #05 : Only three chars should be stored in s with a null
41 termination. */
42 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 4, 0, 0 },
43 /*expect*/ { 0,1,3, "ÄÖÜ" },
45 /* #06 : Only three chars should be stored in s with a null
46 termination. */
47 { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 5, 0, 0 },
48 /*expect*/ { 0,1,3, "ÄÖÜ" },
50 /* #07 : Invalid mb sequence. No chars should be stored in s. */
51 { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2, 0, 0 },
52 /*expect*/ { EILSEQ,1,(size_t)-1, "" },
54 /* #08 : s is a null pointer, no chars should be stored in s. */
55 { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 0, 0, 0 },
56 /*expect*/ { 0,1,3, "" },
58 /* #09 : s is a null pointer, no chars should be stored in s. */
59 { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 1, 0, 0 },
60 /*expect*/ { 0,1,3, "" },
62 /* #10 : s is a null pointer, no chars should be stored in s. */
63 { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 5, 0, 0 },
64 /*expect*/ { 0,1,3, "" },
66 /* #11 : s is a null pointer. No chars should be stored in s. */
67 { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5, 0, 0 },
68 /*expect*/ { EILSEQ,1,(size_t)-1, "" },
70 /* #12 : ws is a null wc string, no chars should be stored in s. */
71 { /*input.*/ { 1,1, { 0x0000 }, 5, 0, 0 },
72 /*expect*/ { 0,1,0, "" },
74 /* #13 : s is a null pointer, no chars should be stored in s. */
75 { /*input.*/ { 0,1, { 0x0000 }, 5, 0, 0 },
76 /*expect*/ { 0,1,0, "" },
78 { .is_last = 1 }
82 { Twcsrtombs, TST_LOC_enUS },
84 /* #01 : Any chars including a null char should not be stored in s. */
85 { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 0, 0, 0 },
86 /*expect*/ { 0,1,0, "" },
88 /* #02 : Only one chars should be stored in s. No null termination. */
89 { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 1, 0, 0 },
90 /*expect*/ { 0,1,1, "A" },
92 /* #03 : Only two chars should be stored in s. No null termination. */
93 { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 2, 0, 0 },
94 /*expect*/ { 0,1,2, "AB" },
96 /* #04 : Only three chars should be stored in s. No null
97 termination. */
98 { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 3, 0, 0 },
99 /*expect*/ { 0,1,3, "ABC" },
101 /* #05 : Only three chars should be stored in s with a null
102 termination. */
103 { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 4, 0, 0 },
104 /*expect*/ { 0,1,3, "ABC" },
106 /* #06 : Only three chars should be stored in s with a null
107 termination. */
108 { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 5, 0, 0 },
109 /*expect*/ { 0,1,3, "ABC" },
111 /* #07 : Invalid mb sequence. No chars should be stored in s. */
112 { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2, 0, 0 },
113 /*expect*/ { EILSEQ,1,(size_t)-1, "" },
115 /* #08 : s is a null pointer, no chars should be stored in s. */
116 { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 0, 0, 0 },
117 /*expect*/ { 0,1,3, "" },
119 /* #09 : s is a null pointer, no chars should be stored in s. */
120 { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 1, 0, 0 },
121 /*expect*/ { 0,1,3, "" },
123 /* #10 : s is a null pointer, no chars should be stored in s. */
124 { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 5, 0, 0 },
125 /*expect*/ { 0,1,3, "" },
127 /* #11 : s is a null pointer. No chars should be stored in s. */
128 { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5, 0, 0 },
129 /*expect*/ { EILSEQ,1,(size_t)-1, "" },
131 /* #12 : ws is a null wc string, no chars should be stored in s. */
132 { /*input.*/ { 1,1, { 0x0000 }, 5, 0, 0 },
133 /*expect*/ { 0,1,0, "" },
135 /* #13 : s is a null pointer, no chars should be stored in s. */
136 { /*input.*/ { 0,1, { 0x0000 }, 5, 0, 0 },
137 /*expect*/ { 0,1,0, "" },
139 { .is_last = 1 }
143 { Twcsrtombs, 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, 0, 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, 0, 0 },
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, 0, 0 },
156 /*expect*/ { 0,1,4, "\244\242\244\244" },
158 /* #04 : Only three chars should be stored in s. No null
159 termination. */
160 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 6, 0, 0 },
161 /*expect*/ { 0,1,6, "\244\242\244\244\216\263" },
163 /* #05 : Only three chars should be stored in s with a null
164 termination. */
165 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 7, 0, 0 },
166 /*expect*/ { 0,1,6, "\244\242\244\244\216\263" },
168 /* #06 : Only three chars should be stored in s with a null
169 termination. */
170 { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 8, 0, 0 },
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, 0, 0 },
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, 0, 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, 0, 0 },
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, 0, 0 },
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, 0, 0 },
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, 0, 0 },
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, 0, 0 },
199 /*expect*/ { 0,1,0, "" },
201 { .is_last = 1 }
205 { Twcsrtombs, TST_LOC_end }