From: Bruno Haible Date: Fri, 31 Mar 2023 02:44:56 +0000 (+0200) Subject: Avoid test failures on Android. X-Git-Tag: v1.0~1538 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=a206ccf8db394a262efc175f1962ba3ea64c8b90;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index e3d94c501e..eed2321d8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2023-03-30 Bruno Haible + + 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. + 2023-03-30 Bruno Haible mbstowcs: Add 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;