diff options
author | Werner Koch <[email protected]> | 2025-08-14 15:03:22 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2025-08-14 15:04:08 +0000 |
commit | 6ac5332e4f6988112f4272cfe7a2eee31173ff3f (patch) | |
tree | 8029968512906204b183ad546c70ec7999bc0fc0 /tests | |
parent | Set build specific variable for zOS (diff) | |
download | libgpg-error-master.tar.gz libgpg-error-master.zip |
* src/estream-printf.c (CONSSPEC_BIN): New.
(compute_type): Handle it.
(parse_format): Support 'b'.
(do_format): Divert 'b' to pr_integer.
(pr_integer): Print binary format.
* tests/t-printf.c (check_fprintf_sf): Add two simple testcases.
--
Might be handy in some cases and is easy to implement. Minor drawback
is that this increases a stack based buffer from 100 to 150 bytes.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/t-printf.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/t-printf.c b/tests/t-printf.c index 87c201d..eb54750 100644 --- a/tests/t-printf.c +++ b/tests/t-printf.c @@ -486,6 +486,32 @@ check_fprintf_sf (void) } free (result); + gpgrt_fprintf_sf (stream, string_filter, &sfstate, + "a=%x b=%b c=%X", + 19410909u, 19410909u, 19410909u); + expect = "a=1282fdd b=1001010000010111111011101 c=1282FDD"; + result = stream_to_string (stream); + if (strcmp (result, expect)) + { + show ("expect: '%s'\n", expect); + show ("result: '%s'\n", result); + fail ("fprintf_sf failed at %d\n", __LINE__); + } + free (result); + + gpgrt_fprintf_sf (stream, string_filter, &sfstate, + "a=%#x b=%#b c=%#X", + 19420130u, 19420130u, 19420130u); + expect = "a=0x12853e2 b=0b1001010000101001111100010 c=0X12853E2"; + result = stream_to_string (stream); + if (strcmp (result, expect)) + { + show ("expect: '%s'\n", expect); + show ("result: '%s'\n", result); + fail ("fprintf_sf failed at %d\n", __LINE__); + } + free (result); + gpgrt_fclose (stream); } |