]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: avoid test failure on Android
authorBruno Haible <bruno@clisp.org>
Mon, 28 Aug 2023 10:07:18 +0000 (12:07 +0200)
committerPádraig Brady <P@draigBrady.com>
Mon, 28 Aug 2023 11:18:26 +0000 (12:18 +0100)
* gl/tests/test-mbsalign.c (main): Skip the unibyte truncation test
on Android, when the "C" locale in fact is multibyte.

gl/tests/test-mbsalign.c

index d7b50b470481b12bd6fd7b8dcaf359f4931af5e2..151dbef13e56b85d6a29cef00b5f0d6cc371ca96 100644 (file)
@@ -29,10 +29,19 @@ main (void)
   char dest[4 * 16 + 1];
   size_t width, n;
 
-  /* Test unibyte truncation.  */
-  width = 4;
-  n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
-  ASSERT (n == 4);
+#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 (MB_CUR_MAX == 1)
+#endif
+    {
+      /* Test unibyte truncation.  */
+      width = 4;
+      n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
+      ASSERT (n == 4);
+    }
 
   /* Test center alignment.  */
   width = 4;