From: Bruno Haible Date: Mon, 24 Apr 2023 10:48:31 +0000 (+0200) Subject: unicodeio tests: Avoid test failures on native Windows. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=500ea0462fd7ab07cd28018c4d41108d6eb86a40;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index a993824a17..700dcd21a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-04-24 Bruno Haible + + 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 category-none: Fix link errors on MSVC, when libunistring is installed. diff --git a/modules/unicodeio-tests b/modules/unicodeio-tests index c53f26f2b5..527dfa458f 100644 --- a/modules/unicodeio-tests +++ b/modules/unicodeio-tests @@ -10,6 +10,7 @@ m4/codeset.m4 Depends-on: setlocale +localcharset configure.ac: gt_LOCALE_FR_UTF8 diff --git a/tests/test-unicodeio.c b/tests/test-unicodeio.c index aeff3a097e..3a4af1345e 100644 --- a/tests/test-unicodeio.c +++ b/tests/test-unicodeio.c @@ -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 #include +#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;