From a206ccf8db394a262efc175f1962ba3ea64c8b90 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 31 Mar 2023 04:44:56 +0200 Subject: 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. --- tests/test-btowc.c | 9 +++++++++ tests/test-mbsnrtowcs.c | 9 +++++++++ tests/test-mbsrtowcs.c | 9 +++++++++ tests/test-mbstowcs.c | 9 +++++++++ 4 files changed, 36 insertions(+) (limited to 'tests') 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; -- cgit v1.2.1