mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
Add support for custom precision in floating point stringification
Closes #1612
This commit is contained in:

committed by
Martin Hořeňovský

parent
9c741fe960
commit
53a83e855e
@@ -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 {
|
||||
|
Reference in New Issue
Block a user