Skip to content

Commit

Permalink
Regards #93: Added testcases for %f and %e with large integral pa…
Browse files Browse the repository at this point in the history
…rt values.
  • Loading branch information
eyalroz committed Feb 11, 2022
1 parent fac5fc7 commit 2ced80a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/test_suite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,15 @@ TEST_CASE("float", "[]" ) {
PRINTING_CHECK("3.1415", ==, sprintf_, buffer, "%.4f", 3.1415354);
PRINTING_CHECK("30343.142", ==, sprintf_, buffer, "%.3f", 30343.1415354);

PRINTING_CHECK("2.1474836470e+09", ==, sprintf_, buffer, "%.10f", 2147483647.0); // 2^31 - 1
PRINTING_CHECK("2.1474836480e+09", ==, sprintf_, buffer, "%.10f", 2147483648.0); // 2^31
PRINTING_CHECK("4.2949672950e+09", ==, sprintf_, buffer, "%.10f", 4294967295.0); // 2^32 - 1
PRINTING_CHECK("4.2949672960e+09", ==, sprintf_, buffer, "%.10f", 4294967296.0); // 2^32
PRINTING_CHECK("2147483647", ==, sprintf_, buffer, "%.10g", 2147483647.0); // 2^31 - 1
PRINTING_CHECK("2147483648", ==, sprintf_, buffer, "%.10g", 2147483648.0); // 2^31
PRINTING_CHECK("4294967295", ==, sprintf_, buffer, "%.10g", 4294967295.0); // 2^32 - 1
PRINTING_CHECK("4294967296", ==, sprintf_, buffer, "%.10g", 4294967296.0); // 2^32

// switch from decimal to exponential representation
//
CAPTURE_AND_PRINT(sprintf_, buffer, "%.0f", (double) ((int64_t)1 * 1000 ) );
Expand Down

0 comments on commit 2ced80a

Please sign in to comment.