From eb42b402487fa04778b62775fa200e35693fe59e Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 14 Apr 2011 21:12:56 -0400 Subject: some new floating point printf tests, including one musl fails --- snprintf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/snprintf.c b/snprintf.c index ea28e18..79ec1cc 100644 --- a/snprintf.c +++ b/snprintf.c @@ -66,6 +66,9 @@ static const struct { { "%f", 1.3, "1.300000" }, { "%f", 1.4, "1.400000" }, { "%f", 1.5, "1.500000" }, + { "%.4f", 1.06125, "1.0612" }, + { "%.2f", 1.375, "1.38" }, + { "%.1f", 1.375, "1.4" }, /* correctness in DBL_DIG places */ { "%.15g", 1.23456789012345, "1.23456789012345" }, @@ -77,6 +80,10 @@ static const struct { { "%g", 1234567, "1.23457e+06" }, { "%.7g", 1234567, "1234567" }, { "%.7g", 12345678, "1.234568e+07" }, + { "%.8g", 0.1, "0.1" }, + { "%.9g", 0.1, "0.1" }, + { "%.10g", 0.1, "0.1" }, + { "%.11g", 0.1, "0.1" }, /* pi in double precision, printed to a few extra places */ { "%.15f", M_PI, "3.141592653589793" }, @@ -134,5 +141,7 @@ int test_snprintf(void) TEST_S(b, fp_tests[j].expect, "bad floating point conversion"); } + TEST(i, snprintf(0, 0, "%.4a", 1.0), 11, "%d != %d"); + return err; } -- cgit v1.2.1