mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 05:45:39 +02:00
Default StringMaker<FloatingPointType>::precision to max_digits10
`max_digits10` is the number of decimal digits that the type _can_ represent, in other words, the number of decimal digits needed to disambiguate any two floating point numbers when serialized to a string.
This commit is contained in:
@@ -124,8 +124,8 @@ TEST_CASE("Precision of floating point stringification can be set", "[toString][
|
||||
const auto oldPrecision = sm::precision;
|
||||
|
||||
const float testFloat = 1.12345678901234567899f;
|
||||
auto str1 = sm::convert(testFloat);
|
||||
sm::precision = 5;
|
||||
auto str1 = sm::convert( testFloat );
|
||||
// "1." prefix = 2 chars, f suffix is another char
|
||||
CHECK(str1.size() == 3 + 5);
|
||||
|
||||
|
@@ -29,8 +29,8 @@ TEST_CASE( "tuple<int>", "[toString][tuple]" )
|
||||
TEST_CASE( "tuple<float,int>", "[toString][tuple]" )
|
||||
{
|
||||
typedef std::tuple<float,int> type;
|
||||
CHECK( "1.2f" == ::Catch::Detail::stringify(float(1.2)) );
|
||||
CHECK( "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) );
|
||||
CHECK( "1.5f" == ::Catch::Detail::stringify(float(1.5)) );
|
||||
CHECK( "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) );
|
||||
}
|
||||
|
||||
TEST_CASE( "tuple<string,string>", "[toString][tuple]" )
|
||||
@@ -42,8 +42,8 @@ TEST_CASE( "tuple<string,string>", "[toString][tuple]" )
|
||||
TEST_CASE( "tuple<tuple<int>,tuple<>,float>", "[toString][tuple]" )
|
||||
{
|
||||
typedef std::tuple<std::tuple<int>,std::tuple<>,float> type;
|
||||
type value { std::tuple<int>{42}, {}, 1.2f };
|
||||
CHECK( "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) );
|
||||
type value { std::tuple<int>{42}, {}, 1.5f };
|
||||
CHECK( "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) );
|
||||
}
|
||||
|
||||
TEST_CASE( "tuple<nullptr,int,const char *>", "[approvals][toString][tuple]" ) {
|
||||
|
Reference in New Issue
Block a user