From 4d78489634016022a30db55fb72fd046fd28b866 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 29 May 2024 14:13:33 +0200 Subject: [PATCH] mbfile tests: Avoid test failure on mingw. * tests/test-mbfile.c: Include , localcharset.h. (main): Verify that setlocale() has installed an UTF-8 locale. * modules/mbfile-tests (Depends-on): Add localcharset. --- ChangeLog | 7 +++++++ modules/mbfile-tests | 1 + tests/test-mbfile.c | 9 ++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0ff9d8d3ee..a0a269f490 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-05-29 Bruno Haible + + mbfile tests: Avoid test failure on mingw. + * tests/test-mbfile.c: Include , localcharset.h. + (main): Verify that setlocale() has installed an UTF-8 locale. + * modules/mbfile-tests (Depends-on): Add localcharset. + 2024-05-29 Bruno Haible pthread-once tests: Fix crash on mingw. diff --git a/modules/mbfile-tests b/modules/mbfile-tests index 246702fc04..d52b9d4975 100644 --- a/modules/mbfile-tests +++ b/modules/mbfile-tests @@ -4,6 +4,7 @@ tests/test-mbfile.c tests/macros.h Depends-on: +localcharset setlocale configure.ac: diff --git a/tests/test-mbfile.c b/tests/test-mbfile.c index 22e6a89ca1..7f1e194235 100644 --- a/tests/test-mbfile.c +++ b/tests/test-mbfile.c @@ -21,13 +21,20 @@ #include "mbfile.h" #include +#include +#include "localcharset.h" #include "macros.h" int main () { - if (setlocale (LC_ALL, "en_US.UTF-8") == NULL) + /* Switch to an UTF-8 locale. */ + if (!(setlocale (LC_ALL, "en_US.UTF-8") != NULL + /* Check whether it's really an UTF-8 locale. + On native Windows, this setlocale call succeeds but the encoding + of this locale is CP1252, not UTF-8. */ + && strcmp (locale_charset (), "UTF-8") == 0)) { fprintf (stderr, "Skipping test: English Unicode locale is not installed\n"); return 77; -- 2.39.5