summaryrefslogtreecommitdiff
path: root/tests/test-btowc.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-03-03 19:11:32 +0100
committerJörg Frings-Fürst <debian@jff.email>2024-03-03 19:11:32 +0100
commit00893e79fc62966067af1a106567db96bd170338 (patch)
tree52b35cd0b42ca28e62a2ffbecade2e13dd8332cf /tests/test-btowc.c
parent26112352a774737e1ce5580c93654a26c1e82b39 (diff)
New upstream version 1.2upstream/1.2
Diffstat (limited to 'tests/test-btowc.c')
-rw-r--r--tests/test-btowc.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/test-btowc.c b/tests/test-btowc.c
index 32806f07..aeac4bbf 100644
--- a/tests/test-btowc.c
+++ b/tests/test-btowc.c
@@ -1,5 +1,5 @@
/* Test of conversion of unibyte character to wide character.
- Copyright (C) 2008-2022 Free Software Foundation, Inc.
+ Copyright (C) 2008-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -39,10 +39,38 @@ main (int argc, char *argv[])
ASSERT (btowc (EOF) == WEOF);
+#ifdef __ANDROID__
+ /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the
+ "C" locale. Furthermore, when you attempt to set the "C" or "POSIX"
+ locale via setlocale(), what you get is a "C" locale with UTF-8 encoding,
+ that is, effectively the "C.UTF-8" locale. */
+ if (argc > 1 && strcmp (argv[1], "1") == 0 && MB_CUR_MAX > 1)
+ argv[1] = "3";
+#endif
+
if (argc > 1)
switch (argv[1][0])
{
case '1':
+ /* C or POSIX locale. */
+ for (c = 0; c < 0x100; c++)
+ if (c != 0)
+ {
+ /* We are testing all nonnull bytes. */
+ wint_t wc = btowc (c);
+ /* POSIX:2018 says: "In the POSIX locale, btowc() shall not return
+ WEOF if c has a value in the range 0 to 255 inclusive." */
+ if (c < 0x80)
+ /* c is an ASCII character. */
+ ASSERT (wc == c);
+ else
+ /* 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 == c || wc == 0xDF00 + c);
+ }
+ return 0;
+
+ case '2':
/* Locale encoding is ISO-8859-1 or ISO-8859-15. */
for (c = 0; c < 0x80; c++)
ASSERT (btowc (c) == c);
@@ -50,7 +78,7 @@ main (int argc, char *argv[])
ASSERT (btowc (c) != WEOF);
return 0;
- case '2':
+ case '3':
/* Locale encoding is UTF-8. */
for (c = 0; c < 0x80; c++)
ASSERT (btowc (c) == c);