From ee180cdbb990ce88b9c9589669df881ec89a3ec1 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 30 Jun 2024 15:47:39 +0200 Subject: [PATCH] *printf-posix-tests: Strengthen tests. * tests/test-fprintf-posix.h (test_function): Test %b directive. * tests/test-printf-posix.h (test_function): Likewise. * tests/test-dprintf-posix.c (test_function): Likewise. * tests/test-printf-posix.output: Update expected test result. --- ChangeLog | 8 ++++++++ tests/test-dprintf-posix.c | 6 ++++++ tests/test-fprintf-posix.h | 6 ++++++ tests/test-printf-posix.h | 6 ++++++ tests/test-printf-posix.output | 1 + 5 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index dc1148d408..e240a5fb63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-06-30 Bruno Haible + + *printf-posix-tests: Strengthen tests. + * tests/test-fprintf-posix.h (test_function): Test %b directive. + * tests/test-printf-posix.h (test_function): Likewise. + * tests/test-dprintf-posix.c (test_function): Likewise. + * tests/test-printf-posix.output: Update expected test result. + 2024-06-30 Bruno Haible *printf-{posix,gnu}: Tweak module descriptions. diff --git a/tests/test-dprintf-posix.c b/tests/test-dprintf-posix.c index 83c1587daf..4d952baa99 100644 --- a/tests/test-dprintf-posix.c +++ b/tests/test-dprintf-posix.c @@ -159,6 +159,12 @@ test_function (int (*my_dprintf) (int, const char *, ...)) /* Precision with rounding. */ my_dprintf (fileno (stdout), "%.2LF %d\n", 999.996L, 33, 44, 55); + /* Test the support of the %b format directive. */ + + /* This test would fail on glibc 2.34, musl libc, macOS 14, + FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4. */ + my_dprintf (fileno (stdout), "%b %d\n", 12345, 33, 44, 55); + /* Test the support of the POSIX/XSI format strings with positions. */ my_dprintf (fileno (stdout), "%2$d %1$d\n", 33, 55); diff --git a/tests/test-fprintf-posix.h b/tests/test-fprintf-posix.h index d36305b145..b5d023ff5b 100644 --- a/tests/test-fprintf-posix.h +++ b/tests/test-fprintf-posix.h @@ -147,6 +147,12 @@ test_function (int (*my_fprintf) (FILE *, const char *, ...)) /* Precision with rounding. */ my_fprintf (stdout, "%.2LF %d\n", 999.996L, 33, 44, 55); + /* Test the support of the %b format directive. */ + + /* This test would fail on glibc 2.34, musl libc, macOS 14, + FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4. */ + my_fprintf (stdout, "%b %d\n", 12345, 33, 44, 55); + /* Test the support of the POSIX/XSI format strings with positions. */ my_fprintf (stdout, "%2$d %1$d\n", 33, 55); diff --git a/tests/test-printf-posix.h b/tests/test-printf-posix.h index f1cb735c9c..acb4e82b26 100644 --- a/tests/test-printf-posix.h +++ b/tests/test-printf-posix.h @@ -149,6 +149,12 @@ test_function (int (*my_printf) (const char *, ...)) /* Precision with rounding. */ my_printf ("%.2LF %d\n", 999.996L, 33, 44, 55); + /* Test the support of the %b format directive. */ + + /* This test would fail on glibc 2.34, musl libc, macOS 14, + FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4. */ + my_printf ("%b %d\n", 12345, 33, 44, 55); + /* Test the support of the POSIX/XSI format strings with positions. */ my_printf ("%2$d %1$d\n", 33, 55); diff --git a/tests/test-printf-posix.output b/tests/test-printf-posix.output index 618825bb7b..f60eda473a 100644 --- a/tests/test-printf-posix.output +++ b/tests/test-printf-posix.output @@ -37,4 +37,5 @@ inf 33 1234 33 999.95 33 1000.00 33 +11000000111001 33 55 33 -- 2.39.5