From 6ed74b5cab3d8cfb2e474b2da1cad70e52cbb3b8 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Wed, 20 May 2015 18:28:22 +0100 Subject: [PATCH] changed hex threshold on ints to 255 - and print it in *addition* to the decimal form --- include/internal/catch_tostring.hpp | 14 ++++++-------- .../SelfTest/Baselines/console.sw.approved.txt | 18 ++++++++++-------- .../SelfTest/Baselines/xml.sw.approved.txt | 18 ++++++++++-------- projects/SelfTest/ToStringVector.cpp | 8 ++++---- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp index c4b3f152..60f8f823 100644 --- a/include/internal/catch_tostring.hpp +++ b/include/internal/catch_tostring.hpp @@ -98,19 +98,17 @@ std::string toString( wchar_t* const value ) std::string toString( int value ) { std::ostringstream oss; - if( value > 8192 ) - oss << "0x" << std::hex << value; - else - oss << value; + oss << value; + if( value >= 255 ) + oss << " (0x" << std::hex << value << ")"; return oss.str(); } std::string toString( unsigned long value ) { std::ostringstream oss; - if( value > 8192 ) - oss << "0x" << std::hex << value; - else - oss << value; + oss << value; + if( value >= 255 ) + oss << " (0x" << std::hex << value << ")"; return oss.str(); } diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index c1045455..744fab67 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -846,7 +846,9 @@ ConditionTests.cpp:: PASSED: REQUIRE( (std::numeric_limits::max)() > ul ) with expansion: - 0x > 4 + 18446744073709551615 (0x) + > + 4 ------------------------------------------------------------------------------- comparisons between int variables @@ -3398,7 +3400,7 @@ MiscTests.cpp:: PASSED: REQUIRE( Factorial(10) == 3628800 ) with expansion: - 0x == 0x + 3628800 (0x) == 3628800 (0x) ------------------------------------------------------------------------------- An empty test with no assertions @@ -5827,7 +5829,7 @@ TrickyTests.cpp:: PASSED: REQUIRE( 0x == o ) with expansion: - 0x == {?} + 3221225472 (0x) == {?} ------------------------------------------------------------------------------- Demonstrate that a non-const == is not used @@ -5851,7 +5853,7 @@ TrickyTests.cpp:: PASSED: REQUIRE( 0x == bit30and31 ) with expansion: - 0x == 3221225472 + 3221225472 (0x) == 3221225472 ------------------------------------------------------------------------------- boolean member @@ -6308,9 +6310,9 @@ with expansion: ToStringVector.cpp:: PASSED: - REQUIRE( Catch::toString(vv) == "{ 42, 512 }" ) + REQUIRE( Catch::toString(vv) == "{ 42, 250 }" ) with expansion: - "{ 42, 512 }" == "{ 42, 512 }" + "{ 42, 250 }" == "{ 42, 250 }" ------------------------------------------------------------------------------- vector -> toString @@ -6358,9 +6360,9 @@ with expansion: ToStringVector.cpp:: PASSED: - REQUIRE( Catch::toString(vv) == "{ 42, 512 }" ) + REQUIRE( Catch::toString(vv) == "{ 42, 250 }" ) with expansion: - "{ 42, 512 }" == "{ 42, 512 }" + "{ 42, 250 }" == "{ 42, 250 }" ------------------------------------------------------------------------------- vec> -> toString diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 4d14a677..c0a75b73 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -1063,7 +1063,9 @@ (std::numeric_limits<unsigned long>::max)() > ul - 0x > 4 + 18446744073709551615 (0x) +> +4 @@ -3519,7 +3521,7 @@ Factorial(10) == 3628800 - 0x == 0x + 3628800 (0x) == 3628800 (0x) @@ -6009,7 +6011,7 @@ there" 0x == o - 0x == {?} + 3221225472 (0x) == {?} @@ -6031,7 +6033,7 @@ there" 0x == bit30and31 - 0x == 3221225472 + 3221225472 (0x) == 3221225472 @@ -6439,10 +6441,10 @@ there" - Catch::toString(vv) == "{ 42, 512 }" + Catch::toString(vv) == "{ 42, 250 }" - "{ 42, 512 }" == "{ 42, 512 }" + "{ 42, 250 }" == "{ 42, 250 }" @@ -6495,10 +6497,10 @@ there" - Catch::toString(vv) == "{ 42, 512 }" + Catch::toString(vv) == "{ 42, 250 }" - "{ 42, 512 }" == "{ 42, 512 }" + "{ 42, 250 }" == "{ 42, 250 }" diff --git a/projects/SelfTest/ToStringVector.cpp b/projects/SelfTest/ToStringVector.cpp index 44790605..c3a8d4ed 100644 --- a/projects/SelfTest/ToStringVector.cpp +++ b/projects/SelfTest/ToStringVector.cpp @@ -9,8 +9,8 @@ TEST_CASE( "vector -> toString", "[toString][vector]" ) REQUIRE( Catch::toString(vv) == "{ }" ); vv.push_back( 42 ); REQUIRE( Catch::toString(vv) == "{ 42 }" ); - vv.push_back( 512 ); - REQUIRE( Catch::toString(vv) == "{ 42, 512 }" ); + vv.push_back( 250 ); + REQUIRE( Catch::toString(vv) == "{ 42, 250 }" ); } TEST_CASE( "vector -> toString", "[toString][vector]" ) @@ -57,8 +57,8 @@ TEST_CASE( "vector -> toString", "[toString][vector,allocator]" ) REQUIRE( Catch::toString(vv) == "{ }" ); vv.push_back( 42 ); REQUIRE( Catch::toString(vv) == "{ 42 }" ); - vv.push_back( 512 ); - REQUIRE( Catch::toString(vv) == "{ 42, 512 }" ); + vv.push_back( 250 ); + REQUIRE( Catch::toString(vv) == "{ 42, 250 }" ); } TEST_CASE( "vec> -> toString", "[toString][vector,allocator]" ) {