summaryrefslogtreecommitdiff
path: root/tests/unistdio/test-u16-printf1.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unistdio/test-u16-printf1.h')
-rw-r--r--tests/unistdio/test-u16-printf1.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/unistdio/test-u16-printf1.h b/tests/unistdio/test-u16-printf1.h
index e501c9e4..d2a71153 100644
--- a/tests/unistdio/test-u16-printf1.h
+++ b/tests/unistdio/test-u16-printf1.h
@@ -120,6 +120,32 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...))
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 };
@@ -178,6 +204,34 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...))
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 };
@@ -236,6 +290,34 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...))
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. */