]> Savannah Git Hosting - gnulib.git/commitdiff
Avoid test failures on Android.
authorBruno Haible <bruno@clisp.org>
Fri, 31 Mar 2023 02:44:56 +0000 (04:44 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 31 Mar 2023 02:44:56 +0000 (04:44 +0200)
* 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.

ChangeLog
tests/test-btowc.c
tests/test-mbsnrtowcs.c
tests/test-mbsrtowcs.c
tests/test-mbstowcs.c

index e3d94c501e2a3247b18aa41903a40a9246e3401a..eed2321d8f8236a92b63c3e063ab2d8ee34f9157 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-03-30  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        mbstowcs: Add tests.
index e5918c36e91b25d9b6f4621ba9d19576e2815d78..8a803e5335727a9026e3988f1b934f4ce8773f28 100644 (file)
@@ -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])
       {
index 2d0e6a7521b7efa65dae9974f6c112627ef36d13..9831fd18431ef8715d837dcde9f0fb0ae8cc26a6 100644 (file)
@@ -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;
index 7e8cc4a1eacb82705ddb9539b282301845f7fb88..3c351f2346f93b3b88c4bbc61c2a8e206d88f20d 100644 (file)
@@ -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;
index a33511a07d17559a2c45f136517c5ccfdb7c4284..21ee0c95dd0bc7cd21210fa867a2872ddd626083 100644 (file)
@@ -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;