summaryrefslogtreecommitdiff
path: root/tests/lib
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2024-03-10 13:30:46 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2024-03-10 15:29:17 +0100
commit91fdb7366cbe1200ef38b3ce379bffb1ac7aacee (patch)
treed8139608d40b0cc8deea69f48afbd3defe55ccc7 /tests/lib
parentc9170233809c149808389837be754c52b3bbdd74 (diff)
tests: exercise `%w`/`%wf` printfrr modifiers
Added by ISO C23 / N2680, implementation imported from FreeBSD. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/test_printfrr.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/lib/test_printfrr.c b/tests/lib/test_printfrr.c
index 66699ec7c0..cefa07ec73 100644
--- a/tests/lib/test_printfrr.c
+++ b/tests/lib/test_printfrr.c
@@ -143,6 +143,8 @@ int main(int argc, char **argv)
NAN,
};
uint64_t ui64 = 0xfeed1278cafef00d;
+ uint16_t i16 = -23456;
+ int_fast8_t if8 = 123;
struct in_addr ip;
char *p;
char buf[256];
@@ -169,6 +171,16 @@ int main(int argc, char **argv)
FMT_NSTD(printchk("11110000000011111010010111000011", "%b", 0xf00fa5c3));
FMT_NSTD(printchk("0b01011010", "%#010b", 0x5a));
+/* FMT_NSTD is conditional on the frr-format plugin being NOT enabled.
+ * However, the frr-format plugin does not support %wd/%wfd yet, so this needs
+ * to be unconditional.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat"
+ printchk("123 -23456 feed1278cafef00d 9876", "%wf8d %w16d %w64x %d",
+ if8, i16, ui64, 9876);
+#pragma GCC diagnostic pop
+
inet_aton("192.168.1.2", &ip);
printchk("192.168.1.2", "%pI4", &ip);
printchk(" 192.168.1.2", "%20pI4", &ip);