diff options
| author | mlimber | 2019-04-26 11:14:33 -0400 |
|---|---|---|
| committer | Martin Hořeňovský | 2019-05-02 21:34:47 +0200 |
| commit | 53a83e855ec5c2a5659dd4ceacf15c00435eeaa6 (patch) | |
| tree | 02b24ca73e7df5dd406984d4408a68677afb8201 /projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp | |
| parent | 9c741fe96073ed620ffc032afbed1f3c789d2b68 (diff) | |
| download | catch3-53a83e855ec5c2a5659dd4ceacf15c00435eeaa6.tar.gz | |
Add support for custom precision in floating point stringification
Closes #1612
Diffstat (limited to 'projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp')
| -rw-r--r-- | projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp b/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp index 09ac3045..bbcc9a66 100644 --- a/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp +++ b/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp @@ -128,6 +128,29 @@ TEST_CASE("String views are stringified like other strings", "[toString][approva #endif +//TEMPLATE_TEST_CASE("Floating-point precision can be set", "[toString][floatingPoint]", float, double) +//{ +// const auto oldPrecision = Catch::StringMaker<TestType>::getPrecision(); +// const auto precision = GENERATE(-1, 0, 3, std::numeric_limits<TestType>::max_digits10); +// const auto expectedLength = unsigned(precision < 0 ? 3 : precision); +// +// CAPTURE( precision ); +// +// if (precision >= 0) +// { +// Catch::StringMaker<TestType>::setPrecision(precision); +// } +// +// // Expected to fail to demonstrate the problem +// const auto str = Catch::StringMaker<TestType>::convert(std::numeric_limits<TestType>::epsilon()); +// CHECK(str.length() >= expectedLength); +// +// if (precision >= 0) +// { +// Catch::StringMaker<TestType>::setPrecision(oldPrecision); +// } +//} + namespace { struct WhatException : std::exception { |