From: Bruno Haible Date: Sat, 29 Jul 2023 22:03:01 +0000 (+0200) Subject: mbrtowc tests: Renumber tests. X-Git-Tag: v1.0~1003 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=8937616375de19573f39628d13b182b23f5c20ec;p=gnulib.git mbrtowc tests: Renumber tests. * tests/test-mbrtowc*.sh: Renamed 1 -> 2 -> 3 -> 4 -> 5 -> 1. * tests/test-mbrtowc.c: Update. * tests/test-mbrtowc-w32-*.sh: Renamed 1 -> 2 -> 3 -> 5 -> 7 -> 4 -> 6 -> 8. * tests/test-mbrtowc-w32.c: Update. * modules/mbrtowc-tests: Update. --- diff --git a/ChangeLog b/ChangeLog index 3c7c412592..1de452327f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2023-07-29 Bruno Haible + mbrtowc tests: Renumber tests. + * tests/test-mbrtowc*.sh: Renamed 1 -> 2 -> 3 -> 4 -> 5 -> 1. + * tests/test-mbrtowc.c: Update. + * tests/test-mbrtowc-w32-*.sh: Renamed 1 -> 2 -> 3 -> 5 -> 7 -> 4 -> 6 + -> 8. + * tests/test-mbrtowc-w32.c: Update. + * modules/mbrtowc-tests: Update. + mbrlen tests: Renumber tests. * tests/test-mbrlen*.sh: Renamed 1 -> 2 -> 3 -> 4 -> 5 -> 1. * tests/test-mbrlen.c: Update. diff --git a/modules/mbrtowc-tests b/modules/mbrtowc-tests index 801425ad24..af02c94016 100644 --- a/modules/mbrtowc-tests +++ b/modules/mbrtowc-tests @@ -1,17 +1,17 @@ Files: -tests/test-mbrtowc1.sh -tests/test-mbrtowc2.sh -tests/test-mbrtowc3.sh -tests/test-mbrtowc4.sh -tests/test-mbrtowc5.sh +tests/test-mbrtowc-1.sh +tests/test-mbrtowc-2.sh +tests/test-mbrtowc-3.sh +tests/test-mbrtowc-4.sh +tests/test-mbrtowc-5.sh tests/test-mbrtowc.c -tests/test-mbrtowc-w32-1.sh tests/test-mbrtowc-w32-2.sh tests/test-mbrtowc-w32-3.sh tests/test-mbrtowc-w32-4.sh tests/test-mbrtowc-w32-5.sh tests/test-mbrtowc-w32-6.sh tests/test-mbrtowc-w32-7.sh +tests/test-mbrtowc-w32-8.sh tests/test-mbrtowc-w32.c tests/signature.h tests/macros.h @@ -34,11 +34,11 @@ gt_LOCALE_ZH_CN Makefile.am: TESTS += \ - test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh \ - test-mbrtowc5.sh \ - test-mbrtowc-w32-1.sh test-mbrtowc-w32-2.sh test-mbrtowc-w32-3.sh \ - test-mbrtowc-w32-4.sh test-mbrtowc-w32-5.sh test-mbrtowc-w32-6.sh \ - test-mbrtowc-w32-7.sh + test-mbrtowc-1.sh test-mbrtowc-2.sh test-mbrtowc-3.sh test-mbrtowc-4.sh \ + test-mbrtowc-5.sh \ + test-mbrtowc-w32-2.sh test-mbrtowc-w32-3.sh test-mbrtowc-w32-4.sh \ + test-mbrtowc-w32-5.sh test-mbrtowc-w32-6.sh test-mbrtowc-w32-7.sh \ + test-mbrtowc-w32-8.sh TESTS_ENVIRONMENT += \ LOCALE_FR='@LOCALE_FR@' \ LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ diff --git a/tests/test-mbrtowc-1.sh b/tests/test-mbrtowc-1.sh new file mode 100755 index 0000000000..f0a1feda19 --- /dev/null +++ b/tests/test-mbrtowc-1.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Test whether the POSIX locale has encoding errors. +LC_ALL=C \ +${CHECKER} ./test-mbrtowc${EXEEXT} 1 || exit 1 +LC_ALL=POSIX \ +${CHECKER} ./test-mbrtowc${EXEEXT} 1 || exit 1 + +exit 0 diff --git a/tests/test-mbrtowc-2.sh b/tests/test-mbrtowc-2.sh new file mode 100755 index 0000000000..30662926c7 --- /dev/null +++ b/tests/test-mbrtowc-2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-mbrtowc${EXEEXT} 2 diff --git a/tests/test-mbrtowc-3.sh b/tests/test-mbrtowc-3.sh new file mode 100755 index 0000000000..36b0023cd5 --- /dev/null +++ b/tests/test-mbrtowc-3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-mbrtowc${EXEEXT} 3 diff --git a/tests/test-mbrtowc-4.sh b/tests/test-mbrtowc-4.sh new file mode 100755 index 0000000000..1c5943ea97 --- /dev/null +++ b/tests/test-mbrtowc-4.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional japanese locale is installed" + else + echo "Skipping test: no traditional japanese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_JA \ +${CHECKER} ./test-mbrtowc${EXEEXT} 4 diff --git a/tests/test-mbrtowc-5.sh b/tests/test-mbrtowc-5.sh new file mode 100755 index 0000000000..8690bbeffe --- /dev/null +++ b/tests/test-mbrtowc-5.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no transitional chinese locale is installed" + else + echo "Skipping test: no transitional chinese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_ZH_CN \ +${CHECKER} ./test-mbrtowc${EXEEXT} 5 diff --git a/tests/test-mbrtowc-w32-1.sh b/tests/test-mbrtowc-w32-1.sh deleted file mode 100755 index fec9eadf26..0000000000 --- a/tests/test-mbrtowc-w32-1.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# Test a CP1252 locale. -${CHECKER} ./test-mbrtowc-w32${EXEEXT} French_France 1252 diff --git a/tests/test-mbrtowc-w32-2.sh b/tests/test-mbrtowc-w32-2.sh index c55a0ec0ae..fec9eadf26 100755 --- a/tests/test-mbrtowc-w32-2.sh +++ b/tests/test-mbrtowc-w32-2.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test a CP1256 locale. -${CHECKER} ./test-mbrtowc-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 +# Test a CP1252 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} French_France 1252 diff --git a/tests/test-mbrtowc-w32-3.sh b/tests/test-mbrtowc-w32-3.sh index c49f4bdf70..c55a0ec0ae 100755 --- a/tests/test-mbrtowc-w32-3.sh +++ b/tests/test-mbrtowc-w32-3.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test a CP932 locale. -${CHECKER} ./test-mbrtowc-w32${EXEEXT} Japanese_Japan 932 +# Test a CP1256 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 diff --git a/tests/test-mbrtowc-w32-4.sh b/tests/test-mbrtowc-w32-4.sh index 3e78615068..2c5d555f1b 100755 --- a/tests/test-mbrtowc-w32-4.sh +++ b/tests/test-mbrtowc-w32-4.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test a CP950 locale. -${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_Taiwan 950 +# Test some UTF-8 locales. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 diff --git a/tests/test-mbrtowc-w32-5.sh b/tests/test-mbrtowc-w32-5.sh index c6ba22261d..c49f4bdf70 100755 --- a/tests/test-mbrtowc-w32-5.sh +++ b/tests/test-mbrtowc-w32-5.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test a CP936 locale. -${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_China 936 +# Test a CP932 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Japanese_Japan 932 diff --git a/tests/test-mbrtowc-w32-6.sh b/tests/test-mbrtowc-w32-6.sh index c2e8dfe081..3e78615068 100755 --- a/tests/test-mbrtowc-w32-6.sh +++ b/tests/test-mbrtowc-w32-6.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test a GB18030 locale. -${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_China 54936 +# Test a CP950 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_Taiwan 950 diff --git a/tests/test-mbrtowc-w32-7.sh b/tests/test-mbrtowc-w32-7.sh index 2c5d555f1b..c6ba22261d 100755 --- a/tests/test-mbrtowc-w32-7.sh +++ b/tests/test-mbrtowc-w32-7.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test some UTF-8 locales. -${CHECKER} ./test-mbrtowc-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 +# Test a CP936 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_China 936 diff --git a/tests/test-mbrtowc-w32-8.sh b/tests/test-mbrtowc-w32-8.sh new file mode 100755 index 0000000000..c2e8dfe081 --- /dev/null +++ b/tests/test-mbrtowc-w32-8.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a GB18030 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_China 54936 diff --git a/tests/test-mbrtowc-w32.c b/tests/test-mbrtowc-w32.c index 5d07bb03ed..fcb7869b37 100644 --- a/tests/test-mbrtowc-w32.c +++ b/tests/test-mbrtowc-w32.c @@ -265,6 +265,126 @@ test_one_locale (const char *name, int codepage) } return 0; + case 65001: + /* Locale encoding is CP65001 = UTF-8. */ + if (strcmp (locale_charset (), "UTF-8") != 0) + return 77; + { + char input[] = "B\303\274\303\237er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 5, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x00FC); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 3, 4, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 4, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x00DF); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 6, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\303\300", 2, &state); /* 0xC3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\300", 2, &state); /* 0xE3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\300\200", 3, &state); /* 0xE3 0xC0 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\200\300", 3, &state); /* 0xE3 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\300", 2, &state); /* 0xF3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\300\200\200", 4, &state); /* 0xF3 0xC0 0x80 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\300", 3, &state); /* 0xF3 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\300\200", 4, &state); /* 0xF3 0x80 0xC0 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\200\300", 4, &state); /* 0xF3 0x80 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + } + return 0; + case 932: /* Locale encoding is CP932, similar to Shift_JIS. */ { @@ -573,126 +693,6 @@ test_one_locale (const char *name, int codepage) } return 0; - case 65001: - /* Locale encoding is CP65001 = UTF-8. */ - if (strcmp (locale_charset (), "UTF-8") != 0) - return 77; - { - char input[] = "B\303\274\303\237er"; /* "Büßer" */ - memset (&state, '\0', sizeof (mbstate_t)); - - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, input, 1, &state); - ASSERT (ret == 1); - ASSERT (wc == 'B'); - ASSERT (mbsinit (&state)); - input[0] = '\0'; - - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, input + 1, 1, &state); - ASSERT (ret == (size_t)(-2)); - ASSERT (wc == (wchar_t) 0xBADFACE); - ASSERT (!mbsinit (&state)); - input[1] = '\0'; - - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, input + 2, 5, &state); - ASSERT (ret == 1); - ASSERT (wctob (wc) == EOF); - ASSERT (wc == 0x00FC); - ASSERT (mbsinit (&state)); - input[2] = '\0'; - - /* Test support of NULL first argument. */ - ret = mbrtowc (NULL, input + 3, 4, &state); - ASSERT (ret == 2); - ASSERT (mbsinit (&state)); - - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, input + 3, 4, &state); - ASSERT (ret == 2); - ASSERT (wctob (wc) == EOF); - ASSERT (wc == 0x00DF); - ASSERT (mbsinit (&state)); - input[3] = '\0'; - input[4] = '\0'; - - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, input + 5, 2, &state); - ASSERT (ret == 1); - ASSERT (wc == 'e'); - ASSERT (mbsinit (&state)); - input[5] = '\0'; - - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, input + 6, 1, &state); - ASSERT (ret == 1); - ASSERT (wc == 'r'); - ASSERT (mbsinit (&state)); - - /* Test some invalid input. */ - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ - ASSERT (ret == (size_t)-1); - ASSERT (errno == EILSEQ); - - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, "\303\300", 2, &state); /* 0xC3 0xC0 */ - ASSERT (ret == (size_t)-1); - ASSERT (errno == EILSEQ); - - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, "\343\300", 2, &state); /* 0xE3 0xC0 */ - ASSERT (ret == (size_t)-1); - ASSERT (errno == EILSEQ); - - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, "\343\300\200", 3, &state); /* 0xE3 0xC0 0x80 */ - ASSERT (ret == (size_t)-1); - ASSERT (errno == EILSEQ); - - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, "\343\200\300", 3, &state); /* 0xE3 0x80 0xC0 */ - ASSERT (ret == (size_t)-1); - ASSERT (errno == EILSEQ); - - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, "\363\300", 2, &state); /* 0xF3 0xC0 */ - ASSERT (ret == (size_t)-1); - ASSERT (errno == EILSEQ); - - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, "\363\300\200\200", 4, &state); /* 0xF3 0xC0 0x80 0x80 */ - ASSERT (ret == (size_t)-1); - ASSERT (errno == EILSEQ); - - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, "\363\200\300", 3, &state); /* 0xF3 0x80 0xC0 */ - ASSERT (ret == (size_t)-1); - ASSERT (errno == EILSEQ); - - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, "\363\200\300\200", 4, &state); /* 0xF3 0x80 0xC0 0x80 */ - ASSERT (ret == (size_t)-1); - ASSERT (errno == EILSEQ); - - memset (&state, '\0', sizeof (mbstate_t)); - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, "\363\200\200\300", 4, &state); /* 0xF3 0x80 0x80 0xC0 */ - ASSERT (ret == (size_t)-1); - ASSERT (errno == EILSEQ); - } - return 0; - default: return 1; } diff --git a/tests/test-mbrtowc.c b/tests/test-mbrtowc.c index cf43011cad..be9df12e38 100644 --- a/tests/test-mbrtowc.c +++ b/tests/test-mbrtowc.c @@ -130,14 +130,48 @@ main (int argc, char *argv[]) "C" locale. Furthermore, when you attempt to set the "C" or "POSIX" locale via setlocale(), what you get is a "C" locale with UTF-8 encoding, that is, effectively the "C.UTF-8" locale. */ - if (argc > 1 && strcmp (argv[1], "5") == 0 && MB_CUR_MAX > 1) - argv[1] = "2"; + if (argc > 1 && strcmp (argv[1], "1") == 0 && MB_CUR_MAX > 1) + argv[1] = "3"; #endif if (argc > 1) switch (argv[1][0]) { case '1': + /* C or POSIX locale. */ + { + int c; + char buf[1]; + + memset (&state, '\0', sizeof (mbstate_t)); + for (c = 0; c < 0x100; c++) + if (c != 0) + { + /* We are testing all nonnull bytes. */ + buf[0] = c; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, buf, 1, &state); + /* POSIX:2018 says: "In the POSIX locale an [EILSEQ] error + cannot occur since all byte values are valid characters." */ + ASSERT (ret == 1); + if (c < 0x80) + /* c is an ASCII character. */ + ASSERT (wc == c); + else + /* On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF. + But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF. */ + ASSERT (wc == (btowc (c) == 0xDF00 + c ? btowc (c) : c)); + ASSERT (mbsinit (&state)); + + ret = mbrtowc (NULL, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + } + } + return 0; + + case '2': /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ { char input[] = "B\374\337er"; /* "Büßer" */ @@ -184,7 +218,7 @@ main (int argc, char *argv[]) } return 0; - case '2': + case '3': /* Locale encoding is UTF-8. */ { char input[] = "B\303\274\303\237er"; /* "Büßer" */ @@ -239,7 +273,7 @@ main (int argc, char *argv[]) } return 0; - case '3': + case '4': /* Locale encoding is EUC-JP. */ { char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ @@ -295,7 +329,7 @@ main (int argc, char *argv[]) } return 0; - case '4': + case '5': /* Locale encoding is GB18030. */ { char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ @@ -351,40 +385,6 @@ main (int argc, char *argv[]) ASSERT (mbsinit (&state)); } return 0; - - case '5': - /* C or POSIX locale. */ - { - int c; - char buf[1]; - - memset (&state, '\0', sizeof (mbstate_t)); - for (c = 0; c < 0x100; c++) - if (c != 0) - { - /* We are testing all nonnull bytes. */ - buf[0] = c; - - wc = (wchar_t) 0xBADFACE; - ret = mbrtowc (&wc, buf, 1, &state); - /* POSIX:2018 says: "In the POSIX locale an [EILSEQ] error - cannot occur since all byte values are valid characters." */ - ASSERT (ret == 1); - if (c < 0x80) - /* c is an ASCII character. */ - ASSERT (wc == c); - else - /* On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF. - But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF. */ - ASSERT (wc == (btowc (c) == 0xDF00 + c ? btowc (c) : c)); - ASSERT (mbsinit (&state)); - - ret = mbrtowc (NULL, buf, 1, &state); - ASSERT (ret == 1); - ASSERT (mbsinit (&state)); - } - } - return 0; } return 1; diff --git a/tests/test-mbrtowc1.sh b/tests/test-mbrtowc1.sh deleted file mode 100755 index 2b6eaf99c9..0000000000 --- a/tests/test-mbrtowc1.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Test in an ISO-8859-1 or ISO-8859-15 locale. -: "${LOCALE_FR=fr_FR}" -if test $LOCALE_FR = none; then - if test -f /usr/bin/localedef; then - echo "Skipping test: no traditional french locale is installed" - else - echo "Skipping test: no traditional french locale is supported" - fi - exit 77 -fi - -LC_ALL=$LOCALE_FR \ -${CHECKER} ./test-mbrtowc${EXEEXT} 1 diff --git a/tests/test-mbrtowc2.sh b/tests/test-mbrtowc2.sh deleted file mode 100755 index 6868e86371..0000000000 --- a/tests/test-mbrtowc2.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Test whether a specific UTF-8 locale is installed. -: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" -if test $LOCALE_FR_UTF8 = none; then - if test -f /usr/bin/localedef; then - echo "Skipping test: no french Unicode locale is installed" - else - echo "Skipping test: no french Unicode locale is supported" - fi - exit 77 -fi - -LC_ALL=$LOCALE_FR_UTF8 \ -${CHECKER} ./test-mbrtowc${EXEEXT} 2 diff --git a/tests/test-mbrtowc3.sh b/tests/test-mbrtowc3.sh deleted file mode 100755 index eca8d648d3..0000000000 --- a/tests/test-mbrtowc3.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Test whether a specific EUC-JP locale is installed. -: "${LOCALE_JA=ja_JP}" -if test $LOCALE_JA = none; then - if test -f /usr/bin/localedef; then - echo "Skipping test: no traditional japanese locale is installed" - else - echo "Skipping test: no traditional japanese locale is supported" - fi - exit 77 -fi - -LC_ALL=$LOCALE_JA \ -${CHECKER} ./test-mbrtowc${EXEEXT} 3 diff --git a/tests/test-mbrtowc4.sh b/tests/test-mbrtowc4.sh deleted file mode 100755 index 7da23a3cab..0000000000 --- a/tests/test-mbrtowc4.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Test whether a specific GB18030 locale is installed. -: "${LOCALE_ZH_CN=zh_CN.GB18030}" -if test $LOCALE_ZH_CN = none; then - if test -f /usr/bin/localedef; then - echo "Skipping test: no transitional chinese locale is installed" - else - echo "Skipping test: no transitional chinese locale is supported" - fi - exit 77 -fi - -LC_ALL=$LOCALE_ZH_CN \ -${CHECKER} ./test-mbrtowc${EXEEXT} 4 diff --git a/tests/test-mbrtowc5.sh b/tests/test-mbrtowc5.sh deleted file mode 100755 index 4c6c6fe868..0000000000 --- a/tests/test-mbrtowc5.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -# Test whether the POSIX locale has encoding errors. -LC_ALL=C \ -${CHECKER} ./test-mbrtowc${EXEEXT} 5 || exit 1 -LC_ALL=POSIX \ -${CHECKER} ./test-mbrtowc${EXEEXT} 5 || exit 1 - -exit 0