1 /* Derived from the test case in
2 https://sourceware.org/bugzilla/show_bug.cgi?id=714 */
16 { (const char[]) { 0x8F, 0xA2, 0xAF }, 3, "ja_JP.EUC-JP" },
17 { (const char[]) { 0xD1, 0xA5 }, 2, "ja_JP.EUC-JP" },
18 { (const char[]) { 0x8E, 0xA5 }, 2, "ja_JP.EUC-JP" },
19 { (const char[]) { 0x8E, 0xA2, 0xA1, 0xA1 }, 4, "zh_TW.EUC-TW" },
20 { (const char[]) { 0xA1, 0xA1 }, 2, "zh_TW.EUC-TW" },
21 { (const char[]) { 0xE3, 0x80, 0x80 }, 3, "de_DE.UTF-8" },
22 { (const char[]) { 0xC3, 0xA4 }, 2, "de_DE.UTF-8" }
24 #define ntests (sizeof (tests) / sizeof (tests[0]))
27 static int t (const char *ch
, size_t nch
, const char *loc
);
33 for (int i
= 0; i
< ntests
; ++i
)
34 r
|= t (tests
[i
].chp
, tests
[i
].nchp
, tests
[i
].loc
);
39 t (const char *ch
, size_t nch
, const char *loc
)
47 setlocale (LC_ALL
, loc
);
49 memset (&mbs
, '\0', sizeof (mbstate_t));
50 for (i
= 0; i
< nch
; i
++)
52 n
= mbrtowc (&wch
, ch
+ i
, 1, &mbs
);
56 printf ("n = %d, count = %d, wch = %08lX\n", n
, i
, (unsigned long int) wch
);
58 memset (&mbs
, '\0', sizeof (mbstate_t));
59 n
= mbrtowc (&wch2
, ch
, nch
, &mbs
);
60 printf ("n = %d, wch = %08lX\n", n
, (unsigned long int) wch2
);
62 int ret
= n
!= nch
|| i
+ 1 != nch
|| n
!= nch
|| wch
!= wch2
;
63 puts (ret
? "FAIL\n" : "OK\n");
67 #include <support/test-driver.c>