summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2023-03-31 04:44:56 +0200
committerBruno Haible <bruno@clisp.org>2023-03-31 04:44:56 +0200
commita206ccf8db394a262efc175f1962ba3ea64c8b90 (patch)
treebfe3efe5f2ad17b4814ecbcd46c9d9df2c3a41c9 /tests
parente5b2b726e2720cb6c13fde84afd1514aca9f03d6 (diff)
downloadgnulib-a206ccf8db394a262efc175f1962ba3ea64c8b90.tar.gz
Avoid test failures on Android.
* tests/test-btowc.c (main): Treat C locale like in tests/test-mbrtowc.c. * tests/test-mbsrtowcs.c (main): Likewise. * tests/test-mbsnrtowcs.c (main): Likewise. * tests/test-mbstowcs.c (main): Likewise.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-btowc.c9
-rw-r--r--tests/test-mbsnrtowcs.c9
-rw-r--r--tests/test-mbsrtowcs.c9
-rw-r--r--tests/test-mbstowcs.c9
4 files changed, 36 insertions, 0 deletions
diff --git a/tests/test-btowc.c b/tests/test-btowc.c
index e5918c36e9..8a803e5335 100644
--- a/tests/test-btowc.c
+++ b/tests/test-btowc.c
@@ -39,6 +39,15 @@ 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], "3") == 0 && MB_CUR_MAX > 1)
+ argv[1] = "2";
+#endif
+
if (argc > 1)
switch (argv[1][0])
{
diff --git a/tests/test-mbsnrtowcs.c b/tests/test-mbsnrtowcs.c
index 2d0e6a7521..9831fd1843 100644
--- a/tests/test-mbsnrtowcs.c
+++ b/tests/test-mbsnrtowcs.c
@@ -72,6 +72,15 @@ main (int argc, char *argv[])
ASSERT (mbsinit (&state));
}
+#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], "5") == 0 && MB_CUR_MAX > 1)
+ argv[1] = "2";
+#endif
+
if (argc > 1)
{
int unlimited;
diff --git a/tests/test-mbsrtowcs.c b/tests/test-mbsrtowcs.c
index 7e8cc4a1ea..3c351f2346 100644
--- a/tests/test-mbsrtowcs.c
+++ b/tests/test-mbsrtowcs.c
@@ -72,6 +72,15 @@ main (int argc, char *argv[])
ASSERT (mbsinit (&state));
}
+#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], "5") == 0 && MB_CUR_MAX > 1)
+ argv[1] = "2";
+#endif
+
if (argc > 1)
{
int unlimited;
diff --git a/tests/test-mbstowcs.c b/tests/test-mbstowcs.c
index a33511a07d..21ee0c95dd 100644
--- a/tests/test-mbstowcs.c
+++ b/tests/test-mbstowcs.c
@@ -65,6 +65,15 @@ main (int argc, char *argv[])
ASSERT (wc == 0);
}
+#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], "5") == 0 && MB_CUR_MAX > 1)
+ argv[1] = "2";
+#endif
+
if (argc > 1)
{
int unlimited;