]> Savannah Git Hosting - gnulib.git/commitdiff
unicodeio tests: Avoid test failures on native Windows.
authorBruno Haible <bruno@clisp.org>
Mon, 24 Apr 2023 10:48:31 +0000 (12:48 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 27 Apr 2023 16:18:22 +0000 (18:18 +0200)
* tests/test-unicodeio.c: Include localcharset.h.
(main): Handle C locales whose encoding is CP1252 or similar.
* modules/unicodeio-tests (Depends-on): Add localcharset.

ChangeLog
modules/unicodeio-tests
tests/test-unicodeio.c

index 173a3602d7cda47cfae83c910c95b1c36e95e06b..ffca8174c4ada5a56a609e1431f1f35ec018f973 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-04-24  Bruno Haible  <bruno@clisp.org>
+
+       unicodeio tests: Avoid test failures on native Windows.
+       * tests/test-unicodeio.c: Include localcharset.h.
+       (main): Handle C locales whose encoding is CP1252 or similar.
+       * modules/unicodeio-tests (Depends-on): Add localcharset.
+
 2023-04-23  Bruno Haible  <bruno@clisp.org>
 
        category-none: Fix link errors on MSVC, when libunistring is installed.
index c53f26f2b53e761621512eede8da5646eb1c9ed6..527dfa458fff0fb6a20396d723255bbf1792860e 100644 (file)
@@ -10,6 +10,7 @@ m4/codeset.m4
 
 Depends-on:
 setlocale
+localcharset
 
 configure.ac:
 gt_LOCALE_FR_UTF8
index 1b7010c1ae5f74a64f72dbc3f4b3404dfe81ef5f..3a4af1345e8942edcfadd579f876289fbc9f71d6 100644 (file)
@@ -25,6 +25,7 @@
 #include <locale.h>
 #include <string.h>
 
+#include "localcharset.h"
 #include "macros.h"
 
 #define TEST_CODE 0x2022
@@ -62,7 +63,27 @@ main (int argc, char *argv[])
       if (argc > 1)
         switch (argv[1][0])
           {
-          case '1': /* On some platforms, the "C" locale has UTF-8 encoding.  */
+          case '1':
+            /* On some platforms, the "C" locale has UTF-8 encoding.
+               And on native Windows, the "C" locale may have an 8-bit encoding
+               such as CP1252, that contains the U+2022 character.  */
+            {
+              const char *charset = locale_charset ();
+              if (strcmp (charset, "CP874") == 0
+                  || strcmp (charset, "CP1250") == 0
+                  || strcmp (charset, "CP1251") == 0
+                  || strcmp (charset, "CP1252") == 0
+                  || strcmp (charset, "CP1253") == 0
+                  || strcmp (charset, "CP1254") == 0
+                  || strcmp (charset, "CP1255") == 0
+                  || strcmp (charset, "CP1256") == 0
+                  || strcmp (charset, "CP1257") == 0
+                  || strcmp (charset, "CP1258") == 0)
+                ASSERT (strcmp (result, "\x95") == 0);
+              else
+                ASSERT (strcmp (result, TEST_CODE_AS_UTF8) == 0);
+            }
+            break;
           case '2':
             ASSERT (strcmp (result, TEST_CODE_AS_UTF8) == 0);
             break;