diff options
author | Bruno Haible <bruno@clisp.org> | 2023-04-24 12:48:31 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-04-24 12:48:31 +0200 |
commit | b9a770fc36076e4b2d641d9d61e804cb13826f78 (patch) | |
tree | a6a97d3624d4ea4c62bd9045cc4004a9e647cf1b | |
parent | ebdce3b64e3ff04daafb742fde8823de4b6ce80f (diff) | |
download | gnulib-b9a770fc36076e4b2d641d9d61e804cb13826f78.tar.gz |
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.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | modules/unicodeio-tests | 1 | ||||
-rw-r--r-- | tests/test-unicodeio.c | 23 |
3 files changed, 30 insertions, 1 deletions
@@ -1,5 +1,12 @@ 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-24 Bruno Haible <bruno@clisp.org> + *sprintf tests: Avoid test failures on mingw 10. * tests/test-vasnprintf-posix.c (test_function): On newer mingw, expect the de-facto standard result. diff --git a/modules/unicodeio-tests b/modules/unicodeio-tests index 05fcdeb0ba..740552abaf 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 1b7010c1ae..3a4af1345e 100644 --- a/tests/test-unicodeio.c +++ b/tests/test-unicodeio.c @@ -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; |