Mercurial > hg > th-libs
changeset 331:6e42d50c08c4
Add tests for 64bit int prints.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 23 Feb 2016 12:55:45 +0200 |
parents | b2c4b0b4d44f |
children | 799e38f867da |
files | tests.c |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tests.c Tue Feb 23 12:55:09 2016 +0200 +++ b/tests.c Tue Feb 23 12:55:45 2016 +0200 @@ -318,6 +318,25 @@ } } + if (test_set_start("printf() integer 64bit")) + { + int64_t i_vals[] = { 0, -0, -1, 2, -2, 612342, -612342, 0x3342344341fff, 0x1f8000000, }; + char *i_fmts[] = { "%", "%05", "%5", "%-5", "%.5", "%5.5", "%05.5", "% ", "% 3", "% 3.2", "%+3", }; + char *i_types[] = { "d", "x", "X", "o", }; + + for (i1 = 0; i1 < NCOUNT(i_vals); i1++) + { + snprintf(buf, sizeof(buf), "%lld", i_vals[i1]); + + for (i3 = 0; i3 < sizeof(i_types) / sizeof(i_types[0]); i3++) + for (i2 = 0; i2 < sizeof(i_fmts) / sizeof(i_fmts[0]); i2++) + { + snprintf(buf2, sizeof(buf2), "%sll%s", i_fmts[i2], i_types[i3]); + test_snprintf(buf, buf2, i_vals[i1]); + } + } + } + if (test_set_start("printf() float")) { double f_vals[] = { 2.02, 612342.234, -2.07, -612342.12, 437692.9876543219, 0x1fff, 0x8000000, };