]> Savannah Git Hosting - gnulib.git/commitdiff
u*-vasnprintf tests: Add tests of %ls directive.
authorBruno Haible <bruno@clisp.org>
Tue, 18 Jun 2024 17:21:53 +0000 (19:21 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 18 Jun 2024 17:21:53 +0000 (19:21 +0200)
* tests/unistdio/test-u8-vasnprintf2.c (test_function): Add tests of
the %ls directive with non-ASCII argument.
* tests/unistdio/test-u8-vasnprintf3.c (test_function): Likewise.
* tests/unistdio/test-u16-vasnprintf2.c (test_function): Likewise.
* tests/unistdio/test-u16-vasnprintf3.c (test_function): Likewise.
* tests/unistdio/test-u32-vasnprintf2.c (test_function): Likewise.
* tests/unistdio/test-u32-vasnprintf3.c (test_function): Likewise.
* tests/unistdio/test-ulc-vasnprintf2.c (test_function): Likewise.
* tests/unistdio/test-ulc-vasnprintf3.c (test_function): Likewise.

ChangeLog
tests/unistdio/test-u16-vasnprintf2.c
tests/unistdio/test-u16-vasnprintf3.c
tests/unistdio/test-u32-vasnprintf2.c
tests/unistdio/test-u32-vasnprintf3.c
tests/unistdio/test-u8-vasnprintf2.c
tests/unistdio/test-u8-vasnprintf3.c
tests/unistdio/test-ulc-vasnprintf2.c
tests/unistdio/test-ulc-vasnprintf3.c

index 5d5acb7de98b1ed86b82f462452e818b56f75e85..43b8424b6b72f7173b79cf0e36bf1608147654c2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2024-06-18  Bruno Haible  <bruno@clisp.org>
 
+       u*-vasnprintf tests: Add tests of %ls directive.
+       * tests/unistdio/test-u8-vasnprintf2.c (test_function): Add tests of
+       the %ls directive with non-ASCII argument.
+       * tests/unistdio/test-u8-vasnprintf3.c (test_function): Likewise.
+       * tests/unistdio/test-u16-vasnprintf2.c (test_function): Likewise.
+       * tests/unistdio/test-u16-vasnprintf3.c (test_function): Likewise.
+       * tests/unistdio/test-u32-vasnprintf2.c (test_function): Likewise.
+       * tests/unistdio/test-u32-vasnprintf3.c (test_function): Likewise.
+       * tests/unistdio/test-ulc-vasnprintf2.c (test_function): Likewise.
+       * tests/unistdio/test-ulc-vasnprintf3.c (test_function): Likewise.
+
        u*-vasnprintf: Fix handling of %ls, %lc directives on Solaris, MSVC.
        * lib/vasnprintf.c (VASNPRINTF): When implementing the %ls, %lc
        directives ourselves: Rename variable 'characters' to 'bytes'. Also
index c0da1e00cfeac819dc7ef89e88ba52e22b5e4efd..4c061c66848894cba6bacbaf7aa67c35b3e52517 100644 (file)
@@ -87,6 +87,69 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, .
       free (result);
     }
   }
+
+  /* Test the support of the 'ls' conversion specifier for wide strings.  */
+
+  {
+    const char *locale_string = "h\351t\351rog\351n\351it\351"; /* hétérogénéité */
+    wchar_t wide_string[20];
+    ASSERT (mbstowcs (wide_string, locale_string, SIZEOF (wide_string)) == 13);
+    {
+      size_t length;
+      uint16_t *result =
+        my_asnprintf (NULL, &length, "%ls %d", wide_string, 33, 44, 55);
+      static const uint16_t expected[] =
+        { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+          'i', 't', 0x00e9, ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u16_strcmp (result, expected) == 0);
+      ASSERT (length == u16_strlen (result));
+      free (result);
+    }
+    { /* Width.  */
+      size_t length;
+      uint16_t *result =
+        my_asnprintf (NULL, &length, "%20ls %d", wide_string, 33, 44, 55);
+      static const uint16_t expected[] =
+        { ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'h', 0x00e9, 't',
+          0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9, 'i', 't', 0x00e9,
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u16_strcmp (result, expected) == 0);
+      ASSERT (length == u16_strlen (result));
+      free (result);
+    }
+    { /* FLAG_LEFT.  */
+      size_t length;
+      uint16_t *result =
+        my_asnprintf (NULL, &length, "%-20ls %d", wide_string, 33, 44, 55);
+      static const uint16_t expected[] =
+        { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+          'i', 't', 0x00e9, ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u16_strcmp (result, expected) == 0);
+      ASSERT (length == u16_strlen (result));
+      free (result);
+    }
+    { /* FLAG_ZERO: no effect.  */
+      size_t length;
+      uint16_t *result =
+        my_asnprintf (NULL, &length, "%020ls %d", wide_string, 33, 44, 55);
+      static const uint16_t expected[] =
+        { ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'h', 0x00e9, 't',
+          0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9, 'i', 't', 0x00e9,
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u16_strcmp (result, expected) == 0);
+      ASSERT (length == u16_strlen (result));
+      free (result);
+    }
+  }
 }
 
 static uint16_t *
index f1156791bc6a605eac8b18af84216694a084a87a..d5924f8bad0b15e144cc65da9c4117ca6bf40e4d 100644 (file)
@@ -87,6 +87,69 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, .
       free (result);
     }
   }
+
+  /* Test the support of the 'ls' conversion specifier for wide strings.  */
+
+  {
+    const char *locale_string = "h\303\251t\303\251rog\303\251n\303\251it\303\251"; /* hétérogénéité */
+    wchar_t wide_string[20];
+    ASSERT (mbstowcs (wide_string, locale_string, SIZEOF (wide_string)) == 13);
+    {
+      size_t length;
+      uint16_t *result =
+        my_asnprintf (NULL, &length, "%ls %d", wide_string, 33, 44, 55);
+      static const uint16_t expected[] =
+        { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+          'i', 't', 0x00e9, ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u16_strcmp (result, expected) == 0);
+      ASSERT (length == u16_strlen (result));
+      free (result);
+    }
+    { /* Width.  */
+      size_t length;
+      uint16_t *result =
+        my_asnprintf (NULL, &length, "%20ls %d", wide_string, 33, 44, 55);
+      static const uint16_t expected[] =
+        { ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'h', 0x00e9, 't',
+          0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9, 'i', 't', 0x00e9,
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u16_strcmp (result, expected) == 0);
+      ASSERT (length == u16_strlen (result));
+      free (result);
+    }
+    { /* FLAG_LEFT.  */
+      size_t length;
+      uint16_t *result =
+        my_asnprintf (NULL, &length, "%-20ls %d", wide_string, 33, 44, 55);
+      static const uint16_t expected[] =
+        { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+          'i', 't', 0x00e9, ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u16_strcmp (result, expected) == 0);
+      ASSERT (length == u16_strlen (result));
+      free (result);
+    }
+    { /* FLAG_ZERO: no effect.  */
+      size_t length;
+      uint16_t *result =
+        my_asnprintf (NULL, &length, "%020ls %d", wide_string, 33, 44, 55);
+      static const uint16_t expected[] =
+        { ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'h', 0x00e9, 't',
+          0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9, 'i', 't', 0x00e9,
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u16_strcmp (result, expected) == 0);
+      ASSERT (length == u16_strlen (result));
+      free (result);
+    }
+  }
 }
 
 static uint16_t *
index 64c91f0c4611de7205c27cbf5135243e104b5daa..70336c7c4928f0f6ce69182ff423cfc5996fba97 100644 (file)
@@ -87,6 +87,69 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, .
       free (result);
     }
   }
+
+  /* Test the support of the 'ls' conversion specifier for wide strings.  */
+
+  {
+    const char *locale_string = "h\351t\351rog\351n\351it\351"; /* hétérogénéité */
+    wchar_t wide_string[20];
+    ASSERT (mbstowcs (wide_string, locale_string, SIZEOF (wide_string)) == 13);
+    {
+      size_t length;
+      uint32_t *result =
+        my_asnprintf (NULL, &length, "%ls %d", wide_string, 33, 44, 55);
+      static const uint32_t expected[] =
+        { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+          'i', 't', 0x00e9, ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u32_strcmp (result, expected) == 0);
+      ASSERT (length == u32_strlen (result));
+      free (result);
+    }
+    { /* Width.  */
+      size_t length;
+      uint32_t *result =
+        my_asnprintf (NULL, &length, "%20ls %d", wide_string, 33, 44, 55);
+      static const uint32_t expected[] =
+        { ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'h', 0x00e9, 't',
+          0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9, 'i', 't', 0x00e9,
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u32_strcmp (result, expected) == 0);
+      ASSERT (length == u32_strlen (result));
+      free (result);
+    }
+    { /* FLAG_LEFT.  */
+      size_t length;
+      uint32_t *result =
+        my_asnprintf (NULL, &length, "%-20ls %d", wide_string, 33, 44, 55);
+      static const uint32_t expected[] =
+        { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+          'i', 't', 0x00e9, ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u32_strcmp (result, expected) == 0);
+      ASSERT (length == u32_strlen (result));
+      free (result);
+    }
+    { /* FLAG_ZERO: no effect.  */
+      size_t length;
+      uint32_t *result =
+        my_asnprintf (NULL, &length, "%020ls %d", wide_string, 33, 44, 55);
+      static const uint32_t expected[] =
+        { ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'h', 0x00e9, 't',
+          0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9, 'i', 't', 0x00e9,
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u32_strcmp (result, expected) == 0);
+      ASSERT (length == u32_strlen (result));
+      free (result);
+    }
+  }
 }
 
 static uint32_t *
index 9e4eb11f9212c1545f8cb3292e0cc63e418759d4..816eb9fd8b30ead2535df4b60bbc25ac64e6b945 100644 (file)
@@ -87,6 +87,69 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, .
       free (result);
     }
   }
+
+  /* Test the support of the 'ls' conversion specifier for wide strings.  */
+
+  {
+    const char *locale_string = "h\303\251t\303\251rog\303\251n\303\251it\303\251"; /* hétérogénéité */
+    wchar_t wide_string[20];
+    ASSERT (mbstowcs (wide_string, locale_string, SIZEOF (wide_string)) == 13);
+    {
+      size_t length;
+      uint32_t *result =
+        my_asnprintf (NULL, &length, "%ls %d", wide_string, 33, 44, 55);
+      static const uint32_t expected[] =
+        { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+          'i', 't', 0x00e9, ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u32_strcmp (result, expected) == 0);
+      ASSERT (length == u32_strlen (result));
+      free (result);
+    }
+    { /* Width.  */
+      size_t length;
+      uint32_t *result =
+        my_asnprintf (NULL, &length, "%20ls %d", wide_string, 33, 44, 55);
+      static const uint32_t expected[] =
+        { ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'h', 0x00e9, 't',
+          0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9, 'i', 't', 0x00e9,
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u32_strcmp (result, expected) == 0);
+      ASSERT (length == u32_strlen (result));
+      free (result);
+    }
+    { /* FLAG_LEFT.  */
+      size_t length;
+      uint32_t *result =
+        my_asnprintf (NULL, &length, "%-20ls %d", wide_string, 33, 44, 55);
+      static const uint32_t expected[] =
+        { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+          'i', 't', 0x00e9, ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u32_strcmp (result, expected) == 0);
+      ASSERT (length == u32_strlen (result));
+      free (result);
+    }
+    { /* FLAG_ZERO: no effect.  */
+      size_t length;
+      uint32_t *result =
+        my_asnprintf (NULL, &length, "%020ls %d", wide_string, 33, 44, 55);
+      static const uint32_t expected[] =
+        { ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'h', 0x00e9, 't',
+          0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9, 'i', 't', 0x00e9,
+          ' ', '3', '3', 0
+        };
+      ASSERT (result != NULL);
+      ASSERT (u32_strcmp (result, expected) == 0);
+      ASSERT (length == u32_strlen (result));
+      free (result);
+    }
+  }
 }
 
 static uint32_t *
index aa11e4743791f57017bcc9aa9d0f7f015388fd49..3c0a00f13f3dd2ebe31839e17d7cd5eee06f5a6a 100644 (file)
@@ -77,6 +77,54 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ...
       free (result);
     }
   }
+
+  /* Test the support of the 'ls' conversion specifier for wide strings.  */
+
+  {
+    const char *locale_string = "h\351t\351rog\351n\351it\351"; /* hétérogénéité */
+    wchar_t wide_string[20];
+    ASSERT (mbstowcs (wide_string, locale_string, SIZEOF (wide_string)) == 13);
+    {
+      size_t length;
+      uint8_t *result =
+        my_asnprintf (NULL, &length, "%ls %d", wide_string, 33, 44, 55);
+      static const uint8_t expected[] = "h\303\251t\303\251rog\303\251n\303\251it\303\251 33";
+      ASSERT (result != NULL);
+      ASSERT (u8_strcmp (result, expected) == 0);
+      ASSERT (length == u8_strlen (result));
+      free (result);
+    }
+    { /* Width.  */
+      size_t length;
+      uint8_t *result =
+        my_asnprintf (NULL, &length, "%20ls %d", wide_string, 33, 44, 55);
+      static const uint8_t expected[] = "       h\303\251t\303\251rog\303\251n\303\251it\303\251 33";
+      ASSERT (result != NULL);
+      ASSERT (u8_strcmp (result, expected) == 0);
+      ASSERT (length == u8_strlen (result));
+      free (result);
+    }
+    { /* FLAG_LEFT.  */
+      size_t length;
+      uint8_t *result =
+        my_asnprintf (NULL, &length, "%-20ls %d", wide_string, 33, 44, 55);
+      static const uint8_t expected[] = "h\303\251t\303\251rog\303\251n\303\251it\303\251        33";
+      ASSERT (result != NULL);
+      ASSERT (u8_strcmp (result, expected) == 0);
+      ASSERT (length == u8_strlen (result));
+      free (result);
+    }
+    { /* FLAG_ZERO: no effect.  */
+      size_t length;
+      uint8_t *result =
+        my_asnprintf (NULL, &length, "%020ls %d", wide_string, 33, 44, 55);
+      static const uint8_t expected[] = "       h\303\251t\303\251rog\303\251n\303\251it\303\251 33";
+      ASSERT (result != NULL);
+      ASSERT (u8_strcmp (result, expected) == 0);
+      ASSERT (length == u8_strlen (result));
+      free (result);
+    }
+  }
 }
 
 static uint8_t *
index 98b851aa2781c2aed88f045a6dad4dbd55cce520..72efa60ae66b58ac25308336ce05ead918962672 100644 (file)
@@ -77,6 +77,54 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ...
       free (result);
     }
   }
+
+  /* Test the support of the 'ls' conversion specifier for wide strings.  */
+
+  {
+    const char *locale_string = "h\303\251t\303\251rog\303\251n\303\251it\303\251"; /* hétérogénéité */
+    wchar_t wide_string[20];
+    ASSERT (mbstowcs (wide_string, locale_string, SIZEOF (wide_string)) == 13);
+    {
+      size_t length;
+      uint8_t *result =
+        my_asnprintf (NULL, &length, "%ls %d", wide_string, 33, 44, 55);
+      static const uint8_t expected[] = "h\303\251t\303\251rog\303\251n\303\251it\303\251 33";
+      ASSERT (result != NULL);
+      ASSERT (u8_strcmp (result, expected) == 0);
+      ASSERT (length == u8_strlen (result));
+      free (result);
+    }
+    { /* Width.  */
+      size_t length;
+      uint8_t *result =
+        my_asnprintf (NULL, &length, "%20ls %d", wide_string, 33, 44, 55);
+      static const uint8_t expected[] = "       h\303\251t\303\251rog\303\251n\303\251it\303\251 33";
+      ASSERT (result != NULL);
+      ASSERT (u8_strcmp (result, expected) == 0);
+      ASSERT (length == u8_strlen (result));
+      free (result);
+    }
+    { /* FLAG_LEFT.  */
+      size_t length;
+      uint8_t *result =
+        my_asnprintf (NULL, &length, "%-20ls %d", wide_string, 33, 44, 55);
+      static const uint8_t expected[] = "h\303\251t\303\251rog\303\251n\303\251it\303\251        33";
+      ASSERT (result != NULL);
+      ASSERT (u8_strcmp (result, expected) == 0);
+      ASSERT (length == u8_strlen (result));
+      free (result);
+    }
+    { /* FLAG_ZERO: no effect.  */
+      size_t length;
+      uint8_t *result =
+        my_asnprintf (NULL, &length, "%020ls %d", wide_string, 33, 44, 55);
+      static const uint8_t expected[] = "       h\303\251t\303\251rog\303\251n\303\251it\303\251 33";
+      ASSERT (result != NULL);
+      ASSERT (u8_strcmp (result, expected) == 0);
+      ASSERT (length == u8_strlen (result));
+      free (result);
+    }
+  }
 }
 
 static uint8_t *
index 1904aa76f1f7b363fc799088d984a167a2571c55..d91fa86e5a964c134ca22a9f0b4557ba454cb098 100644 (file)
@@ -214,6 +214,50 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
       free (result);
     }
   }
+
+  /* Test the support of the 'ls' conversion specifier for wide strings.  */
+
+  {
+    const char *locale_string = "h\351t\351rog\351n\351it\351"; /* hétérogénéité */
+    wchar_t wide_string[20];
+    ASSERT (mbstowcs (wide_string, locale_string, SIZEOF (wide_string)) == 13);
+    {
+      size_t length;
+      char *result =
+        my_asnprintf (NULL, &length, "%ls %d", wide_string, 33, 44, 55);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "h\351t\351rog\351n\351it\351 33") == 0);
+      ASSERT (length == strlen (result));
+      free (result);
+    }
+    { /* Width.  */
+      size_t length;
+      char *result =
+        my_asnprintf (NULL, &length, "%20ls %d", wide_string, 33, 44, 55);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "       h\351t\351rog\351n\351it\351 33") == 0);
+      ASSERT (length == strlen (result));
+      free (result);
+    }
+    { /* FLAG_LEFT.  */
+      size_t length;
+      char *result =
+        my_asnprintf (NULL, &length, "%-20ls %d", wide_string, 33, 44, 55);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "h\351t\351rog\351n\351it\351        33") == 0);
+      ASSERT (length == strlen (result));
+      free (result);
+    }
+    { /* FLAG_ZERO: no effect.  */
+      size_t length;
+      char *result =
+        my_asnprintf (NULL, &length, "%020ls %d", wide_string, 33, 44, 55);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "       h\351t\351rog\351n\351it\351 33") == 0);
+      ASSERT (length == strlen (result));
+      free (result);
+    }
+  }
 }
 
 static char *
index 12ef2bfc662620f49a55d12ceaf615dfcecac9de..7fc6171952c87b5b8466a10d3950c0f25ba5852e 100644 (file)
@@ -202,6 +202,50 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
       free (result);
     }
   }
+
+  /* Test the support of the 'ls' conversion specifier for wide strings.  */
+
+  {
+    const char *locale_string = "h\303\251t\303\251rog\303\251n\303\251it\303\251"; /* hétérogénéité */
+    wchar_t wide_string[20];
+    ASSERT (mbstowcs (wide_string, locale_string, SIZEOF (wide_string)) == 13);
+    {
+      size_t length;
+      char *result =
+        my_asnprintf (NULL, &length, "%ls %d", wide_string, 33, 44, 55);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "h\303\251t\303\251rog\303\251n\303\251it\303\251 33") == 0);
+      ASSERT (length == strlen (result));
+      free (result);
+    }
+    { /* Width.  */
+      size_t length;
+      char *result =
+        my_asnprintf (NULL, &length, "%20ls %d", wide_string, 33, 44, 55);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "       h\303\251t\303\251rog\303\251n\303\251it\303\251 33") == 0);
+      ASSERT (length == strlen (result));
+      free (result);
+    }
+    { /* FLAG_LEFT.  */
+      size_t length;
+      char *result =
+        my_asnprintf (NULL, &length, "%-20ls %d", wide_string, 33, 44, 55);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "h\303\251t\303\251rog\303\251n\303\251it\303\251        33") == 0);
+      ASSERT (length == strlen (result));
+      free (result);
+    }
+    { /* FLAG_ZERO: no effect.  */
+      size_t length;
+      char *result =
+        my_asnprintf (NULL, &length, "%020ls %d", wide_string, 33, 44, 55);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "       h\303\251t\303\251rog\303\251n\303\251it\303\251 33") == 0);
+      ASSERT (length == strlen (result));
+      free (result);
+    }
+  }
 }
 
 static char *