From 74cdf7d6063d1d8586f8673075d93516ce0ac0ac Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 3 Jan 2020 01:26:10 +0100 Subject: [PATCH 2/2] wcrtomb: Add more tests. * tests/test-wcrtomb-w32.c: Include localcharset.h. (test_one_locale): For the GB18030 and UTF-8 tests, verify that locale_charset() returns the expected value; otherwise, skip the test. * tests/test-wcrtomb-w32-6.sh: Remove old comment. * tests/test-wcrtomb-w32-7.sh: Likewise. * modules/wcrtomb-tests (Files): Add these files. (Depends-on): Add localcharset. (TESTS): Add test-wcrtomb-w32-6.sh, test-wcrtomb-w32-7.sh. --- ChangeLog | 12 ++++++++++++ modules/wcrtomb-tests | 6 +++++- tests/test-wcrtomb-w32-6.sh | 3 --- tests/test-wcrtomb-w32-7.sh | 3 --- tests/test-wcrtomb-w32.c | 5 +++++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1eb4419..045aae3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2020-01-02 Bruno Haible + wcrtomb: Add more tests. + * tests/test-wcrtomb-w32.c: Include localcharset.h. + (test_one_locale): For the GB18030 and UTF-8 tests, verify that + locale_charset() returns the expected value; otherwise, skip the test. + * tests/test-wcrtomb-w32-6.sh: Remove old comment. + * tests/test-wcrtomb-w32-7.sh: Likewise. + * modules/wcrtomb-tests (Files): Add these files. + (Depends-on): Add localcharset. + (TESTS): Add test-wcrtomb-w32-6.sh, test-wcrtomb-w32-7.sh. + +2020-01-02 Bruno Haible + mbrtowc: Add more tests. * tests/test-mbrtowc-w32.c: Include localcharset.h. (test_one_locale): For the GB18030 and UTF-8 tests, verify that diff --git a/modules/wcrtomb-tests b/modules/wcrtomb-tests index 43c28e8..18ff62c 100644 --- a/modules/wcrtomb-tests +++ b/modules/wcrtomb-tests @@ -6,6 +6,8 @@ tests/test-wcrtomb-w32-2.sh tests/test-wcrtomb-w32-3.sh tests/test-wcrtomb-w32-4.sh tests/test-wcrtomb-w32-5.sh +tests/test-wcrtomb-w32-6.sh +tests/test-wcrtomb-w32-7.sh tests/test-wcrtomb-w32.c tests/signature.h tests/macros.h @@ -17,6 +19,7 @@ m4/codeset.m4 Depends-on: btowc setlocale +localcharset configure.ac: gt_LOCALE_FR @@ -28,7 +31,8 @@ Makefile.am: TESTS += \ test-wcrtomb.sh \ test-wcrtomb-w32-1.sh test-wcrtomb-w32-2.sh test-wcrtomb-w32-3.sh \ - test-wcrtomb-w32-4.sh test-wcrtomb-w32-5.sh + test-wcrtomb-w32-4.sh test-wcrtomb-w32-5.sh test-wcrtomb-w32-6.sh \ + test-wcrtomb-w32-7.sh TESTS_ENVIRONMENT += \ LOCALE_FR='@LOCALE_FR@' \ LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ diff --git a/tests/test-wcrtomb-w32-6.sh b/tests/test-wcrtomb-w32-6.sh index 99f9971..802237d 100755 --- a/tests/test-wcrtomb-w32-6.sh +++ b/tests/test-wcrtomb-w32-6.sh @@ -1,7 +1,4 @@ #!/bin/sh -# This test is not enabled by default, because MSVCRT does not support and -# will likely never support locales with MB_CUR_MAX > 2. - # Test a GB18030 locale. ${CHECKER} ./test-wcrtomb-w32${EXEEXT} Chinese_China 54936 diff --git a/tests/test-wcrtomb-w32-7.sh b/tests/test-wcrtomb-w32-7.sh index d8b5291..fb04e58 100755 --- a/tests/test-wcrtomb-w32-7.sh +++ b/tests/test-wcrtomb-w32-7.sh @@ -1,7 +1,4 @@ #!/bin/sh -# This test is not enabled by default, because MSVCRT does not support and -# will likely never support locales with MB_CUR_MAX > 2. - # Test some UTF-8 locales. ${CHECKER} ./test-wcrtomb-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 diff --git a/tests/test-wcrtomb-w32.c b/tests/test-wcrtomb-w32.c index 3bbba72..0f02ed2 100644 --- a/tests/test-wcrtomb-w32.c +++ b/tests/test-wcrtomb-w32.c @@ -23,6 +23,7 @@ #include #include +#include "localcharset.h" #include "macros.h" #if defined _WIN32 && !defined __CYGWIN__ @@ -257,6 +258,8 @@ test_one_locale (const char *name, int codepage) case 54936: /* Locale encoding is CP54936 = GB18030. */ + if (strcmp (locale_charset (), "GB18030") != 0) + return 77; { /* Convert "B\250\271\201\060\211\070er": "Büßer" */ memset (buf, 'x', 8); @@ -275,6 +278,8 @@ test_one_locale (const char *name, int codepage) case 65001: /* Locale encoding is CP65001 = UTF-8. */ + if (strcmp (locale_charset (), "UTF-8") != 0) + return 77; { /* Convert "B\303\274\303\237er": "Büßer" */ memset (buf, 'x', 8); -- 2.7.4