x86_64: Fix svml_s_tanhf8_core_avx2.S code formatting
[glibc.git] / wcsmbs / tst-mbrtowc2.c
blob95e95414668b8208559883707880f9d18ac6109b
1 /* Derived from the test case in
2 https://sourceware.org/bugzilla/show_bug.cgi?id=714 */
3 #include <locale.h>
4 #include <stdio.h>
5 #include <string.h>
6 #include <wchar.h>
9 static struct
11 const char *chp;
12 size_t nchp;
13 const char *loc;
14 } tests[] =
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);
29 static int
30 do_test (void)
32 int r = 0;
33 for (int i = 0; i < ntests; ++i)
34 r |= t (tests[i].chp, tests[i].nchp, tests[i].loc);
35 return r;
38 static int
39 t (const char *ch, size_t nch, const char *loc)
41 int i;
42 wchar_t wch;
43 wchar_t wch2;
44 mbstate_t mbs;
45 int n = 0;
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);
53 if (n >= 0)
54 break;
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");
64 return ret;
67 #include <support/test-driver.c>