]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: exercise `%w`/`%wf` printfrr modifiers
authorDavid Lamparter <equinox@opensourcerouting.org>
Sun, 10 Mar 2024 12:30:46 +0000 (13:30 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Sun, 10 Mar 2024 14:29:17 +0000 (15:29 +0100)
Added by ISO C23 / N2680, implementation imported from FreeBSD.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
tests/lib/test_printfrr.c

index 66699ec7c056d4bc4e83496a11150e3306851cbb..cefa07ec7323aff373040aa69f67acbca30c6790 100644 (file)
@@ -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);