summaryrefslogtreecommitdiff
path: root/tests/unistdio/test-u8-vasnprintf3.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-10-20 15:22:21 +0200
committerJörg Frings-Fürst <debian@jff.email>2024-10-20 15:22:21 +0200
commit1d8b9e17ea13630aec475484da09ebba0366f7c8 (patch)
tree0c801f68561bfb0930a4ade80d7ca3a7940887ab /tests/unistdio/test-u8-vasnprintf3.c
parent84e26c587987e8484d55db4165f188b40c09e94b (diff)
parent630f99f29bd31a76d8d24da2975a045452c763ef (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'tests/unistdio/test-u8-vasnprintf3.c')
-rw-r--r--tests/unistdio/test-u8-vasnprintf3.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/tests/unistdio/test-u8-vasnprintf3.c b/tests/unistdio/test-u8-vasnprintf3.c
index b5dc9ab6..72efa60a 100644
--- a/tests/unistdio/test-u8-vasnprintf3.c
+++ b/tests/unistdio/test-u8-vasnprintf3.c
@@ -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 *
@@ -105,5 +153,5 @@ main (int argc, char *argv[])
return 1;
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}