From 1aa60fada9c925068507f202d7ab63217c6275d1 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 19 Dec 2013 18:41:55 +0000 Subject: [PATCH] Changed Approx::toString() to be implemented in terms of toString( double ) (as proposed in #233) --- include/internal/catch_approx.hpp | 2 +- .../Baselines/console.std.approved.txt | 12 +++--- .../Baselines/console.sw.approved.txt | 40 ++++++++++--------- .../Baselines/console.swa4.approved.txt | 20 ++++++---- .../SelfTest/Baselines/junit.sw.approved.txt | 12 +++--- .../SelfTest/Baselines/xml.sw.approved.txt | 40 +++++++++---------- 6 files changed, 67 insertions(+), 59 deletions(-) diff --git a/include/internal/catch_approx.hpp b/include/internal/catch_approx.hpp index 67dba619..4370ab3e 100644 --- a/include/internal/catch_approx.hpp +++ b/include/internal/catch_approx.hpp @@ -70,7 +70,7 @@ namespace Detail { std::string toString() const { std::ostringstream oss; - oss << "Approx( " << m_value << " )"; + oss << "Approx( " << Catch::toString( m_value ) << " )"; return oss.str(); } diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 422f0fc2..52b4db55 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -49,22 +49,22 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 9.11f ) ) with expansion: - 9.1 == Approx( 9.11 ) + 9.1 == Approx( 9.1099996567 ) ConditionTests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 9.0f ) ) with expansion: - 9.1 == Approx( 9 ) + 9.1 == Approx( 9.0 ) ConditionTests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 1 ) ) with expansion: - 9.1 == Approx( 1 ) + 9.1 == Approx( 1.0 ) ConditionTests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 0 ) ) with expansion: - 9.1 == Approx( 0 ) + 9.1 == Approx( 0.0 ) ConditionTests.cpp:: FAILED: CHECK( data.double_pi == Approx( 3.1415 ) ) @@ -110,12 +110,12 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK( data.float_nine_point_one != Approx( 9.1f ) ) with expansion: - 9.1 != Approx( 9.1 ) + 9.1 != Approx( 9.1000003815 ) ConditionTests.cpp:: FAILED: CHECK( data.double_pi != Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 != Approx( 3.14159 ) + 3.1415926535 != Approx( 3.1415926535 ) ConditionTests.cpp:: FAILED: CHECK( data.str_hello != "hello" ) diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 792004c9..81ee03db 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -73,13 +73,13 @@ ApproxTests.cpp:: PASSED: REQUIRE( 1.23f == Approx( 1.23f ) ) with expansion: - 1.23 == Approx( 1.23 ) + 1.23 == Approx( 1.2300000191 ) ApproxTests.cpp:: PASSED: REQUIRE( 0.0f == Approx( 0.0f ) ) with expansion: - 0 == Approx( 0 ) + 0 == Approx( 0.0 ) ------------------------------------------------------------------------------- Approximate comparisons with ints @@ -90,10 +90,14 @@ ApproxTests.cpp: ApproxTests.cpp:: PASSED: REQUIRE( 1 == Approx( 1 ) ) +with expansion: + 1 == Approx( 1.0 ) ApproxTests.cpp:: PASSED: REQUIRE( 0 == Approx( 0 ) ) +with expansion: + 0 == Approx( 0.0 ) ------------------------------------------------------------------------------- Approximate comparisons with mixed numeric types @@ -105,19 +109,19 @@ ApproxTests.cpp:: PASSED: REQUIRE( 1.0f == Approx( 1 ) ) with expansion: - 1 == Approx( 1 ) + 1 == Approx( 1.0 ) ApproxTests.cpp:: PASSED: REQUIRE( 0 == Approx( dZero) ) with expansion: - 0 == Approx( 0 ) + 0 == Approx( 0.0 ) ApproxTests.cpp:: PASSED: REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) ) with expansion: - 0 == Approx( 1e-05 ) + 0 == Approx( 0.00001 ) ApproxTests.cpp:: PASSED: @@ -129,7 +133,7 @@ ApproxTests.cpp:: PASSED: REQUIRE( dMedium == Approx( 1.234f ) ) with expansion: - 1.234 == Approx( 1.234 ) + 1.234 == Approx( 1.2339999676 ) ------------------------------------------------------------------------------- Use a custom approx @@ -265,13 +269,13 @@ ConditionTests.cpp:: PASSED: REQUIRE( data.float_nine_point_one == Approx( 9.1f ) ) with expansion: - 9.1 == Approx( 9.1 ) + 9.1 == Approx( 9.1000003815 ) ConditionTests.cpp:: PASSED: REQUIRE( data.double_pi == Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 == Approx( 3.14159 ) + 3.1415926535 == Approx( 3.1415926535 ) ConditionTests.cpp:: PASSED: @@ -321,22 +325,22 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 9.11f ) ) with expansion: - 9.1 == Approx( 9.11 ) + 9.1 == Approx( 9.1099996567 ) ConditionTests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 9.0f ) ) with expansion: - 9.1 == Approx( 9 ) + 9.1 == Approx( 9.0 ) ConditionTests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 1 ) ) with expansion: - 9.1 == Approx( 1 ) + 9.1 == Approx( 1.0 ) ConditionTests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 0 ) ) with expansion: - 9.1 == Approx( 0 ) + 9.1 == Approx( 0.0 ) ConditionTests.cpp:: FAILED: CHECK( data.double_pi == Approx( 3.1415 ) ) @@ -390,25 +394,25 @@ ConditionTests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 9.11f ) ) with expansion: - 9.1 != Approx( 9.11 ) + 9.1 != Approx( 9.1099996567 ) ConditionTests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 9.0f ) ) with expansion: - 9.1 != Approx( 9 ) + 9.1 != Approx( 9.0 ) ConditionTests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 1 ) ) with expansion: - 9.1 != Approx( 1 ) + 9.1 != Approx( 1.0 ) ConditionTests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 0 ) ) with expansion: - 9.1 != Approx( 0 ) + 9.1 != Approx( 0.0 ) ConditionTests.cpp:: PASSED: @@ -454,12 +458,12 @@ with expansion: ConditionTests.cpp:: FAILED: CHECK( data.float_nine_point_one != Approx( 9.1f ) ) with expansion: - 9.1 != Approx( 9.1 ) + 9.1 != Approx( 9.1000003815 ) ConditionTests.cpp:: FAILED: CHECK( data.double_pi != Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 != Approx( 3.14159 ) + 3.1415926535 != Approx( 3.1415926535 ) ConditionTests.cpp:: FAILED: CHECK( data.str_hello != "hello" ) diff --git a/projects/SelfTest/Baselines/console.swa4.approved.txt b/projects/SelfTest/Baselines/console.swa4.approved.txt index 65a96d7d..e701d91a 100644 --- a/projects/SelfTest/Baselines/console.swa4.approved.txt +++ b/projects/SelfTest/Baselines/console.swa4.approved.txt @@ -73,13 +73,13 @@ ApproxTests.cpp:: PASSED: REQUIRE( 1.23f == Approx( 1.23f ) ) with expansion: - 1.23 == Approx( 1.23 ) + 1.23 == Approx( 1.2300000191 ) ApproxTests.cpp:: PASSED: REQUIRE( 0.0f == Approx( 0.0f ) ) with expansion: - 0 == Approx( 0 ) + 0 == Approx( 0.0 ) ------------------------------------------------------------------------------- Approximate comparisons with ints @@ -90,10 +90,14 @@ ApproxTests.cpp: ApproxTests.cpp:: PASSED: REQUIRE( 1 == Approx( 1 ) ) +with expansion: + 1 == Approx( 1.0 ) ApproxTests.cpp:: PASSED: REQUIRE( 0 == Approx( 0 ) ) +with expansion: + 0 == Approx( 0.0 ) ------------------------------------------------------------------------------- Approximate comparisons with mixed numeric types @@ -105,19 +109,19 @@ ApproxTests.cpp:: PASSED: REQUIRE( 1.0f == Approx( 1 ) ) with expansion: - 1 == Approx( 1 ) + 1 == Approx( 1.0 ) ApproxTests.cpp:: PASSED: REQUIRE( 0 == Approx( dZero) ) with expansion: - 0 == Approx( 0 ) + 0 == Approx( 0.0 ) ApproxTests.cpp:: PASSED: REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) ) with expansion: - 0 == Approx( 1e-05 ) + 0 == Approx( 0.00001 ) ApproxTests.cpp:: PASSED: @@ -129,7 +133,7 @@ ApproxTests.cpp:: PASSED: REQUIRE( dMedium == Approx( 1.234f ) ) with expansion: - 1.234 == Approx( 1.234 ) + 1.234 == Approx( 1.2339999676 ) ------------------------------------------------------------------------------- Use a custom approx @@ -265,13 +269,13 @@ ConditionTests.cpp:: PASSED: REQUIRE( data.float_nine_point_one == Approx( 9.1f ) ) with expansion: - 9.1 == Approx( 9.1 ) + 9.1 == Approx( 9.1000003815 ) ConditionTests.cpp:: PASSED: REQUIRE( data.double_pi == Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 == Approx( 3.14159 ) + 3.1415926535 == Approx( 3.1415926535 ) ConditionTests.cpp:: PASSED: diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 5dd37bd7..e28449ca 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -30,16 +30,16 @@ ConditionTests.cpp: ConditionTests.cpp: - + ConditionTests.cpp: - + ConditionTests.cpp: - + ConditionTests.cpp: - + ConditionTests.cpp: @@ -66,10 +66,10 @@ ConditionTests.cpp: ConditionTests.cpp: - + ConditionTests.cpp: - + ConditionTests.cpp: diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index dda010b1..9bebc628 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -76,7 +76,7 @@ 1.23f == Approx( 1.23f ) - 1.23 == Approx( 1.23 ) + 1.23 == Approx( 1.2300000191 ) @@ -84,7 +84,7 @@ 0.0f == Approx( 0.0f ) - 0 == Approx( 0 ) + 0 == Approx( 0.0 ) @@ -95,7 +95,7 @@ 1 == Approx( 1 ) - 1 == Approx( 1 ) + 1 == Approx( 1.0 ) @@ -103,7 +103,7 @@ 0 == Approx( 0 ) - 0 == Approx( 0 ) + 0 == Approx( 0.0 ) @@ -114,7 +114,7 @@ 1.0f == Approx( 1 ) - 1 == Approx( 1 ) + 1 == Approx( 1.0 ) @@ -122,7 +122,7 @@ 0 == Approx( dZero) - 0 == Approx( 0 ) + 0 == Approx( 0.0 ) @@ -130,7 +130,7 @@ 0 == Approx( dSmall ).epsilon( 0.001 ) - 0 == Approx( 1e-05 ) + 0 == Approx( 0.00001 ) @@ -146,7 +146,7 @@ dMedium == Approx( 1.234f ) - 1.234 == Approx( 1.234 ) + 1.234 == Approx( 1.2339999676 ) @@ -295,7 +295,7 @@ data.float_nine_point_one == Approx( 9.1f ) - 9.1 == Approx( 9.1 ) + 9.1 == Approx( 9.1000003815 ) @@ -303,7 +303,7 @@ data.double_pi == Approx( 3.1415926535 ) - 3.1415926535 == Approx( 3.14159 ) + 3.1415926535 == Approx( 3.1415926535 ) @@ -370,7 +370,7 @@ data.float_nine_point_one == Approx( 9.11f ) - 9.1 == Approx( 9.11 ) + 9.1 == Approx( 9.1099996567 ) @@ -378,7 +378,7 @@ data.float_nine_point_one == Approx( 9.0f ) - 9.1 == Approx( 9 ) + 9.1 == Approx( 9.0 ) @@ -386,7 +386,7 @@ data.float_nine_point_one == Approx( 1 ) - 9.1 == Approx( 1 ) + 9.1 == Approx( 1.0 ) @@ -394,7 +394,7 @@ data.float_nine_point_one == Approx( 0 ) - 9.1 == Approx( 0 ) + 9.1 == Approx( 0.0 ) @@ -469,7 +469,7 @@ data.float_nine_point_one != Approx( 9.11f ) - 9.1 != Approx( 9.11 ) + 9.1 != Approx( 9.1099996567 ) @@ -477,7 +477,7 @@ data.float_nine_point_one != Approx( 9.0f ) - 9.1 != Approx( 9 ) + 9.1 != Approx( 9.0 ) @@ -485,7 +485,7 @@ data.float_nine_point_one != Approx( 1 ) - 9.1 != Approx( 1 ) + 9.1 != Approx( 1.0 ) @@ -493,7 +493,7 @@ data.float_nine_point_one != Approx( 0 ) - 9.1 != Approx( 0 ) + 9.1 != Approx( 0.0 ) @@ -552,7 +552,7 @@ data.float_nine_point_one != Approx( 9.1f ) - 9.1 != Approx( 9.1 ) + 9.1 != Approx( 9.1000003815 ) @@ -560,7 +560,7 @@ data.double_pi != Approx( 3.1415926535 ) - 3.1415926535 != Approx( 3.14159 ) + 3.1415926535 != Approx( 3.1415926535 )