]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/test/locale-mbwc/dat_wcstombs.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / test / locale-mbwc / dat_wcstombs.c
1 /*
2  *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
3  *
4  *       FILE:  dat_wcstombs.c
5  *
6  *       WCSTOMBS:  size_t wcstombs (char *s, const wchar_t *ws, size_t n)
7  */
8
9
10 /*
11  *  CAUTION:
12  *           Do not use a value 0x01 for string data. The test program
13  *           uses it.
14  *
15  */
16
17
18 TST_WCSTOMBS tst_wcstombs_loc [] = {
19   {
20     { Twcstombs, TST_LOC_de },
21     {
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,      ""                                       },
25       },
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,      "Ä"                                      },
29       },
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,      "ÄÖ"                                     },
33       },
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,      "ÄÖÜ"                                    },
38       },
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,      "ÄÖÜ"                                    },
43       },
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,      "ÄÖÜ"                                    },
48       },
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,        ""                       },
52       },
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,      ""                                       },
56       },
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,      ""                                       },
60       },
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,      ""                                       },
64       },
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,        ""                       },
68       },
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,      ""                                       },
72       },
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,      ""                                       },
76       },
77       { .is_last = 1 }
78     }
79   },
80   {
81     { Twcstombs, TST_LOC_enUS },
82     {
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,      ""                                        },
86       },
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"                                       },
90       },
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"                                      },
94       },
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"                                     },
99       },
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"                                     },
104       },
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"                                     },
109       },
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,        ""                        },
113       },
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,      ""                                        },
117       },
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,      ""                                        },
121       },
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,      ""                                        },
125       },
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,        ""                        },
129       },
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,      ""                                        },
133       },
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,      ""                                        },
137       },
138       { .is_last = 1 }
139     }
140   },
141 #if 0
142   {
143     { Twcstombs, TST_LOC_eucJP },
144     {
145
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,      ""                                        },
149       },
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"                            },
153       },
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"                    },
157       },
158       /* #04 : Only three chars should be stored in s. No null
159                termination.  */
160       { /*input.*/ { 1,1,              { 0x3042,0x3044,0xFF73,0x0000 }, 6  },
161         /*expect*/ { 0,1,6,          "\244\242\244\244\216\263"            },
162       },
163       /* #05 : Only three chars should be stored in s with a null
164                termination.  */
165       { /*input.*/ { 1,1,              { 0x3042,0x3044,0xFF73,0x0000 }, 7  },
166         /*expect*/ { 0,1,6,          "\244\242\244\244\216\263"            },
167       },
168       /* #06 : Only three chars should be stored in s with a null
169                termination.  */
170       { /*input.*/ { 1,1,              { 0x3042,0x3044,0xFF73,0x0000 }, 8  },
171         /*expect*/ { 0,1,6,          "\244\242\244\244\216\263"            },
172       },
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,        ""                                },
176       },
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,      ""                                        },
180       },
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,      ""                                        },
184       },
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,      ""                                        },
188       },
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,        ""                        },
192       },
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,      ""                                        },
196       },
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,      ""                                        },
200       },
201       { .is_last = 1 }
202     }
203   },
204 #else
205   {
206     { Twcstombs, TST_LOC_ja_UTF8 },
207     {
208
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,      ""                                        },
212       },
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"                        },
216       },
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"            },
220       },
221       /* #04 : Only three chars should be stored in s. No null
222                termination.  */
223       { /*input.*/ { 1,1,              { 0x3042,0x3044,0xFF73,0x0000 }, 9  },
224         /*expect*/ { 0,1,9,     "\343\201\202\343\201\204\357\275\263"     },
225       },
226       /* #05 : Only three chars should be stored in s with a null
227                termination.  */
228       { /*input.*/ { 1,1,              { 0x3042,0x3044,0xFF73,0x0000 }, 10 },
229         /*expect*/ { 0,1,9,     "\343\201\202\343\201\204\357\275\263"     },
230       },
231       /* #06 : Only three chars should be stored in s with a null
232                termination.  */
233       { /*input.*/ { 1,1,              { 0x3042,0x3044,0xFF73,0x0000 }, 11 },
234         /*expect*/ { 0,1,9,     "\343\201\202\343\201\204\357\275\263"     },
235       },
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,        ""                                },
239       },
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,      ""                                        },
243       },
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,      ""                                        },
247       },
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,      ""                                        },
251       },
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,        ""                        },
255       },
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,      ""                                        },
259       },
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,      ""                                        },
263       },
264       { .is_last = 1 }
265     }
266   },
267 #endif
268   {
269     { Twcstombs, TST_LOC_end }
270   }
271 };