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