diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2024-10-20 15:21:43 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2024-10-20 15:21:43 +0200 |
commit | 4682deeb62247d34de87f8e777f99e2d337fd377 (patch) | |
tree | 5bd5b5605b5f3a4b3c8ea7468c34c23094afdef4 /tests/unistdio/test-u32-printf1.h | |
parent | 00893e79fc62966067af1a106567db96bd170338 (diff) |
New upstream version 1.3upstream/1.3upstream
Diffstat (limited to 'tests/unistdio/test-u32-printf1.h')
-rw-r--r-- | tests/unistdio/test-u32-printf1.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/unistdio/test-u32-printf1.h b/tests/unistdio/test-u32-printf1.h index ae0edc6a..d7ba2e09 100644 --- a/tests/unistdio/test-u32-printf1.h +++ b/tests/unistdio/test-u32-printf1.h @@ -120,6 +120,32 @@ test_xfunction (uint32_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"; + 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 }; @@ -178,6 +204,34 @@ test_xfunction (uint32_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 + }; + 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 }; @@ -236,6 +290,34 @@ test_xfunction (uint32_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 + }; + 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. */ |