changed hex threshold on ints to 255

- and print it in *addition* to the decimal form
This commit is contained in:
Phil Nash 2015-05-20 18:28:22 +01:00
parent bdbfe69e3c
commit 6ed74b5cab
4 changed files with 30 additions and 28 deletions

View File

@ -98,19 +98,17 @@ std::string toString( wchar_t* const value )
std::string toString( int value ) { std::string toString( int value ) {
std::ostringstream oss; 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(); return oss.str();
} }
std::string toString( unsigned long value ) { std::string toString( unsigned long value ) {
std::ostringstream oss; 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(); return oss.str();
} }

View File

@ -846,7 +846,9 @@ ConditionTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( (std::numeric_limits<unsigned long>::max)() > ul ) REQUIRE( (std::numeric_limits<unsigned long>::max)() > ul )
with expansion: with expansion:
0x<hex digits> > 4 18446744073709551615 (0x<hex digits>)
>
4
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
comparisons between int variables comparisons between int variables
@ -3398,7 +3400,7 @@ MiscTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( Factorial(10) == 3628800 ) REQUIRE( Factorial(10) == 3628800 )
with expansion: with expansion:
0x<hex digits> == 0x<hex digits> 3628800 (0x<hex digits>) == 3628800 (0x<hex digits>)
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
An empty test with no assertions An empty test with no assertions
@ -5827,7 +5829,7 @@ TrickyTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( 0x<hex digits> == o ) REQUIRE( 0x<hex digits> == o )
with expansion: with expansion:
0x<hex digits> == {?} 3221225472 (0x<hex digits>) == {?}
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Demonstrate that a non-const == is not used Demonstrate that a non-const == is not used
@ -5851,7 +5853,7 @@ TrickyTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE( 0x<hex digits> == bit30and31 ) REQUIRE( 0x<hex digits> == bit30and31 )
with expansion: with expansion:
0x<hex digits> == 3221225472 3221225472 (0x<hex digits>) == 3221225472
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
boolean member boolean member
@ -6308,9 +6310,9 @@ with expansion:
ToStringVector.cpp:<line number>: ToStringVector.cpp:<line number>:
PASSED: PASSED:
REQUIRE( Catch::toString(vv) == "{ 42, 512 }" ) REQUIRE( Catch::toString(vv) == "{ 42, 250 }" )
with expansion: with expansion:
"{ 42, 512 }" == "{ 42, 512 }" "{ 42, 250 }" == "{ 42, 250 }"
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
vector<string> -> toString vector<string> -> toString
@ -6358,9 +6360,9 @@ with expansion:
ToStringVector.cpp:<line number>: ToStringVector.cpp:<line number>:
PASSED: PASSED:
REQUIRE( Catch::toString(vv) == "{ 42, 512 }" ) REQUIRE( Catch::toString(vv) == "{ 42, 250 }" )
with expansion: with expansion:
"{ 42, 512 }" == "{ 42, 512 }" "{ 42, 250 }" == "{ 42, 250 }"
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
vec<vec<string,alloc>> -> toString vec<vec<string,alloc>> -> toString

View File

@ -1063,7 +1063,9 @@
(std::numeric_limits&lt;unsigned long>::max)() > ul (std::numeric_limits&lt;unsigned long>::max)() > ul
</Original> </Original>
<Expanded> <Expanded>
0x<hex digits> > 4 18446744073709551615 (0x<hex digits>)
>
4
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
@ -3519,7 +3521,7 @@
Factorial(10) == 3628800 Factorial(10) == 3628800
</Original> </Original>
<Expanded> <Expanded>
0x<hex digits> == 0x<hex digits> 3628800 (0x<hex digits>) == 3628800 (0x<hex digits>)
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
@ -6009,7 +6011,7 @@ there&quot;
0x<hex digits> == o 0x<hex digits> == o
</Original> </Original>
<Expanded> <Expanded>
0x<hex digits> == {?} 3221225472 (0x<hex digits>) == {?}
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
@ -6031,7 +6033,7 @@ there&quot;
0x<hex digits> == bit30and31 0x<hex digits> == bit30and31
</Original> </Original>
<Expanded> <Expanded>
0x<hex digits> == 3221225472 3221225472 (0x<hex digits>) == 3221225472
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
@ -6439,10 +6441,10 @@ there&quot;
</Expression> </Expression>
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" >
<Original> <Original>
Catch::toString(vv) == &quot;{ 42, 512 }&quot; Catch::toString(vv) == &quot;{ 42, 250 }&quot;
</Original> </Original>
<Expanded> <Expanded>
&quot;{ 42, 512 }&quot; == &quot;{ 42, 512 }&quot; &quot;{ 42, 250 }&quot; == &quot;{ 42, 250 }&quot;
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
@ -6495,10 +6497,10 @@ there&quot;
</Expression> </Expression>
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" >
<Original> <Original>
Catch::toString(vv) == &quot;{ 42, 512 }&quot; Catch::toString(vv) == &quot;{ 42, 250 }&quot;
</Original> </Original>
<Expanded> <Expanded>
&quot;{ 42, 512 }&quot; == &quot;{ 42, 512 }&quot; &quot;{ 42, 250 }&quot; == &quot;{ 42, 250 }&quot;
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>

View File

@ -9,8 +9,8 @@ TEST_CASE( "vector<int> -> toString", "[toString][vector]" )
REQUIRE( Catch::toString(vv) == "{ }" ); REQUIRE( Catch::toString(vv) == "{ }" );
vv.push_back( 42 ); vv.push_back( 42 );
REQUIRE( Catch::toString(vv) == "{ 42 }" ); REQUIRE( Catch::toString(vv) == "{ 42 }" );
vv.push_back( 512 ); vv.push_back( 250 );
REQUIRE( Catch::toString(vv) == "{ 42, 512 }" ); REQUIRE( Catch::toString(vv) == "{ 42, 250 }" );
} }
TEST_CASE( "vector<string> -> toString", "[toString][vector]" ) TEST_CASE( "vector<string> -> toString", "[toString][vector]" )
@ -57,8 +57,8 @@ TEST_CASE( "vector<int,allocator> -> toString", "[toString][vector,allocator]" )
REQUIRE( Catch::toString(vv) == "{ }" ); REQUIRE( Catch::toString(vv) == "{ }" );
vv.push_back( 42 ); vv.push_back( 42 );
REQUIRE( Catch::toString(vv) == "{ 42 }" ); REQUIRE( Catch::toString(vv) == "{ 42 }" );
vv.push_back( 512 ); vv.push_back( 250 );
REQUIRE( Catch::toString(vv) == "{ 42, 512 }" ); REQUIRE( Catch::toString(vv) == "{ 42, 250 }" );
} }
TEST_CASE( "vec<vec<string,alloc>> -> toString", "[toString][vector,allocator]" ) { TEST_CASE( "vec<vec<string,alloc>> -> toString", "[toString][vector,allocator]" ) {