1 /* Test of conversion of multibyte character to 16-bit wide characters.
2 Copyright (C) 2008-2024 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
28 #include "localcharset.h"
31 #if defined _WIN32 && !defined __CYGWIN__
34 test_one_locale (const char *name
, int codepage
)
41 /* Portable code to set the locale. */
43 char name_with_codepage
[1024];
45 sprintf (name_with_codepage
, "%s.%d", name
, codepage
);
48 if (setlocale (LC_ALL
, name_with_codepage
) == NULL
)
52 /* Hacky way to set a locale.codepage combination that setlocale() refuses
55 /* Codepage of the current locale, set with setlocale().
56 Not necessarily the same as GetACP(). */
57 extern __declspec(dllimport
) unsigned int __lc_codepage
;
60 if (setlocale (LC_ALL
, name
) == NULL
)
63 /* Clobber the codepage and MB_CUR_MAX, both set by setlocale(). */
64 __lc_codepage
= codepage
;
82 /* Test whether the codepage is really available. */
83 memset (&state
, '\0', sizeof (mbstate_t));
84 if (mbrtoc16 (&wc
, " ", 1, &state
) == (size_t)(-1))
89 /* Test zero-length input. */
91 memset (&state
, '\0', sizeof (mbstate_t));
92 wc
= (char16_t
) 0xBADF;
93 ret
= mbrtoc16 (&wc
, "x", 0, &state
);
94 ASSERT (ret
== (size_t)(-2));
95 ASSERT (mbsinit (&state
));
98 /* Test NUL byte input. */
100 memset (&state
, '\0', sizeof (mbstate_t));
101 wc
= (char16_t
) 0xBADF;
102 ret
= mbrtoc16 (&wc
, "", 1, &state
);
105 ASSERT (mbsinit (&state
));
106 ret
= mbrtoc16 (NULL
, "", 1, &state
);
108 ASSERT (mbsinit (&state
));
111 /* Test single-byte input. */
116 memset (&state
, '\0', sizeof (mbstate_t));
117 for (c
= 0; c
< 0x100; c
++)
120 case '\t': case '\v': case '\f':
121 case ' ': case '!': case '"': case '#': case '%':
122 case '&': case '\'': case '(': case ')': case '*':
123 case '+': case ',': case '-': case '.': case '/':
124 case '0': case '1': case '2': case '3': case '4':
125 case '5': case '6': case '7': case '8': case '9':
126 case ':': case ';': case '<': case '=': case '>':
128 case 'A': case 'B': case 'C': case 'D': case 'E':
129 case 'F': case 'G': case 'H': case 'I': case 'J':
130 case 'K': case 'L': case 'M': case 'N': case 'O':
131 case 'P': case 'Q': case 'R': case 'S': case 'T':
132 case 'U': case 'V': case 'W': case 'X': case 'Y':
134 case '[': case '\\': case ']': case '^': case '_':
135 case 'a': case 'b': case 'c': case 'd': case 'e':
136 case 'f': case 'g': case 'h': case 'i': case 'j':
137 case 'k': case 'l': case 'm': case 'n': case 'o':
138 case 'p': case 'q': case 'r': case 's': case 't':
139 case 'u': case 'v': case 'w': case 'x': case 'y':
140 case 'z': case '{': case '|': case '}': case '~':
141 /* c is in the ISO C "basic character set". */
143 wc
= (char16_t
) 0xBADF;
144 ret
= mbrtoc16 (&wc
, buf
, 1, &state
);
147 ASSERT (mbsinit (&state
));
148 ret
= mbrtoc16 (NULL
, buf
, 1, &state
);
150 ASSERT (mbsinit (&state
));
155 /* Test special calling convention, passing a NULL pointer. */
157 memset (&state
, '\0', sizeof (mbstate_t));
158 wc
= (char16_t
) 0xBADF;
159 ret
= mbrtoc16 (&wc
, NULL
, 5, &state
);
161 ASSERT (wc
== (char16_t
) 0xBADF);
162 ASSERT (mbsinit (&state
));
168 /* Locale encoding is CP1252, an extension of ISO-8859-1. */
170 char input
[] = "B\374\337er"; /* "Büßer" */
171 memset (&state
, '\0', sizeof (mbstate_t));
173 wc
= (char16_t
) 0xBADF;
174 ret
= mbrtoc16 (&wc
, input
, 1, &state
);
177 ASSERT (mbsinit (&state
));
180 wc
= (char16_t
) 0xBADF;
181 ret
= mbrtoc16 (&wc
, input
+ 1, 1, &state
);
183 ASSERT (c32tob (wc
) == (unsigned char) '\374');
184 ASSERT (wc
== 0x00FC);
185 ASSERT (mbsinit (&state
));
188 /* Test support of NULL first argument. */
189 ret
= mbrtoc16 (NULL
, input
+ 2, 3, &state
);
191 ASSERT (mbsinit (&state
));
193 wc
= (char16_t
) 0xBADF;
194 ret
= mbrtoc16 (&wc
, input
+ 2, 3, &state
);
196 ASSERT (c32tob (wc
) == (unsigned char) '\337');
197 ASSERT (wc
== 0x00DF);
198 ASSERT (mbsinit (&state
));
201 wc
= (char16_t
) 0xBADF;
202 ret
= mbrtoc16 (&wc
, input
+ 3, 2, &state
);
205 ASSERT (mbsinit (&state
));
208 wc
= (char16_t
) 0xBADF;
209 ret
= mbrtoc16 (&wc
, input
+ 4, 1, &state
);
212 ASSERT (mbsinit (&state
));
217 /* Locale encoding is CP1256, not the same as ISO-8859-6. */
219 char input
[] = "x\302\341\346y"; /* "xآلوy" */
220 memset (&state
, '\0', sizeof (mbstate_t));
222 wc
= (char16_t
) 0xBADF;
223 ret
= mbrtoc16 (&wc
, input
, 1, &state
);
226 ASSERT (mbsinit (&state
));
229 wc
= (char16_t
) 0xBADF;
230 ret
= mbrtoc16 (&wc
, input
+ 1, 1, &state
);
232 ASSERT (c32tob (wc
) == (unsigned char) '\302');
233 ASSERT (wc
== 0x0622);
234 ASSERT (mbsinit (&state
));
237 /* Test support of NULL first argument. */
238 ret
= mbrtoc16 (NULL
, input
+ 2, 3, &state
);
240 ASSERT (mbsinit (&state
));
242 wc
= (char16_t
) 0xBADF;
243 ret
= mbrtoc16 (&wc
, input
+ 2, 3, &state
);
245 ASSERT (c32tob (wc
) == (unsigned char) '\341');
246 ASSERT (wc
== 0x0644);
247 ASSERT (mbsinit (&state
));
250 wc
= (char16_t
) 0xBADF;
251 ret
= mbrtoc16 (&wc
, input
+ 3, 2, &state
);
253 ASSERT (c32tob (wc
) == (unsigned char) '\346');
254 ASSERT (wc
== 0x0648);
255 ASSERT (mbsinit (&state
));
258 wc
= (char16_t
) 0xBADF;
259 ret
= mbrtoc16 (&wc
, input
+ 4, 1, &state
);
262 ASSERT (mbsinit (&state
));
267 /* Locale encoding is CP65001 = UTF-8. */
268 if (strcmp (locale_charset (), "UTF-8") != 0)
271 char input
[] = "s\303\274\303\237\360\237\230\213!"; /* "süß😋!" */
272 memset (&state
, '\0', sizeof (mbstate_t));
274 wc
= (char16_t
) 0xBADF;
275 ret
= mbrtoc16 (&wc
, input
, 1, &state
);
278 ASSERT (mbsinit (&state
));
281 wc
= (char16_t
) 0xBADF;
282 ret
= mbrtoc16 (&wc
, input
+ 1, 1, &state
);
283 ASSERT (ret
== (size_t)(-2));
284 ASSERT (wc
== (char16_t
) 0xBADF);
286 ASSERT (!mbsinit (&state
));
290 wc
= (char16_t
) 0xBADF;
291 ret
= mbrtoc16 (&wc
, input
+ 2, 7, &state
);
293 ASSERT (c32tob (wc
) == EOF
);
294 ASSERT (wc
== 0x00FC);
295 ASSERT (mbsinit (&state
));
298 /* Test support of NULL first argument. */
299 ret
= mbrtoc16 (NULL
, input
+ 3, 6, &state
);
301 ASSERT (mbsinit (&state
));
303 wc
= (char16_t
) 0xBADF;
304 ret
= mbrtoc16 (&wc
, input
+ 3, 6, &state
);
306 ASSERT (c32tob (wc
) == EOF
);
307 ASSERT (wc
== 0x00DF);
308 ASSERT (mbsinit (&state
));
312 /* Test support of NULL first argument. */
313 ret
= mbrtoc16 (NULL
, input
+ 5, 4, &state
);
315 ret
= mbrtoc16 (NULL
, input
+ 9, 0, &state
);
316 ASSERT (ret
== (size_t)(-3));
317 ASSERT (mbsinit (&state
));
319 wc
= (char16_t
) 0xBADF;
320 ret
= mbrtoc16 (&wc
, input
+ 5, 4, &state
);
322 ASSERT (c32tob (wc
) == EOF
);
323 ASSERT (wc
== 0xD83D); /* expect UTF-16 encoding */
328 wc
= (char16_t
) 0xBADF;
329 ret
= mbrtoc16 (&wc
, input
+ 9, 0, &state
);
330 ASSERT (ret
== (size_t)(-3));
331 ASSERT (c32tob (wc
) == EOF
);
332 ASSERT (wc
== 0xDE0B); /* expect UTF-16 encoding */
333 ASSERT (mbsinit (&state
));
335 wc
= (char16_t
) 0xBADF;
336 ret
= mbrtoc16 (&wc
, input
+ 9, 1, &state
);
339 ASSERT (mbsinit (&state
));
341 /* Test some invalid input. */
342 memset (&state
, '\0', sizeof (mbstate_t));
343 wc
= (char16_t
) 0xBADF;
344 ret
= mbrtoc16 (&wc
, "\377", 1, &state
); /* 0xFF */
345 ASSERT (ret
== (size_t)-1);
346 ASSERT (errno
== EILSEQ
);
348 memset (&state
, '\0', sizeof (mbstate_t));
349 wc
= (char16_t
) 0xBADF;
350 ret
= mbrtoc16 (&wc
, "\303\300", 2, &state
); /* 0xC3 0xC0 */
351 ASSERT (ret
== (size_t)-1);
352 ASSERT (errno
== EILSEQ
);
354 memset (&state
, '\0', sizeof (mbstate_t));
355 wc
= (char16_t
) 0xBADF;
356 ret
= mbrtoc16 (&wc
, "\343\300", 2, &state
); /* 0xE3 0xC0 */
357 ASSERT (ret
== (size_t)-1);
358 ASSERT (errno
== EILSEQ
);
360 memset (&state
, '\0', sizeof (mbstate_t));
361 wc
= (char16_t
) 0xBADF;
362 ret
= mbrtoc16 (&wc
, "\343\300\200", 3, &state
); /* 0xE3 0xC0 0x80 */
363 ASSERT (ret
== (size_t)-1);
364 ASSERT (errno
== EILSEQ
);
366 memset (&state
, '\0', sizeof (mbstate_t));
367 wc
= (char16_t
) 0xBADF;
368 ret
= mbrtoc16 (&wc
, "\343\200\300", 3, &state
); /* 0xE3 0x80 0xC0 */
369 ASSERT (ret
== (size_t)-1);
370 ASSERT (errno
== EILSEQ
);
372 memset (&state
, '\0', sizeof (mbstate_t));
373 wc
= (char16_t
) 0xBADF;
374 ret
= mbrtoc16 (&wc
, "\363\300", 2, &state
); /* 0xF3 0xC0 */
375 ASSERT (ret
== (size_t)-1);
376 ASSERT (errno
== EILSEQ
);
378 memset (&state
, '\0', sizeof (mbstate_t));
379 wc
= (char16_t
) 0xBADF;
380 ret
= mbrtoc16 (&wc
, "\363\300\200\200", 4, &state
); /* 0xF3 0xC0 0x80 0x80 */
381 ASSERT (ret
== (size_t)-1);
382 ASSERT (errno
== EILSEQ
);
384 memset (&state
, '\0', sizeof (mbstate_t));
385 wc
= (char16_t
) 0xBADF;
386 ret
= mbrtoc16 (&wc
, "\363\200\300", 3, &state
); /* 0xF3 0x80 0xC0 */
387 ASSERT (ret
== (size_t)-1);
388 ASSERT (errno
== EILSEQ
);
390 memset (&state
, '\0', sizeof (mbstate_t));
391 wc
= (char16_t
) 0xBADF;
392 ret
= mbrtoc16 (&wc
, "\363\200\300\200", 4, &state
); /* 0xF3 0x80 0xC0 0x80 */
393 ASSERT (ret
== (size_t)-1);
394 ASSERT (errno
== EILSEQ
);
396 memset (&state
, '\0', sizeof (mbstate_t));
397 wc
= (char16_t
) 0xBADF;
398 ret
= mbrtoc16 (&wc
, "\363\200\200\300", 4, &state
); /* 0xF3 0x80 0x80 0xC0 */
399 ASSERT (ret
== (size_t)-1);
400 ASSERT (errno
== EILSEQ
);
405 /* Locale encoding is CP932, similar to Shift_JIS. */
407 char input
[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */
408 memset (&state
, '\0', sizeof (mbstate_t));
410 wc
= (char16_t
) 0xBADF;
411 ret
= mbrtoc16 (&wc
, input
, 1, &state
);
414 ASSERT (mbsinit (&state
));
417 wc
= (char16_t
) 0xBADF;
418 ret
= mbrtoc16 (&wc
, input
+ 1, 2, &state
);
420 ASSERT (c32tob (wc
) == EOF
);
421 ASSERT (wc
== 0x65E5);
422 ASSERT (mbsinit (&state
));
426 wc
= (char16_t
) 0xBADF;
427 ret
= mbrtoc16 (&wc
, input
+ 3, 1, &state
);
428 ASSERT (ret
== (size_t)(-2));
429 ASSERT (wc
== (char16_t
) 0xBADF);
431 ASSERT (!mbsinit (&state
));
435 wc
= (char16_t
) 0xBADF;
436 ret
= mbrtoc16 (&wc
, input
+ 4, 4, &state
);
438 ASSERT (c32tob (wc
) == EOF
);
439 ASSERT (wc
== 0x672C);
440 ASSERT (mbsinit (&state
));
443 /* Test support of NULL first argument. */
444 ret
= mbrtoc16 (NULL
, input
+ 5, 3, &state
);
446 ASSERT (mbsinit (&state
));
448 wc
= (char16_t
) 0xBADF;
449 ret
= mbrtoc16 (&wc
, input
+ 5, 3, &state
);
451 ASSERT (c32tob (wc
) == EOF
);
452 ASSERT (wc
== 0x8A9E);
453 ASSERT (mbsinit (&state
));
457 wc
= (char16_t
) 0xBADF;
458 ret
= mbrtoc16 (&wc
, input
+ 7, 1, &state
);
461 ASSERT (mbsinit (&state
));
463 /* Test some invalid input. */
464 memset (&state
, '\0', sizeof (mbstate_t));
465 wc
= (char16_t
) 0xBADF;
466 ret
= mbrtoc16 (&wc
, "\377", 1, &state
); /* 0xFF */
467 ASSERT ((ret
== (size_t)-1 && errno
== EILSEQ
) || ret
== (size_t)-2);
469 memset (&state
, '\0', sizeof (mbstate_t));
470 wc
= (char16_t
) 0xBADF;
471 ret
= mbrtoc16 (&wc
, "\225\377", 2, &state
); /* 0x95 0xFF */
472 ASSERT ((ret
== (size_t)-1 && errno
== EILSEQ
) || (ret
== 2 && wc
== 0x30FB));
477 /* Locale encoding is CP950, similar to Big5. */
479 char input
[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */
480 memset (&state
, '\0', sizeof (mbstate_t));
482 wc
= (char16_t
) 0xBADF;
483 ret
= mbrtoc16 (&wc
, input
, 1, &state
);
486 ASSERT (mbsinit (&state
));
489 wc
= (char16_t
) 0xBADF;
490 ret
= mbrtoc16 (&wc
, input
+ 1, 2, &state
);
492 ASSERT (c32tob (wc
) == EOF
);
493 ASSERT (wc
== 0x65E5);
494 ASSERT (mbsinit (&state
));
498 wc
= (char16_t
) 0xBADF;
499 ret
= mbrtoc16 (&wc
, input
+ 3, 1, &state
);
500 ASSERT (ret
== (size_t)(-2));
501 ASSERT (wc
== (char16_t
) 0xBADF);
503 ASSERT (!mbsinit (&state
));
507 wc
= (char16_t
) 0xBADF;
508 ret
= mbrtoc16 (&wc
, input
+ 4, 4, &state
);
510 ASSERT (c32tob (wc
) == EOF
);
511 ASSERT (wc
== 0x672C);
512 ASSERT (mbsinit (&state
));
515 /* Test support of NULL first argument. */
516 ret
= mbrtoc16 (NULL
, input
+ 5, 3, &state
);
518 ASSERT (mbsinit (&state
));
520 wc
= (char16_t
) 0xBADF;
521 ret
= mbrtoc16 (&wc
, input
+ 5, 3, &state
);
523 ASSERT (c32tob (wc
) == EOF
);
524 ASSERT (wc
== 0x8A9E);
525 ASSERT (mbsinit (&state
));
529 wc
= (char16_t
) 0xBADF;
530 ret
= mbrtoc16 (&wc
, input
+ 7, 1, &state
);
533 ASSERT (mbsinit (&state
));
535 /* Test some invalid input. */
536 memset (&state
, '\0', sizeof (mbstate_t));
537 wc
= (char16_t
) 0xBADF;
538 ret
= mbrtoc16 (&wc
, "\377", 1, &state
); /* 0xFF */
539 ASSERT ((ret
== (size_t)-1 && errno
== EILSEQ
) || ret
== (size_t)-2);
541 memset (&state
, '\0', sizeof (mbstate_t));
542 wc
= (char16_t
) 0xBADF;
543 ret
= mbrtoc16 (&wc
, "\225\377", 2, &state
); /* 0x95 0xFF */
544 ASSERT ((ret
== (size_t)-1 && errno
== EILSEQ
) || (ret
== 2 && wc
== '?'));
549 /* Locale encoding is CP936 = GBK, an extension of GB2312. */
551 char input
[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */
552 memset (&state
, '\0', sizeof (mbstate_t));
554 wc
= (char16_t
) 0xBADF;
555 ret
= mbrtoc16 (&wc
, input
, 1, &state
);
558 ASSERT (mbsinit (&state
));
561 wc
= (char16_t
) 0xBADF;
562 ret
= mbrtoc16 (&wc
, input
+ 1, 2, &state
);
564 ASSERT (c32tob (wc
) == EOF
);
565 ASSERT (wc
== 0x65E5);
566 ASSERT (mbsinit (&state
));
570 wc
= (char16_t
) 0xBADF;
571 ret
= mbrtoc16 (&wc
, input
+ 3, 1, &state
);
572 ASSERT (ret
== (size_t)(-2));
573 ASSERT (wc
== (char16_t
) 0xBADF);
575 ASSERT (!mbsinit (&state
));
579 wc
= (char16_t
) 0xBADF;
580 ret
= mbrtoc16 (&wc
, input
+ 4, 4, &state
);
582 ASSERT (c32tob (wc
) == EOF
);
583 ASSERT (wc
== 0x672C);
584 ASSERT (mbsinit (&state
));
587 /* Test support of NULL first argument. */
588 ret
= mbrtoc16 (NULL
, input
+ 5, 3, &state
);
590 ASSERT (mbsinit (&state
));
592 wc
= (char16_t
) 0xBADF;
593 ret
= mbrtoc16 (&wc
, input
+ 5, 3, &state
);
595 ASSERT (c32tob (wc
) == EOF
);
596 ASSERT (wc
== 0x8A9E);
597 ASSERT (mbsinit (&state
));
601 wc
= (char16_t
) 0xBADF;
602 ret
= mbrtoc16 (&wc
, input
+ 7, 1, &state
);
605 ASSERT (mbsinit (&state
));
607 /* Test some invalid input. */
608 memset (&state
, '\0', sizeof (mbstate_t));
609 wc
= (char16_t
) 0xBADF;
610 ret
= mbrtoc16 (&wc
, "\377", 1, &state
); /* 0xFF */
611 ASSERT ((ret
== (size_t)-1 && errno
== EILSEQ
) || ret
== (size_t)-2);
613 memset (&state
, '\0', sizeof (mbstate_t));
614 wc
= (char16_t
) 0xBADF;
615 ret
= mbrtoc16 (&wc
, "\225\377", 2, &state
); /* 0x95 0xFF */
616 ASSERT ((ret
== (size_t)-1 && errno
== EILSEQ
) || (ret
== 2 && wc
== '?'));
621 /* Locale encoding is CP54936 = GB18030. */
622 if (strcmp (locale_charset (), "GB18030") != 0)
625 char input
[] = "s\250\271\201\060\211\070\224\071\375\067!"; /* "süß😋!" */
626 memset (&state
, '\0', sizeof (mbstate_t));
628 wc
= (char16_t
) 0xBADF;
629 ret
= mbrtoc16 (&wc
, input
, 1, &state
);
632 ASSERT (mbsinit (&state
));
635 wc
= (char16_t
) 0xBADF;
636 ret
= mbrtoc16 (&wc
, input
+ 1, 1, &state
);
637 ASSERT (ret
== (size_t)(-2));
638 ASSERT (wc
== (char16_t
) 0xBADF);
640 ASSERT (!mbsinit (&state
));
644 wc
= (char16_t
) 0xBADF;
645 ret
= mbrtoc16 (&wc
, input
+ 2, 9, &state
);
647 ASSERT (c32tob (wc
) == EOF
);
648 ASSERT (wc
== 0x00FC);
649 ASSERT (mbsinit (&state
));
652 /* Test support of NULL first argument. */
653 ret
= mbrtoc16 (NULL
, input
+ 3, 8, &state
);
655 ASSERT (mbsinit (&state
));
657 wc
= (char16_t
) 0xBADF;
658 ret
= mbrtoc16 (&wc
, input
+ 3, 8, &state
);
660 ASSERT (c32tob (wc
) == EOF
);
661 ASSERT (wc
== 0x00DF);
662 ASSERT (mbsinit (&state
));
668 /* Test support of NULL first argument. */
669 ret
= mbrtoc16 (NULL
, input
+ 7, 4, &state
);
671 ret
= mbrtoc16 (NULL
, input
+ 11, 0, &state
);
672 ASSERT (ret
== (size_t)(-3));
673 ASSERT (mbsinit (&state
));
675 wc
= (char16_t
) 0xBADF;
676 ret
= mbrtoc16 (&wc
, input
+ 7, 4, &state
);
678 ASSERT (c32tob (wc
) == EOF
);
679 ASSERT (wc
== 0xD83D); /* expect UTF-16 encoding */
684 wc
= (char16_t
) 0xBADF;
685 ret
= mbrtoc16 (&wc
, input
+ 11, 0, &state
);
686 ASSERT (ret
== (size_t)(-3));
687 ASSERT (c32tob (wc
) == EOF
);
688 ASSERT (wc
== 0xDE0B); /* expect UTF-16 encoding */
689 ASSERT (mbsinit (&state
));
691 wc
= (char16_t
) 0xBADF;
692 ret
= mbrtoc16 (&wc
, input
+ 11, 1, &state
);
695 ASSERT (mbsinit (&state
));
697 /* Test some invalid input. */
698 memset (&state
, '\0', sizeof (mbstate_t));
699 wc
= (char16_t
) 0xBADF;
700 ret
= mbrtoc16 (&wc
, "\377", 1, &state
); /* 0xFF */
701 ASSERT (ret
== (size_t)-1);
702 ASSERT (errno
== EILSEQ
);
704 memset (&state
, '\0', sizeof (mbstate_t));
705 wc
= (char16_t
) 0xBADF;
706 ret
= mbrtoc16 (&wc
, "\225\377", 2, &state
); /* 0x95 0xFF */
707 ASSERT (ret
== (size_t)-1);
708 ASSERT (errno
== EILSEQ
);
710 memset (&state
, '\0', sizeof (mbstate_t));
711 wc
= (char16_t
) 0xBADF;
712 ret
= mbrtoc16 (&wc
, "\201\045", 2, &state
); /* 0x81 0x25 */
713 ASSERT (ret
== (size_t)-1);
714 ASSERT (errno
== EILSEQ
);
716 memset (&state
, '\0', sizeof (mbstate_t));
717 wc
= (char16_t
) 0xBADF;
718 ret
= mbrtoc16 (&wc
, "\201\060\377", 3, &state
); /* 0x81 0x30 0xFF */
719 ASSERT (ret
== (size_t)-1);
720 ASSERT (errno
== EILSEQ
);
722 memset (&state
, '\0', sizeof (mbstate_t));
723 wc
= (char16_t
) 0xBADF;
724 ret
= mbrtoc16 (&wc
, "\201\060\377\064", 4, &state
); /* 0x81 0x30 0xFF 0x34 */
725 ASSERT (ret
== (size_t)-1);
726 ASSERT (errno
== EILSEQ
);
728 memset (&state
, '\0', sizeof (mbstate_t));
729 wc
= (char16_t
) 0xBADF;
730 ret
= mbrtoc16 (&wc
, "\201\060\211\072", 4, &state
); /* 0x81 0x30 0x89 0x3A */
731 ASSERT (ret
== (size_t)-1);
732 ASSERT (errno
== EILSEQ
);
742 main (int argc
, char *argv
[])
744 int codepage
= atoi (argv
[argc
- 1]);
749 for (i
= 1; i
< argc
- 1; i
++)
751 int ret
= test_one_locale (argv
[i
], codepage
);
759 if (test_exit_status
!= EXIT_SUCCESS
)
760 return test_exit_status
;
761 fprintf (stderr
, "Skipping test: found no locale with codepage %d\n",
764 return (result
? result
: test_exit_status
);
770 main (int argc
, char *argv
[])
772 fputs ("Skipping test: not a native Windows system\n", stderr
);