+2024-06-19 Bruno Haible <bruno@clisp.org>
+
+ u*-vasnprintf tests: Add more tests of %U, %lU, %llU directives.
+ * tests/unistdio/test-u8-printf1.h (test_xfunction): Add more tests of
+ %U, %lU, %llU directives with width and non-ASCII argument.
+ * tests/unistdio/test-u16-printf1.h (test_xfunction): Likewise.
+ * tests/unistdio/test-u32-printf1.h (test_xfunction): Likewise.
+ * tests/unistdio/test-ulc-vasnprintf2.c (test_function): Likewise.
+ * tests/unistdio/test-ulc-vasnprintf3.c (test_function): Likewise.
+
2024-06-19 Bruno Haible <bruno@clisp.org>
filemode tests: Tweak.
free (result);
}
}
+ { /* Width with a non-ASCII argument. */
+ static const uint8_t unicode_string[] = /* hétérogénéité */
+ "h\303\251t\303\251rog\303\251n\303\251it\303\251";
+ uint16_t *result =
+ my_xasprintf ("%20U %d", unicode_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);
+ free (result);
+ }
+ { /* Width with a non-BMP argument. */
+ static const uint8_t unicode_string[] = "\360\237\220\203"; /* 🐃 */
+ uint16_t *result =
+ my_xasprintf ("%10U %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0xd83d,
+ 0xdc03, ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
{
static const uint16_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
free (result);
}
}
+ { /* Width with a non-ASCII argument. */
+ static const uint16_t unicode_string[] = /* hétérogénéité */
+ { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+ 'i', 't', 0x00e9, 0
+ };
+ uint16_t *result =
+ my_xasprintf ("%20lU %d", unicode_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);
+ free (result);
+ }
+ { /* Width with a non-BMP argument. */
+ static const uint16_t unicode_string[] = { 0xd83d, 0xdc03, 0 }; /* 🐃 */
+ uint16_t *result =
+ my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0xd83d,
+ 0xdc03, ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
{
static const uint32_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
free (result);
}
}
+ { /* Width with a non-ASCII argument. */
+ static const uint32_t unicode_string[] = /* hétérogénéité */
+ { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+ 'i', 't', 0x00e9, 0
+ };
+ uint16_t *result =
+ my_xasprintf ("%20llU %d", unicode_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);
+ free (result);
+ }
+ { /* Width with a non-BMP argument. */
+ static const uint32_t unicode_string[] = { 0x1f403, 0 }; /* 🐃 */
+ uint16_t *result =
+ my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0xd83d,
+ 0xdc03, ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
/* Test the support of the 's' conversion specifier for strings. */
free (result);
}
}
+ { /* Width with a non-ASCII argument. */
+ static const uint8_t unicode_string[] = /* hétérogénéité */
+ "h\303\251t\303\251rog\303\251n\303\251it\303\251";
+ uint32_t *result =
+ my_xasprintf ("%20U %d", unicode_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);
+ free (result);
+ }
+ { /* Width with a non-BMP argument. */
+ static const uint8_t unicode_string[] = "\360\237\220\203"; /* 🐃 */
+ uint32_t *result =
+ my_xasprintf ("%10U %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x1f403,
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
{
static const uint16_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
free (result);
}
}
+ { /* Width with a non-ASCII argument. */
+ static const uint16_t unicode_string[] = /* hétérogénéité */
+ { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+ 'i', 't', 0x00e9, 0
+ };
+ uint32_t *result =
+ my_xasprintf ("%20lU %d", unicode_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);
+ free (result);
+ }
+ { /* Width with a non-BMP argument. */
+ static const uint16_t unicode_string[] = { 0xd83d, 0xdc03, 0 }; /* 🐃 */
+ uint32_t *result =
+ my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x1f403,
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
{
static const uint32_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
free (result);
}
}
+ { /* Width with a non-ASCII argument. */
+ static const uint32_t unicode_string[] = /* hétérogénéité */
+ { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+ 'i', 't', 0x00e9, 0
+ };
+ uint32_t *result =
+ my_xasprintf ("%20llU %d", unicode_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);
+ free (result);
+ }
+ { /* Width with a non-BMP argument. */
+ static const uint32_t unicode_string[] = { 0x1f403, 0 }; /* 🐃 */
+ uint32_t *result =
+ my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x1f403,
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
/* Test the support of the 's' conversion specifier for strings. */
free (result);
}
}
+ { /* Width with a non-ASCII argument. */
+ static const uint8_t unicode_string[] = /* hétérogénéité */
+ "h\303\251t\303\251rog\303\251n\303\251it\303\251";
+ uint8_t *result =
+ my_xasprintf ("%20U %d", unicode_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);
+ free (result);
+ }
+ { /* Width with a non-BMP argument. */
+ static const uint8_t unicode_string[] = "\360\237\220\203"; /* 🐃 */
+ uint8_t *result =
+ my_xasprintf ("%10U %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " \360\237\220\203 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
{
static const uint16_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
free (result);
}
}
+ { /* Width with a non-ASCII argument. */
+ static const uint16_t unicode_string[] = /* hétérogénéité */
+ { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+ 'i', 't', 0x00e9, 0
+ };
+ uint8_t *result =
+ my_xasprintf ("%20lU %d", unicode_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);
+ free (result);
+ }
+ { /* Width with a non-BMP argument. */
+ static const uint16_t unicode_string[] = { 0xd83d, 0xdc03, 0 }; /* 🐃 */
+ uint8_t *result =
+ my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " \360\237\220\203 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
{
static const uint32_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
free (result);
}
}
+ { /* Width with a non-ASCII argument. */
+ static const uint32_t unicode_string[] = /* hétérogénéité */
+ { 'h', 0x00e9, 't', 0x00e9, 'r', 'o', 'g', 0x00e9, 'n', 0x00e9,
+ 'i', 't', 0x00e9, 0
+ };
+ uint8_t *result =
+ my_xasprintf ("%20llU %d", unicode_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);
+ free (result);
+ }
+ { /* Width with a non-BMP argument. */
+ static const uint32_t unicode_string[] = { 0x1f403, 0 }; /* 🐃 */
+ uint8_t *result =
+ my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " \360\237\220\203 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
/* Test the support of the 's' conversion specifier for strings. */
free (result);
}
}
+ { /* Width with a non-BMP argument. */
+ static const uint8_t unicode_string[] = "\360\237\220\203"; /* 🐃 */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%10U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " ? 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
{
static const uint16_t unicode_string[] = /* Rafał Maszkowski */
free (result);
}
}
+ { /* Width with a non-BMP argument. */
+ static const uint16_t unicode_string[] = { 0xd83d, 0xdc03, 0 }; /* 🐃 */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%10lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " ? 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
{
static const uint32_t unicode_string[] = /* Rafał Maszkowski */
free (result);
}
}
+ { /* Width with a non-BMP argument. */
+ static const uint32_t unicode_string[] = { 0x1f403, 0 }; /* 🐃 */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%10llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " ? 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
/* Test the support of the 's' conversion specifier for strings. */
free (result);
}
}
+ { /* Width with a non-BMP argument. */
+ static const uint8_t unicode_string[] = "\360\237\220\203"; /* 🐃 */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%10U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " \360\237\220\203 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
{
static const uint16_t unicode_string[] = /* Rafał Maszkowski */
free (result);
}
}
+ { /* Width with a non-BMP argument. */
+ static const uint16_t unicode_string[] = { 0xd83d, 0xdc03, 0 }; /* 🐃 */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%10lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " \360\237\220\203 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
{
static const uint32_t unicode_string[] = /* Rafał Maszkowski */
free (result);
}
}
+ { /* Width with a non-BMP argument. */
+ static const uint32_t unicode_string[] = { 0x1f403, 0 }; /* 🐃 */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%10llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " \360\237\220\203 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
/* Test the support of the 's' conversion specifier for strings. */