Skip to content

Commit

Permalink
tests: exercise %w/%wf printfrr modifiers
Browse files Browse the repository at this point in the history
Added by ISO C23 / N2680, implementation imported from FreeBSD.

Signed-off-by: David Lamparter <[email protected]>
  • Loading branch information
eqvinox committed Mar 10, 2024
1 parent dd2592a commit 7fa1c23
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/lib/test_printfrr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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);
Expand Down

0 comments on commit 7fa1c23

Please sign in to comment.