Skip to content

Commit

Permalink
Added a testcase check exposing issue #120 - and corrected the expect…
Browse files Browse the repository at this point in the history
…ed output in two other testcase, which was indeed what the library was producing, but is invalid ("%e" output with a two-digit integral part).
  • Loading branch information
eyalroz committed Aug 4, 2021
1 parent 6efee1a commit 7a9953e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/test_suite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,15 +770,15 @@ TEST_CASE("float", "[]" ) {

CAPTURE_AND_PRINT(test::sprintf_, buffer, "%.0f", (double) ((int64_t)1 * 1000 * 1000 * 1000 * 1000) );
if (PRINTF_FLOAT_NOTATION_THRESHOLD < 10e+11) {
CHECK(!strcmp(buffer, "10e+11"));
CHECK(!strcmp(buffer, "1e+12"));
}
else {
CHECK(!strcmp(buffer, "1000000000000"));
}

CAPTURE_AND_PRINT(test::sprintf_, buffer, "%.0f", (double) ((int64_t)1 * 1000 * 1000 * 1000 * 1000 * 1000) );
if (PRINTF_FLOAT_NOTATION_THRESHOLD < 10e+14) {
CHECK(!strcmp(buffer, "10e+14"));
CHECK(!strcmp(buffer, "1e+15"));
}
else {
CHECK(!strcmp(buffer, "1000000000000000"));
Expand Down Expand Up @@ -826,6 +826,7 @@ TEST_CASE("float", "[]" ) {
PRINTING_CHECK("+001.234e-05", ==, test::sprintf_, buffer, "%+012.4g", 0.00001234);
PRINTING_CHECK("-1.23e-308", ==, test::sprintf_, buffer, "%.3g", -1.2345e-308);
PRINTING_CHECK("+1.230E+308", ==, test::sprintf_, buffer, "%+.3E", 1.23e+308);
PRINTING_CHECK("1.000e+01", ==, test::sprintf_, buffer, "%.3e", 9.9996);
#endif

// out of range for float: should switch to exp notation if supported, else empty
Expand Down

0 comments on commit 7a9953e

Please sign in to comment.