These two patches activate tests for locales with UTF-8 and GB18030
encodings on native Windows. The native setlocale() does not support
such locales. But the gnulib overridden setlocale() does, in some cases
(namely, with MSVC, the locales with UTF-8 encoding appear to work).


2020-01-02  Bruno Haible  <br...@clisp.org>

        mbrtowc: Add more tests.
        * tests/test-mbrtowc-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-mbrtowc-w32-6.sh: Remove old comment.
        * tests/test-mbrtowc-w32-7.sh: Likewise.
        * modules/mbrtowc-tests (Files): Add these files.
        (Depends-on): Add localcharset.
        (TESTS): Add test-mbrtowc-w32-6.sh, test-mbrtowc-w32-7.sh.

2020-01-02  Bruno Haible  <br...@clisp.org>

        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.

From 5f5389b7b8d5037d77b37859a0c7821e61e90d4d Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 3 Jan 2020 01:23:24 +0100
Subject: [PATCH 1/2] mbrtowc: Add more tests.

* tests/test-mbrtowc-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-mbrtowc-w32-6.sh: Remove old comment.
* tests/test-mbrtowc-w32-7.sh: Likewise.
* modules/mbrtowc-tests (Files): Add these files.
(Depends-on): Add localcharset.
(TESTS): Add test-mbrtowc-w32-6.sh, test-mbrtowc-w32-7.sh.
---
 ChangeLog                   | 12 ++++++++++++
 modules/mbrtowc-tests       |  6 +++++-
 tests/test-mbrtowc-w32-6.sh |  3 ---
 tests/test-mbrtowc-w32-7.sh |  3 ---
 tests/test-mbrtowc-w32.c    |  5 +++++
 5 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6c71b81..1eb4419 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2020-01-02  Bruno Haible  <br...@clisp.org>
 
+	mbrtowc: Add more tests.
+	* tests/test-mbrtowc-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-mbrtowc-w32-6.sh: Remove old comment.
+	* tests/test-mbrtowc-w32-7.sh: Likewise.
+	* modules/mbrtowc-tests (Files): Add these files.
+	(Depends-on): Add localcharset.
+	(TESTS): Add test-mbrtowc-w32-6.sh, test-mbrtowc-w32-7.sh.
+
+2020-01-02  Bruno Haible  <br...@clisp.org>
+
 	mbrtowc: Fix test failures on MSVC (regression by previous commit).
 	* m4/mbrtowc.m4 (gl_MBRTOWC_STORES_INCOMPLETE): New macro.
 	(gl_FUNC_MBRTOWC): Invoke it. Define MBRTOWC_STORES_INCOMPLETE_BUG.
diff --git a/modules/mbrtowc-tests b/modules/mbrtowc-tests
index 86008d8..f5c9166 100644
--- a/modules/mbrtowc-tests
+++ b/modules/mbrtowc-tests
@@ -10,6 +10,8 @@ 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.c
 tests/signature.h
 tests/macros.h
@@ -22,6 +24,7 @@ Depends-on:
 mbsinit
 wctob
 setlocale
+localcharset
 
 configure.ac:
 gt_LOCALE_FR
@@ -34,7 +37,8 @@ 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-4.sh test-mbrtowc-w32-5.sh test-mbrtowc-w32-6.sh \
+  test-mbrtowc-w32-7.sh
 TESTS_ENVIRONMENT += \
   LOCALE_FR='@LOCALE_FR@' \
   LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
diff --git a/tests/test-mbrtowc-w32-6.sh b/tests/test-mbrtowc-w32-6.sh
index e608233..c2e8dfe 100755
--- a/tests/test-mbrtowc-w32-6.sh
+++ b/tests/test-mbrtowc-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-mbrtowc-w32${EXEEXT} Chinese_China 54936
diff --git a/tests/test-mbrtowc-w32-7.sh b/tests/test-mbrtowc-w32-7.sh
index 0a3eb8f..2c5d555 100755
--- a/tests/test-mbrtowc-w32-7.sh
+++ b/tests/test-mbrtowc-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-mbrtowc-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001
diff --git a/tests/test-mbrtowc-w32.c b/tests/test-mbrtowc-w32.c
index efeee15..17908ed 100644
--- a/tests/test-mbrtowc-w32.c
+++ b/tests/test-mbrtowc-w32.c
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "localcharset.h"
 #include "macros.h"
 
 #if defined _WIN32 && !defined __CYGWIN__
@@ -476,6 +477,8 @@ test_one_locale (const char *name, int codepage)
 
     case 54936:
       /* Locale encoding is CP54936 = GB18030.  */
+      if (strcmp (locale_charset (), "GB18030") != 0)
+        return 77;
       {
         char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
         memset (&state, '\0', sizeof (mbstate_t));
@@ -572,6 +575,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;
       {
         char input[] = "B\303\274\303\237er"; /* "Büßer" */
         memset (&state, '\0', sizeof (mbstate_t));
-- 
2.7.4

From 74cdf7d6063d1d8586f8673075d93516ce0ac0ac Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
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  <br...@clisp.org>
 
+	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  <br...@clisp.org>
+
 	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 <stdlib.h>
 #include <string.h>
 
+#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

Reply via email to