]> 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:32:50 +0000 (18:32 +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 a993824a178aa0d7d6cb0470f04e2a3e74b48154..700dcd21a2deb29382bcd75d4436044272c68783 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 aeff3a097eb4495cea1ecc36dd9308e84970c816..3a4af1345e8942edcfadd579f876289fbc9f71d6 100644 (file)
@@ -1,6 +1,6 @@
 /* Tests for Unicode character output.
 
-   Copyright (C) 2020-2022 Free Software Foundation, Inc.
+   Copyright (C) 2020-2023 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -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;