summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2018-02-24 12:01:30 +0100
committerBruno Haible <bruno@clisp.org>2018-02-24 12:01:30 +0100
commitd9ff660d1908a02733946f7f19a96ebd2feff3b9 (patch)
tree7b6d6a8ba7dfcdb5a12cabed86cd351a1965c1ef
parent262981295f31caebf08b2bfc30bf40239e117d7d (diff)
downloadgnulib-d9ff660d1908a02733946f7f19a96ebd2feff3b9.tar.gz
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.
-rw-r--r--ChangeLog6
-rw-r--r--tests/test-mbrtowc.c10
2 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 66996fa90a..0c1ebc057e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
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.
* tests/test-ptsname_r.c (test_errors): Don't test errno after return
from ptsname_r().
diff --git a/tests/test-mbrtowc.c b/tests/test-mbrtowc.c
index a0b5231a3f..54d52f8070 100644
--- a/tests/test-mbrtowc.c
+++ b/tests/test-mbrtowc.c
@@ -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);