diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-10-01 17:01:29 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-10-09 17:53:23 +0200 |
commit | 759b204be33fa8485c9e28038ee029a49e2e9d3f (patch) | |
tree | c590185bee7022f9bc3944314f578ce141f0fa32 /lib/printf_test.c | |
parent | cc95b4594ac924b40325a4f1adcae5312179db40 (diff) |
Lib: Support for 64-bit numbers in bvsnprintf()
Use 'l' for s64/u64 instead of for long/ulong, as that is much more
useful. Also make number() correct with regard to signed/unsigned
typecasts.
Diffstat (limited to 'lib/printf_test.c')
-rw-r--r-- | lib/printf_test.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/printf_test.c b/lib/printf_test.c index 341fde9c..47ea905d 100644 --- a/lib/printf_test.c +++ b/lib/printf_test.c @@ -45,7 +45,7 @@ t_simple(void) else BSPRINTF(16, "00000fee1a15600d", buf, "%p", (void *) 0xfee1a15600d); - long ln = 0; + s64 ln = 0; BSPRINTF(10, "TeStStRiNg", buf, "TeStS%lntRiNg", &ln); bt_assert_msg(ln == 5, "fmt=\"TeStS%%lntRiNg\", &ln makes ln=%ld, want 5", ln); @@ -54,7 +54,19 @@ t_simple(void) BSPRINTF(2, "+1", buf, "%+d", 1); BSPRINTF(2, " 1", buf, "% d", 1); BSPRINTF(2, "-1", buf, "%d", -1); - BSPRINTF(11, "-2147483648", buf, "%d", -2147483648); + BSPRINTF(11, "-2147483648", buf, "%d", INT32_MIN); + BSPRINTF(10, "2147483647", buf, "%d", INT32_MAX); + + BSPRINTF(1, "0", buf, "%u", 0x0); + BSPRINTF(10, "4294967295", buf, "%u", 0xFFFFFFFF); + + BSPRINTF(4, "-100", buf, "%ld", (s64) -100); + BSPRINTF(3, "100", buf, "%ld", (s64) 100); + BSPRINTF(20, "-9223372036854775808", buf, "%ld", INT64_MIN); + BSPRINTF(19, "9223372036854775807", buf, "%ld", INT64_MAX); + + BSPRINTF(3, "0 8", buf, "%lu %lu", U64(0), U64(8)); + BSPRINTF(20, "18446744073709551615", buf, "%lu", UINT64_MAX); return 1; } |