]> Savannah Git Hosting - gnulib.git/commitdiff
mbrtowc tests: Don't make assumptions about the charset the C locale.
authorBruno Haible <bruno@clisp.org>
Sat, 24 Feb 2018 11:01:30 +0000 (12:01 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 24 Feb 2018 11:01:30 +0000 (12:01 +0100)
* tests/test-mbrtowc.c (main): For bytes >= 0x80, don't assume a
particular mapping in the C locale.

ChangeLog
tests/test-mbrtowc.c

index 66996fa90ab50ba14900e83e88daa33dae86c15d..0c1ebc057e6d4c0e1c5384975366b387a6e85ca5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-24  Bruno Haible  <bruno@clisp.org>
+
+       mbrtowc tests: Don't make assumptions about the charset the C locale.
+       * tests/test-mbrtowc.c (main): For bytes >= 0x80, don't assume a
+       particular mapping in the C locale.
+
 2018-02-24  Bruno Haible  <bruno@clisp.org>
 
        ptsname_r: Don't expect that this function sets errno.
index a0b5231a3f58d055944cd4ee57d332cffd355431..54d52f8070e6a4f1f64e39376124b6e7b7ebb8f2 100644 (file)
@@ -103,7 +103,15 @@ main (int argc, char *argv[])
           wc = (wchar_t) 0xBADFACE;
           ret = mbrtowc (&wc, buf, 1, &state);
           ASSERT (ret == 1);
-          ASSERT (wc == c);
+          if (c < 0x80)
+            /* c is an ASCII character.  */
+            ASSERT (wc == c);
+          else
+            /* argv[1] starts with '5', that is, we are testing the C or POSIX
+               locale.
+               On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF.
+               But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF.  */
+            ASSERT (wc == btowc (c));
           ASSERT (mbsinit (&state));
           ret = mbrtowc (NULL, buf, 1, &state);
           ASSERT (ret == 1);