summaryrefslogtreecommitdiff
path: root/tests/unistdio
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unistdio')
-rw-r--r--tests/unistdio/test-u16-asnprintf1.c4
-rw-r--r--tests/unistdio/test-u16-asnprintf1.h57
-rw-r--r--tests/unistdio/test-u16-printf1.h84
-rw-r--r--tests/unistdio/test-u16-vasnprintf1.c4
-rw-r--r--tests/unistdio/test-u16-vasnprintf2.c67
-rw-r--r--tests/unistdio/test-u16-vasnprintf3.c67
-rw-r--r--tests/unistdio/test-u16-vasprintf1.c4
-rw-r--r--tests/unistdio/test-u16-vsnprintf1.c4
-rw-r--r--tests/unistdio/test-u16-vsprintf1.c4
-rw-r--r--tests/unistdio/test-u32-asnprintf1.c4
-rw-r--r--tests/unistdio/test-u32-asnprintf1.h57
-rw-r--r--tests/unistdio/test-u32-printf1.h84
-rw-r--r--tests/unistdio/test-u32-vasnprintf1.c4
-rw-r--r--tests/unistdio/test-u32-vasnprintf2.c67
-rw-r--r--tests/unistdio/test-u32-vasnprintf3.c67
-rw-r--r--tests/unistdio/test-u32-vasprintf1.c4
-rw-r--r--tests/unistdio/test-u32-vsnprintf1.c4
-rw-r--r--tests/unistdio/test-u32-vsprintf1.c4
-rw-r--r--tests/unistdio/test-u8-asnprintf1.c4
-rw-r--r--tests/unistdio/test-u8-asnprintf1.h57
-rw-r--r--tests/unistdio/test-u8-printf1.h66
-rw-r--r--tests/unistdio/test-u8-vasnprintf1.c4
-rw-r--r--tests/unistdio/test-u8-vasnprintf2.c52
-rw-r--r--tests/unistdio/test-u8-vasnprintf3.c52
-rw-r--r--tests/unistdio/test-u8-vasprintf1.c4
-rw-r--r--tests/unistdio/test-u8-vsnprintf1.c4
-rw-r--r--tests/unistdio/test-u8-vsprintf1.c4
-rw-r--r--tests/unistdio/test-ulc-asnprintf1.c5
-rw-r--r--tests/unistdio/test-ulc-asnprintf1.h57
-rw-r--r--tests/unistdio/test-ulc-printf1.h2
-rw-r--r--tests/unistdio/test-ulc-vasnprintf1.c5
-rw-r--r--tests/unistdio/test-ulc-vasnprintf2.c78
-rw-r--r--tests/unistdio/test-ulc-vasnprintf3.c78
-rw-r--r--tests/unistdio/test-ulc-vasprintf1.c4
-rw-r--r--tests/unistdio/test-ulc-vsnprintf1.c4
-rw-r--r--tests/unistdio/test-ulc-vsprintf1.c4
-rw-r--r--tests/unistdio/test-unistdio-h.c26
37 files changed, 1036 insertions, 64 deletions
diff --git a/tests/unistdio/test-u16-asnprintf1.c b/tests/unistdio/test-u16-asnprintf1.c
index 67ce490a..8e047cce 100644
--- a/tests/unistdio/test-u16-asnprintf1.c
+++ b/tests/unistdio/test-u16-asnprintf1.c
@@ -1,5 +1,5 @@
/* Test of u16_asnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -42,5 +42,5 @@ int
main (int argc, char *argv[])
{
test_asnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u16-asnprintf1.h b/tests/unistdio/test-u16-asnprintf1.h
index 4ec31a43..6d1be290 100644
--- a/tests/unistdio/test-u16-asnprintf1.h
+++ b/tests/unistdio/test-u16-asnprintf1.h
@@ -1,5 +1,5 @@
/* Test of u16_[v]asnprintf() function.
- Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -57,4 +57,59 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, .
if (result != buf)
free (result);
}
+
+ /* Verify that u16_[v]asnprintf() rejects a width > 2 GiB, < 4 GiB. */
+ {
+ size_t length;
+ uint16_t *s = my_asnprintf (NULL, &length, "x%03000000000dy\n", -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint16_t arg[] = { '@', 0 };
+ size_t length;
+ uint16_t *s = my_asnprintf (NULL, &length, "x%03000000000lUy\n", arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+
+ /* Verify that u16_[v]asnprintf() rejects a width > 4 GiB. */
+ {
+ size_t length;
+ uint16_t *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306dy\n", /* 2^32 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint16_t arg[] = { '@', 0 };
+ size_t length;
+ uint16_t *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306lUy\n", /* 2^32 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ size_t length;
+ uint16_t *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626dy\n", /* 2^64 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint16_t arg[] = { '@', 0 };
+ size_t length;
+ uint16_t *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626lUy\n", /* 2^64 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
}
diff --git a/tests/unistdio/test-u16-printf1.h b/tests/unistdio/test-u16-printf1.h
index e501c9e4..0498b32e 100644
--- a/tests/unistdio/test-u16-printf1.h
+++ b/tests/unistdio/test-u16-printf1.h
@@ -1,5 +1,5 @@
/* Test of u16_v[a]s[n]printf() function.
- Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -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. */
diff --git a/tests/unistdio/test-u16-vasnprintf1.c b/tests/unistdio/test-u16-vasnprintf1.c
index e39495c9..c6c0f520 100644
--- a/tests/unistdio/test-u16-vasnprintf1.c
+++ b/tests/unistdio/test-u16-vasnprintf1.c
@@ -1,5 +1,5 @@
/* Test of u16_vasnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -71,5 +71,5 @@ int
main (int argc, char *argv[])
{
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u16-vasnprintf2.c b/tests/unistdio/test-u16-vasnprintf2.c
index aee67584..cb9fb27a 100644
--- a/tests/unistdio/test-u16-vasnprintf2.c
+++ b/tests/unistdio/test-u16-vasnprintf2.c
@@ -1,5 +1,5 @@
/* Test of u16_vasnprintf() function in an ISO-8859-1 locale.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -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 *
@@ -115,5 +178,5 @@ main (int argc, char *argv[])
return 1;
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u16-vasnprintf3.c b/tests/unistdio/test-u16-vasnprintf3.c
index 0efe1984..80391a38 100644
--- a/tests/unistdio/test-u16-vasnprintf3.c
+++ b/tests/unistdio/test-u16-vasnprintf3.c
@@ -1,5 +1,5 @@
/* Test of u16_vasnprintf() function in an UTF-8 locale.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -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 *
@@ -115,5 +178,5 @@ main (int argc, char *argv[])
return 1;
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u16-vasprintf1.c b/tests/unistdio/test-u16-vasprintf1.c
index 203d2edf..f1613023 100644
--- a/tests/unistdio/test-u16-vasprintf1.c
+++ b/tests/unistdio/test-u16-vasprintf1.c
@@ -1,5 +1,5 @@
/* Test of u16_vasprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -58,5 +58,5 @@ int
main (int argc, char *argv[])
{
test_vasprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u16-vsnprintf1.c b/tests/unistdio/test-u16-vsnprintf1.c
index 6859468a..ac9d81f5 100644
--- a/tests/unistdio/test-u16-vsnprintf1.c
+++ b/tests/unistdio/test-u16-vsnprintf1.c
@@ -1,5 +1,5 @@
/* Test of u16_vsnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -64,5 +64,5 @@ main (int argc, char *argv[])
{
test_vsnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u16-vsprintf1.c b/tests/unistdio/test-u16-vsprintf1.c
index b39a3056..dd323bd0 100644
--- a/tests/unistdio/test-u16-vsprintf1.c
+++ b/tests/unistdio/test-u16-vsprintf1.c
@@ -1,5 +1,5 @@
/* Test of u16_vsprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -64,5 +64,5 @@ main (int argc, char *argv[])
{
test_vsprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u32-asnprintf1.c b/tests/unistdio/test-u32-asnprintf1.c
index 5a16094b..4fd23030 100644
--- a/tests/unistdio/test-u32-asnprintf1.c
+++ b/tests/unistdio/test-u32-asnprintf1.c
@@ -1,5 +1,5 @@
/* Test of u32_asnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -42,5 +42,5 @@ int
main (int argc, char *argv[])
{
test_asnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u32-asnprintf1.h b/tests/unistdio/test-u32-asnprintf1.h
index 85fa2cf0..2046d4f6 100644
--- a/tests/unistdio/test-u32-asnprintf1.h
+++ b/tests/unistdio/test-u32-asnprintf1.h
@@ -1,5 +1,5 @@
/* Test of u32_[v]asnprintf() function.
- Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -57,4 +57,59 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, .
if (result != buf)
free (result);
}
+
+ /* Verify that u32_[v]asnprintf() rejects a width > 2 GiB, < 4 GiB. */
+ {
+ size_t length;
+ uint32_t *s = my_asnprintf (NULL, &length, "x%03000000000dy\n", -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint32_t arg[] = { '@', 0 };
+ size_t length;
+ uint32_t *s = my_asnprintf (NULL, &length, "x%03000000000llUy\n", arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+
+ /* Verify that u32_[v]asnprintf() rejects a width > 4 GiB. */
+ {
+ size_t length;
+ uint32_t *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306dy\n", /* 2^32 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint32_t arg[] = { '@', 0 };
+ size_t length;
+ uint32_t *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306llUy\n", /* 2^32 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ size_t length;
+ uint32_t *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626dy\n", /* 2^64 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint32_t arg[] = { '@', 0 };
+ size_t length;
+ uint32_t *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626llUy\n", /* 2^64 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
}
diff --git a/tests/unistdio/test-u32-printf1.h b/tests/unistdio/test-u32-printf1.h
index ae0edc6a..05cedd07 100644
--- a/tests/unistdio/test-u32-printf1.h
+++ b/tests/unistdio/test-u32-printf1.h
@@ -1,5 +1,5 @@
/* Test of u32_v[a]s[n]printf() function.
- Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -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. */
diff --git a/tests/unistdio/test-u32-vasnprintf1.c b/tests/unistdio/test-u32-vasnprintf1.c
index 43c115cf..e73753ea 100644
--- a/tests/unistdio/test-u32-vasnprintf1.c
+++ b/tests/unistdio/test-u32-vasnprintf1.c
@@ -1,5 +1,5 @@
/* Test of u32_vasnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -71,5 +71,5 @@ int
main (int argc, char *argv[])
{
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u32-vasnprintf2.c b/tests/unistdio/test-u32-vasnprintf2.c
index 1ddab53f..b45fa8ef 100644
--- a/tests/unistdio/test-u32-vasnprintf2.c
+++ b/tests/unistdio/test-u32-vasnprintf2.c
@@ -1,5 +1,5 @@
/* Test of u32_vasnprintf() function in an ISO-8859-1 locale.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -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 *
@@ -115,5 +178,5 @@ main (int argc, char *argv[])
return 1;
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u32-vasnprintf3.c b/tests/unistdio/test-u32-vasnprintf3.c
index cfc4674c..1a73f248 100644
--- a/tests/unistdio/test-u32-vasnprintf3.c
+++ b/tests/unistdio/test-u32-vasnprintf3.c
@@ -1,5 +1,5 @@
/* Test of u32_vasnprintf() function in an UTF-8 locale.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -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 *
@@ -115,5 +178,5 @@ main (int argc, char *argv[])
return 1;
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u32-vasprintf1.c b/tests/unistdio/test-u32-vasprintf1.c
index 3ab5e89c..ac030cd6 100644
--- a/tests/unistdio/test-u32-vasprintf1.c
+++ b/tests/unistdio/test-u32-vasprintf1.c
@@ -1,5 +1,5 @@
/* Test of u32_vasprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -58,5 +58,5 @@ int
main (int argc, char *argv[])
{
test_vasprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u32-vsnprintf1.c b/tests/unistdio/test-u32-vsnprintf1.c
index fa38f8db..94602d85 100644
--- a/tests/unistdio/test-u32-vsnprintf1.c
+++ b/tests/unistdio/test-u32-vsnprintf1.c
@@ -1,5 +1,5 @@
/* Test of u32_vsnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -64,5 +64,5 @@ main (int argc, char *argv[])
{
test_vsnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u32-vsprintf1.c b/tests/unistdio/test-u32-vsprintf1.c
index c857ca71..2fd3b137 100644
--- a/tests/unistdio/test-u32-vsprintf1.c
+++ b/tests/unistdio/test-u32-vsprintf1.c
@@ -1,5 +1,5 @@
/* Test of u32_vsprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -64,5 +64,5 @@ main (int argc, char *argv[])
{
test_vsprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u8-asnprintf1.c b/tests/unistdio/test-u8-asnprintf1.c
index d5d256aa..49ee6134 100644
--- a/tests/unistdio/test-u8-asnprintf1.c
+++ b/tests/unistdio/test-u8-asnprintf1.c
@@ -1,5 +1,5 @@
/* Test of u8_asnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -42,5 +42,5 @@ int
main (int argc, char *argv[])
{
test_asnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u8-asnprintf1.h b/tests/unistdio/test-u8-asnprintf1.h
index f48e2365..90238c8e 100644
--- a/tests/unistdio/test-u8-asnprintf1.h
+++ b/tests/unistdio/test-u8-asnprintf1.h
@@ -1,5 +1,5 @@
/* Test of u8_[v]asnprintf() function.
- Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -54,4 +54,59 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ...
if (result != buf)
free (result);
}
+
+ /* Verify that u8_[v]asnprintf() rejects a width > 2 GiB, < 4 GiB. */
+ {
+ size_t length;
+ uint8_t *s = my_asnprintf (NULL, &length, "x%03000000000dy\n", -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint8_t arg[] = { '@', 0 };
+ size_t length;
+ uint8_t *s = my_asnprintf (NULL, &length, "x%03000000000Uy\n", arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+
+ /* Verify that u8_[v]asnprintf() rejects a width > 4 GiB. */
+ {
+ size_t length;
+ uint8_t *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306dy\n", /* 2^32 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint8_t arg[] = { '@', 0 };
+ size_t length;
+ uint8_t *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306Uy\n", /* 2^32 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ size_t length;
+ uint8_t *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626dy\n", /* 2^64 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint8_t arg[] = { '@', 0 };
+ size_t length;
+ uint8_t *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626Uy\n", /* 2^64 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
}
diff --git a/tests/unistdio/test-u8-printf1.h b/tests/unistdio/test-u8-printf1.h
index 3e8999b6..1dd28469 100644
--- a/tests/unistdio/test-u8-printf1.h
+++ b/tests/unistdio/test-u8-printf1.h
@@ -1,5 +1,5 @@
/* Test of u8_v[a]s[n]printf() function.
- Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -110,6 +110,26 @@ test_xfunction (uint8_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";
+ 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 };
@@ -162,6 +182,28 @@ test_xfunction (uint8_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
+ };
+ 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 };
@@ -214,6 +256,28 @@ test_xfunction (uint8_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
+ };
+ 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. */
diff --git a/tests/unistdio/test-u8-vasnprintf1.c b/tests/unistdio/test-u8-vasnprintf1.c
index 895faa93..2aaf839f 100644
--- a/tests/unistdio/test-u8-vasnprintf1.c
+++ b/tests/unistdio/test-u8-vasnprintf1.c
@@ -1,5 +1,5 @@
/* Test of u8_vasnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -71,5 +71,5 @@ int
main (int argc, char *argv[])
{
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u8-vasnprintf2.c b/tests/unistdio/test-u8-vasnprintf2.c
index 30289688..9fa03988 100644
--- a/tests/unistdio/test-u8-vasnprintf2.c
+++ b/tests/unistdio/test-u8-vasnprintf2.c
@@ -1,5 +1,5 @@
/* Test of u8_vasnprintf() function in an ISO-8859-1 locale.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -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 *
@@ -105,5 +153,5 @@ main (int argc, char *argv[])
return 1;
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u8-vasnprintf3.c b/tests/unistdio/test-u8-vasnprintf3.c
index b5dc9ab6..aab9dfe3 100644
--- a/tests/unistdio/test-u8-vasnprintf3.c
+++ b/tests/unistdio/test-u8-vasnprintf3.c
@@ -1,5 +1,5 @@
/* Test of u8_vasnprintf() function in an UTF-8 locale.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -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;
}
diff --git a/tests/unistdio/test-u8-vasprintf1.c b/tests/unistdio/test-u8-vasprintf1.c
index 611f1395..82512028 100644
--- a/tests/unistdio/test-u8-vasprintf1.c
+++ b/tests/unistdio/test-u8-vasprintf1.c
@@ -1,5 +1,5 @@
/* Test of u8_vasprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -58,5 +58,5 @@ int
main (int argc, char *argv[])
{
test_vasprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u8-vsnprintf1.c b/tests/unistdio/test-u8-vsnprintf1.c
index 5de57fb1..015c1725 100644
--- a/tests/unistdio/test-u8-vsnprintf1.c
+++ b/tests/unistdio/test-u8-vsnprintf1.c
@@ -1,5 +1,5 @@
/* Test of u8_vsnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -64,5 +64,5 @@ main (int argc, char *argv[])
{
test_vsnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-u8-vsprintf1.c b/tests/unistdio/test-u8-vsprintf1.c
index 542cce32..0d846de2 100644
--- a/tests/unistdio/test-u8-vsprintf1.c
+++ b/tests/unistdio/test-u8-vsprintf1.c
@@ -1,5 +1,5 @@
/* Test of u8_vsprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -64,5 +64,5 @@ main (int argc, char *argv[])
{
test_vsprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-ulc-asnprintf1.c b/tests/unistdio/test-ulc-asnprintf1.c
index 236cd3b2..5e40575c 100644
--- a/tests/unistdio/test-ulc-asnprintf1.c
+++ b/tests/unistdio/test-ulc-asnprintf1.c
@@ -1,5 +1,5 @@
/* Test of ulc_asnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
#include "unistdio.h"
+#include <errno.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
@@ -40,5 +41,5 @@ int
main (int argc, char *argv[])
{
test_asnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-ulc-asnprintf1.h b/tests/unistdio/test-ulc-asnprintf1.h
index 9e11f314..0e7e9cff 100644
--- a/tests/unistdio/test-ulc-asnprintf1.h
+++ b/tests/unistdio/test-ulc-asnprintf1.h
@@ -1,5 +1,5 @@
/* Test of ulc_[v]asnprintf() functions.
- Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -51,4 +51,59 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
if (result != buf)
free (result);
}
+
+ /* Verify that ulc_[v]asnprintf() rejects a width > 2 GiB, < 4 GiB. */
+ {
+ size_t length;
+ char *s = my_asnprintf (NULL, &length, "x%03000000000dy\n", -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint8_t arg[] = { '@', 0 };
+ size_t length;
+ char *s = my_asnprintf (NULL, &length, "x%03000000000Uy\n", arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+
+ /* Verify that ulc_[v]asnprintf() rejects a width > 4 GiB. */
+ {
+ size_t length;
+ char *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306dy\n", /* 2^32 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint8_t arg[] = { '@', 0 };
+ size_t length;
+ char *s =
+ my_asnprintf (NULL, &length,
+ "x%04294967306Uy\n", /* 2^32 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ size_t length;
+ char *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626dy\n", /* 2^64 + 10 */
+ -17);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
+ {
+ static const uint8_t arg[] = { '@', 0 };
+ size_t length;
+ char *s =
+ my_asnprintf (NULL, &length,
+ "x%018446744073709551626Uy\n", /* 2^64 + 10 */
+ arg);
+ ASSERT (s == NULL);
+ ASSERT (errno == EOVERFLOW);
+ }
}
diff --git a/tests/unistdio/test-ulc-printf1.h b/tests/unistdio/test-ulc-printf1.h
index 49089c1b..02e0372d 100644
--- a/tests/unistdio/test-ulc-printf1.h
+++ b/tests/unistdio/test-ulc-printf1.h
@@ -1,5 +1,5 @@
/* Test of ulc_v[a]s[n]printf() functions.
- Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/unistdio/test-ulc-vasnprintf1.c b/tests/unistdio/test-ulc-vasnprintf1.c
index d0d6f858..f662f4e9 100644
--- a/tests/unistdio/test-ulc-vasnprintf1.c
+++ b/tests/unistdio/test-ulc-vasnprintf1.c
@@ -1,5 +1,5 @@
/* Test of ulc_vasnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
#include "unistdio.h"
+#include <errno.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
@@ -69,5 +70,5 @@ int
main (int argc, char *argv[])
{
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-ulc-vasnprintf2.c b/tests/unistdio/test-ulc-vasnprintf2.c
index 458ce4aa..5375c8e8 100644
--- a/tests/unistdio/test-ulc-vasnprintf2.c
+++ b/tests/unistdio/test-ulc-vasnprintf2.c
@@ -1,5 +1,5 @@
/* Test of ulc_vasnprintf() function in an ISO-8859-1 locale.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -76,6 +76,16 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
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 */
@@ -124,6 +134,16 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
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 */
@@ -172,6 +192,16 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
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. */
@@ -214,6 +244,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 *
@@ -242,5 +316,5 @@ main (int argc, char *argv[])
return 1;
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-ulc-vasnprintf3.c b/tests/unistdio/test-ulc-vasnprintf3.c
index 717e9850..e71887c8 100644
--- a/tests/unistdio/test-ulc-vasnprintf3.c
+++ b/tests/unistdio/test-ulc-vasnprintf3.c
@@ -1,5 +1,5 @@
/* Test of ulc_vasnprintf() function in an UTF-8 locale.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -72,6 +72,16 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
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 */
@@ -116,6 +126,16 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
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 */
@@ -160,6 +180,16 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
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. */
@@ -202,6 +232,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 *
@@ -230,5 +304,5 @@ main (int argc, char *argv[])
return 1;
test_vasnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-ulc-vasprintf1.c b/tests/unistdio/test-ulc-vasprintf1.c
index c97909cc..3eed14f9 100644
--- a/tests/unistdio/test-ulc-vasprintf1.c
+++ b/tests/unistdio/test-ulc-vasprintf1.c
@@ -1,5 +1,5 @@
/* Test of ulc_vasprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -56,5 +56,5 @@ int
main (int argc, char *argv[])
{
test_vasprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-ulc-vsnprintf1.c b/tests/unistdio/test-ulc-vsnprintf1.c
index 899ad10b..344fd353 100644
--- a/tests/unistdio/test-ulc-vsnprintf1.c
+++ b/tests/unistdio/test-ulc-vsnprintf1.c
@@ -1,5 +1,5 @@
/* Test of ulc_vsnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -57,5 +57,5 @@ main (int argc, char *argv[])
{
test_vsnprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-ulc-vsprintf1.c b/tests/unistdio/test-ulc-vsprintf1.c
index 123397d7..1f8bb8ac 100644
--- a/tests/unistdio/test-ulc-vsprintf1.c
+++ b/tests/unistdio/test-ulc-vsprintf1.c
@@ -1,5 +1,5 @@
/* Test of ulc_vsprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -57,5 +57,5 @@ main (int argc, char *argv[])
{
test_vsprintf ();
- return 0;
+ return test_exit_status;
}
diff --git a/tests/unistdio/test-unistdio-h.c b/tests/unistdio/test-unistdio-h.c
new file mode 100644
index 00000000..b5a085d2
--- /dev/null
+++ b/tests/unistdio/test-unistdio-h.c
@@ -0,0 +1,26 @@
+/* Test of <unistdio.h>.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistdio.h>
+
+int
+main (void)
+{
+ return 0;
+}