]> Savannah Git Hosting - gnulib.git/commitdiff
mbfile tests: Avoid test failure on mingw.
authorBruno Haible <bruno@clisp.org>
Wed, 29 May 2024 12:13:33 +0000 (14:13 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 31 May 2024 16:10:31 +0000 (18:10 +0200)
* tests/test-mbfile.c: Include <string.h>, localcharset.h.
(main): Verify that setlocale() has installed an UTF-8 locale.
* modules/mbfile-tests (Depends-on): Add localcharset.

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

index 0ff9d8d3ee827873d5038952bd63963e70b98d3b..a0a269f490251df3565d55eb4aa7036013cf1f41 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-05-29  Bruno Haible  <bruno@clisp.org>
+
+       mbfile tests: Avoid test failure on mingw.
+       * tests/test-mbfile.c: Include <string.h>, localcharset.h.
+       (main): Verify that setlocale() has installed an UTF-8 locale.
+       * modules/mbfile-tests (Depends-on): Add localcharset.
+
 2024-05-29  Bruno Haible  <bruno@clisp.org>
 
        pthread-once tests: Fix crash on mingw.
index 246702fc042efeaba94285d013ebac2e617ba9f4..d52b9d4975867f081727b49885d456612e85c330 100644 (file)
@@ -4,6 +4,7 @@ tests/test-mbfile.c
 tests/macros.h
 
 Depends-on:
+localcharset
 setlocale
 
 configure.ac:
index 22e6a89ca13ac5c7d122fa0a25c1fbb79750c2ac..7f1e1942358ed0e18ffa462950a365af32b567f2 100644 (file)
 #include "mbfile.h"
 
 #include <locale.h>
+#include <string.h>
 
+#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;