1 /*
2  *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
3  *
4  *	 FILE:	dat_wcsrtombs.c
5  *
6  *	 WCSTOMBS:  size_t wcsrtombs (char *s, const wchar_t **ws,
7  *				      size_t n, mbstate *ps)
8  */
9 
10 
11 /*
12  *  CAUTION:
13  *	     Do not use a value 0x01 for string data. The test program
14  *	     uses it.
15  *
16  */
17 
18 
19 TST_WCSRTOMBS tst_wcsrtombs_loc [] = {
20   {
21     { Twcsrtombs, TST_LOC_de },
22     {
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,	 ""					},
26       },
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,	 "�"					 },
30       },
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,	 "��"					 },
34       },
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,	 "���"					 },
39       },
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,	 "���"					 },
44       },
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,	 "���"					 },
49       },
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,	 ""			 },
53       },
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,	 ""					 },
57       },
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,	 ""					 },
61       },
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,	 ""					 },
65       },
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,	 ""			 },
69       },
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,	 ""					 },
73       },
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,	 ""					 },
77       },
78       { .is_last = 1 }
79     }
80   },
81   {
82     { Twcsrtombs, TST_LOC_enUS },
83     {
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,	 ""					 },
87       },
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"					 },
91       },
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"					 },
95       },
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"					 },
100       },
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"					 },
105       },
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"					 },
110       },
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,	 ""					},
114       },
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,	 ""					 },
118       },
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,	 ""					 },
122       },
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,	 ""					 },
126       },
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,	 ""			 },
130       },
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,	 ""					 },
134       },
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,	 ""					 },
138       },
139       { .is_last = 1 }
140     }
141   },
142   {
143     { Twcsrtombs, 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, 0, 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, 0, 0 },
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, 0, 0 },
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, 0, 0 },
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, 0, 0 },
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, 0, 0 },
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, 0, 0 },
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, 0, 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, 0, 0 },
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, 0, 0 },
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, 0, 0 },
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, 0, 0 },
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, 0, 0 },
199 	/*expect*/ { 0,1,0,	 ""					 },
200       },
201       { .is_last = 1 }
202     }
203   },
204   {
205     { Twcsrtombs, TST_LOC_end }
206   }
207 };
208