[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
*printf-posix-tests: Strengthen tests
From: |
Bruno Haible |
Subject: |
*printf-posix-tests: Strengthen tests |
Date: |
Sun, 30 Jun 2024 15:55:49 +0200 |
Since 2023-03-22, Gnulib implements the %b directive in the *printf-posix
modules. This patch updates some unit tests to also test the %b directive.
2024-06-30 Bruno Haible <bruno@clisp.org>
*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.
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- *printf-posix-tests: Strengthen tests,
Bruno Haible <=