diff options
-rw-r--r-- | snprintf.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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; } |