From b7cf2e8923560f238e5ec6327b093ecefb7b2f73 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 29 Jul 2023 22:02:54 +0200 Subject: [PATCH] c32rtomb tests: Renumber tests. * tests/test-c32rtomb.sh: Renamed 1 -> 2 -> 3 -> 4 -> 5 -> 1. * tests/test-c32rtomb.c: Update. * tests/test-c32rtomb-w32-*.sh: Renamed 1 -> 2 -> 3 -> 5 -> 7 -> 4 -> 6 -> 8. * tests/test-c32rtomb-w32.c: Update. * modules/c32rtomb-tests: Update. --- ChangeLog | 8 ++++++ modules/c32rtomb-tests | 8 +++--- tests/test-c32rtomb-w32-1.sh | 4 --- tests/test-c32rtomb-w32-2.sh | 4 +-- tests/test-c32rtomb-w32-3.sh | 4 +-- tests/test-c32rtomb-w32-4.sh | 4 +-- tests/test-c32rtomb-w32-5.sh | 4 +-- tests/test-c32rtomb-w32-6.sh | 4 +-- tests/test-c32rtomb-w32-7.sh | 4 +-- tests/test-c32rtomb-w32-8.sh | 4 +++ tests/test-c32rtomb-w32.c | 52 ++++++++++++++++++------------------ tests/test-c32rtomb.c | 14 +++++----- tests/test-c32rtomb.sh | 16 +++++------ 13 files changed, 69 insertions(+), 61 deletions(-) delete mode 100755 tests/test-c32rtomb-w32-1.sh create mode 100755 tests/test-c32rtomb-w32-8.sh diff --git a/ChangeLog b/ChangeLog index 55188989db..44c83c2bdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2023-07-29 Bruno Haible + c32rtomb tests: Renumber tests. + * tests/test-c32rtomb.sh: Renamed 1 -> 2 -> 3 -> 4 -> 5 -> 1. + * tests/test-c32rtomb.c: Update. + * tests/test-c32rtomb-w32-*.sh: Renamed 1 -> 2 -> 3 -> 5 -> 7 -> 4 -> 6 + -> 8. + * tests/test-c32rtomb-w32.c: Update. + * modules/c32rtomb-tests: Update. + btoc32 tests: Renumber tests. * tests/test-btoc32-*.sh: Renamed 1 -> 2 -> 3 -> 1. * tests/test-btoc32.c: Update. diff --git a/modules/c32rtomb-tests b/modules/c32rtomb-tests index 9a1e0dcede..4051a212c9 100644 --- a/modules/c32rtomb-tests +++ b/modules/c32rtomb-tests @@ -1,13 +1,13 @@ Files: tests/test-c32rtomb.sh tests/test-c32rtomb.c -tests/test-c32rtomb-w32-1.sh tests/test-c32rtomb-w32-2.sh tests/test-c32rtomb-w32-3.sh tests/test-c32rtomb-w32-4.sh tests/test-c32rtomb-w32-5.sh tests/test-c32rtomb-w32-6.sh tests/test-c32rtomb-w32-7.sh +tests/test-c32rtomb-w32-8.sh tests/test-c32rtomb-w32.c tests/signature.h tests/macros.h @@ -31,9 +31,9 @@ gt_LOCALE_ZH_CN Makefile.am: TESTS += \ test-c32rtomb.sh \ - test-c32rtomb-w32-1.sh test-c32rtomb-w32-2.sh test-c32rtomb-w32-3.sh \ - test-c32rtomb-w32-4.sh test-c32rtomb-w32-5.sh test-c32rtomb-w32-6.sh \ - test-c32rtomb-w32-7.sh + test-c32rtomb-w32-2.sh test-c32rtomb-w32-3.sh test-c32rtomb-w32-4.sh \ + test-c32rtomb-w32-5.sh test-c32rtomb-w32-6.sh test-c32rtomb-w32-7.sh \ + test-c32rtomb-w32-8.sh TESTS_ENVIRONMENT += \ LOCALE_FR='@LOCALE_FR@' \ LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ diff --git a/tests/test-c32rtomb-w32-1.sh b/tests/test-c32rtomb-w32-1.sh deleted file mode 100755 index e797d0e5eb..0000000000 --- a/tests/test-c32rtomb-w32-1.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# Test a CP1252 locale. -${CHECKER} ./test-c32rtomb-w32${EXEEXT} French_France 1252 diff --git a/tests/test-c32rtomb-w32-2.sh b/tests/test-c32rtomb-w32-2.sh index 1b63d472aa..e797d0e5eb 100755 --- a/tests/test-c32rtomb-w32-2.sh +++ b/tests/test-c32rtomb-w32-2.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test a CP1256 locale. -${CHECKER} ./test-c32rtomb-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 +# Test a CP1252 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} French_France 1252 diff --git a/tests/test-c32rtomb-w32-3.sh b/tests/test-c32rtomb-w32-3.sh index ff59a8727e..1b63d472aa 100755 --- a/tests/test-c32rtomb-w32-3.sh +++ b/tests/test-c32rtomb-w32-3.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test a CP932 locale. -${CHECKER} ./test-c32rtomb-w32${EXEEXT} Japanese_Japan 932 +# Test a CP1256 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 diff --git a/tests/test-c32rtomb-w32-4.sh b/tests/test-c32rtomb-w32-4.sh index 3cf3406552..3c0f3db48f 100755 --- a/tests/test-c32rtomb-w32-4.sh +++ b/tests/test-c32rtomb-w32-4.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test a CP950 locale. -${CHECKER} ./test-c32rtomb-w32${EXEEXT} Chinese_Taiwan 950 +# Test some UTF-8 locales. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 diff --git a/tests/test-c32rtomb-w32-5.sh b/tests/test-c32rtomb-w32-5.sh index 2174c0b572..ff59a8727e 100755 --- a/tests/test-c32rtomb-w32-5.sh +++ b/tests/test-c32rtomb-w32-5.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test a CP936 locale. -${CHECKER} ./test-c32rtomb-w32${EXEEXT} Chinese_China 936 +# Test a CP932 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} Japanese_Japan 932 diff --git a/tests/test-c32rtomb-w32-6.sh b/tests/test-c32rtomb-w32-6.sh index b7e77b28d1..3cf3406552 100755 --- a/tests/test-c32rtomb-w32-6.sh +++ b/tests/test-c32rtomb-w32-6.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test a GB18030 locale. -${CHECKER} ./test-c32rtomb-w32${EXEEXT} Chinese_China 54936 +# Test a CP950 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} Chinese_Taiwan 950 diff --git a/tests/test-c32rtomb-w32-7.sh b/tests/test-c32rtomb-w32-7.sh index 3c0f3db48f..2174c0b572 100755 --- a/tests/test-c32rtomb-w32-7.sh +++ b/tests/test-c32rtomb-w32-7.sh @@ -1,4 +1,4 @@ #!/bin/sh -# Test some UTF-8 locales. -${CHECKER} ./test-c32rtomb-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 +# Test a CP936 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} Chinese_China 936 diff --git a/tests/test-c32rtomb-w32-8.sh b/tests/test-c32rtomb-w32-8.sh new file mode 100755 index 0000000000..b7e77b28d1 --- /dev/null +++ b/tests/test-c32rtomb-w32-8.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a GB18030 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} Chinese_China 54936 diff --git a/tests/test-c32rtomb-w32.c b/tests/test-c32rtomb-w32.c index 06cfa1e44f..dbf1440e63 100644 --- a/tests/test-c32rtomb-w32.c +++ b/tests/test-c32rtomb-w32.c @@ -184,6 +184,32 @@ 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; + { + /* Convert "s\303\274\303\237\360\237\230\213!"; "süß😋!" */ + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x00FC, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\303\274", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x00DF, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\303\237", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x1F60B, NULL); + ASSERT (ret == 4); + ASSERT (memcmp (buf, "\360\237\230\213", 4) == 0); + ASSERT (buf[4] == 'x'); + } + return 0; + case 932: /* Locale encoding is CP932, similar to Shift_JIS. */ { @@ -282,32 +308,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; - { - /* Convert "s\303\274\303\237\360\237\230\213!"; "süß😋!" */ - memset (buf, 'x', 8); - ret = c32rtomb (buf, 0x00FC, NULL); - ASSERT (ret == 2); - ASSERT (memcmp (buf, "\303\274", 2) == 0); - ASSERT (buf[2] == 'x'); - - memset (buf, 'x', 8); - ret = c32rtomb (buf, 0x00DF, NULL); - ASSERT (ret == 2); - ASSERT (memcmp (buf, "\303\237", 2) == 0); - ASSERT (buf[2] == 'x'); - - memset (buf, 'x', 8); - ret = c32rtomb (buf, 0x1F60B, NULL); - ASSERT (ret == 4); - ASSERT (memcmp (buf, "\360\237\230\213", 4) == 0); - ASSERT (buf[4] == 'x'); - } - return 0; - default: return 1; } diff --git a/tests/test-c32rtomb.c b/tests/test-c32rtomb.c index 8969873181..4c39fd54a6 100644 --- a/tests/test-c32rtomb.c +++ b/tests/test-c32rtomb.c @@ -119,6 +119,10 @@ main (int argc, char *argv[]) switch (argv[1][0]) { case '1': + /* C locale; tested above. */ + return 0; + + case '2': /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ { const char input[] = "B\374\337er"; /* "Büßer" */ @@ -128,7 +132,7 @@ main (int argc, char *argv[]) } return 0; - case '2': + case '3': /* Locale encoding is UTF-8. */ { const char input[] = "s\303\274\303\237\360\237\230\213!"; /* "süß😋!" */ @@ -139,7 +143,7 @@ main (int argc, char *argv[]) } return 0; - case '3': + case '4': /* Locale encoding is EUC-JP. */ { const char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ @@ -150,7 +154,7 @@ main (int argc, char *argv[]) } return 0; - case '4': + case '5': /* Locale encoding is GB18030. */ #if GL_CHAR32_T_IS_UNICODE && (defined __NetBSD__ || defined __sun) fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); @@ -164,10 +168,6 @@ main (int argc, char *argv[]) check_character (input + 7, 4); } return 0; - - case '5': - /* C locale; tested above. */ - return 0; } return 1; diff --git a/tests/test-c32rtomb.sh b/tests/test-c32rtomb.sh index 3239935332..e5236c976a 100755 --- a/tests/test-c32rtomb.sh +++ b/tests/test-c32rtomb.sh @@ -1,10 +1,14 @@ #!/bin/sh +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32rtomb${EXEEXT} 1 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32rtomb${EXEEXT} 1 || exit 1 + # Test in an ISO-8859-1 or ISO-8859-15 locale. : "${LOCALE_FR=fr_FR}" if test $LOCALE_FR != none; then LC_ALL=$LOCALE_FR \ - ${CHECKER} ./test-c32rtomb${EXEEXT} 1 \ + ${CHECKER} ./test-c32rtomb${EXEEXT} 2 \ || exit 1 fi @@ -12,7 +16,7 @@ fi : "${LOCALE_FR_UTF8=fr_FR.UTF-8}" if test $LOCALE_FR_UTF8 != none; then LC_ALL=$LOCALE_FR_UTF8 \ - ${CHECKER} ./test-c32rtomb${EXEEXT} 2 \ + ${CHECKER} ./test-c32rtomb${EXEEXT} 3 \ || exit 1 fi @@ -20,7 +24,7 @@ fi : "${LOCALE_JA=ja_JP}" if test $LOCALE_JA != none; then LC_ALL=$LOCALE_JA \ - ${CHECKER} ./test-c32rtomb${EXEEXT} 3 \ + ${CHECKER} ./test-c32rtomb${EXEEXT} 4 \ || exit 1 fi @@ -28,15 +32,11 @@ fi : "${LOCALE_ZH_CN=zh_CN.GB18030}" if test $LOCALE_ZH_CN != none; then LC_ALL=$LOCALE_ZH_CN \ - ${CHECKER} ./test-c32rtomb${EXEEXT} 4 + ${CHECKER} ./test-c32rtomb${EXEEXT} 5 case $? in 0 | 77) ;; *) exit 1 ;; esac fi -# Test in the POSIX locale. -LC_ALL=C ${CHECKER} ./test-c32rtomb${EXEEXT} 5 || exit 1 -LC_ALL=POSIX ${CHECKER} ./test-c32rtomb${EXEEXT} 5 || exit 1 - exit 0 -- 2.39.5