Reworked stringification layer, removed Catch::toString

Now the order of stringification checks is

1) StringMaker specialization
2) operator<<

toString overloads and specializations have been removed.
This commit is contained in:
Martin Hořeňovský
2017-05-02 23:51:03 +02:00
parent 40130e59b4
commit 33ed1773f4
20 changed files with 626 additions and 557 deletions

View File

@@ -119,7 +119,7 @@ with expansion:
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( (*__error()) == 1 )
REQUIRE( (*__errno_location ()) == 1 )
with expansion:
1 == 1
@@ -5873,7 +5873,7 @@ TrickyTests.cpp:<line number>:
PASSED:
REQUIRE( (std::pair<int, int>( 1, 2 )) == aNicePair )
with expansion:
std::pair( 1, 2 ) == std::pair( 1, 2 )
{ 1, 2 } == { 1, 2 }
-------------------------------------------------------------------------------
Pointers can be compared to null
@@ -5885,13 +5885,13 @@ ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( p == 0 )
with expansion:
NULL == 0
0 == 0
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( p == pNULL )
with expansion:
NULL == NULL
0 == 0
ConditionTests.cpp:<line number>:
PASSED:
@@ -8864,7 +8864,7 @@ ToStringPair.cpp:<line number>
ToStringPair.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" )
REQUIRE( ::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" )
with expansion:
"{ { 42, "Arthur" }, { "Ford", 24 } }"
==
@@ -8880,7 +8880,7 @@ TrickyTests.cpp:<line number>:
PASSED:
REQUIRE( p == 0 )
with expansion:
NULL == 0
0 == 0
-------------------------------------------------------------------------------
random SECTION tests
@@ -9078,7 +9078,7 @@ ToStringPair.cpp:<line number>
ToStringPair.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString(value) == "{ 34, \"xyzzy\" }" )
REQUIRE( ::Catch::Detail::stringify(value) == "{ 34, \"xyzzy\" }" )
with expansion:
"{ 34, "xyzzy" }" == "{ 34, "xyzzy" }"
@@ -9090,7 +9090,7 @@ ToStringPair.cpp:<line number>
ToStringPair.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString( value ) == "{ 34, \"xyzzy\" }" )
REQUIRE( ::Catch::Detail::stringify( value ) == "{ 34, \"xyzzy\" }" )
with expansion:
"{ 34, "xyzzy" }" == "{ 34, "xyzzy" }"
@@ -9102,7 +9102,7 @@ ToStringPair.cpp:<line number>
ToStringPair.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString( pr ) == "{ { \"green\", 55 } }" )
REQUIRE( ::Catch::Detail::stringify( pr ) == "{ { \"green\", 55 } }" )
with expansion:
"{ { "green", 55 } }"
==
@@ -9119,6 +9119,48 @@ TrickyTests.cpp:<line number>: FAILED:
with expansion:
"first" == "second"
-------------------------------------------------------------------------------
stringify( has_maker )
-------------------------------------------------------------------------------
ToStringWhich.cpp:<line number>
...............................................................................
ToStringWhich.cpp:<line number>:
PASSED:
REQUIRE( ::Catch::Detail::stringify( item ) == "StringMaker<has_maker>" )
with expansion:
"StringMaker<has_maker>"
==
"StringMaker<has_maker>"
-------------------------------------------------------------------------------
stringify( has_maker_and_toString )
-------------------------------------------------------------------------------
ToStringWhich.cpp:<line number>
...............................................................................
ToStringWhich.cpp:<line number>:
PASSED:
REQUIRE( ::Catch::Detail::stringify( item ) == "StringMaker<has_maker_and_operator>" )
with expansion:
"StringMaker<has_maker_and_operator>"
==
"StringMaker<has_maker_and_operator>"
-------------------------------------------------------------------------------
stringify( has_operator )
-------------------------------------------------------------------------------
ToStringWhich.cpp:<line number>
...............................................................................
ToStringWhich.cpp:<line number>:
PASSED:
REQUIRE( ::Catch::Detail::stringify( item ) == "operator<<( has_operator )" )
with expansion:
"operator<<( has_operator )"
==
"operator<<( has_operator )"
-------------------------------------------------------------------------------
toString on const wchar_t const pointer returns the string contents
-------------------------------------------------------------------------------
@@ -9167,48 +9209,6 @@ PASSED:
with expansion:
""wide load"" == ""wide load""
-------------------------------------------------------------------------------
toString( has_maker )
-------------------------------------------------------------------------------
ToStringWhich.cpp:<line number>
...............................................................................
ToStringWhich.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString( item ) == "StringMaker<has_maker>" )
with expansion:
"StringMaker<has_maker>"
==
"StringMaker<has_maker>"
-------------------------------------------------------------------------------
toString( has_maker_and_toString )
-------------------------------------------------------------------------------
ToStringWhich.cpp:<line number>
...............................................................................
ToStringWhich.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString( item ) == "toString( has_maker_and_toString )" )
with expansion:
"toString( has_maker_and_toString )"
==
"toString( has_maker_and_toString )"
-------------------------------------------------------------------------------
toString( has_toString )
-------------------------------------------------------------------------------
ToStringWhich.cpp:<line number>
...............................................................................
ToStringWhich.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString( item ) == "toString( has_toString )" )
with expansion:
"toString( has_toString )"
==
"toString( has_toString )"
-------------------------------------------------------------------------------
toString( vectors<has_maker )
-------------------------------------------------------------------------------
@@ -9217,7 +9217,7 @@ ToStringWhich.cpp:<line number>
ToStringWhich.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString( v ) == "{ StringMaker<has_maker> }" )
REQUIRE( ::Catch::Detail::stringify( v ) == "{ StringMaker<has_maker> }" )
with expansion:
"{ StringMaker<has_maker> }"
==
@@ -9231,13 +9231,13 @@ EnumToString.cpp:<line number>
EnumToString.cpp:<line number>:
PASSED:
CHECK( Catch::toString(e0) == "E2{0}" )
CHECK( ::Catch::Detail::stringify(e0) == "E2{0}" )
with expansion:
"E2{0}" == "E2{0}"
EnumToString.cpp:<line number>:
PASSED:
CHECK( Catch::toString(e1) == "E2{1}" )
CHECK( ::Catch::Detail::stringify(e1) == "E2{1}" )
with expansion:
"E2{1}" == "E2{1}"
@@ -9249,13 +9249,13 @@ EnumToString.cpp:<line number>
EnumToString.cpp:<line number>:
PASSED:
CHECK( Catch::toString(e0) == "0" )
CHECK( ::Catch::Detail::stringify(e0) == "0" )
with expansion:
"0" == "0"
EnumToString.cpp:<line number>:
PASSED:
CHECK( Catch::toString(e1) == "1" )
CHECK( ::Catch::Detail::stringify(e1) == "1" )
with expansion:
"1" == "1"
@@ -9267,19 +9267,19 @@ ToStringVector.cpp:<line number>
ToStringVector.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString(vv) == "{ }" )
REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" )
with expansion:
"{ }" == "{ }"
ToStringVector.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString(vv) == "{ 42 }" )
REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42 }" )
with expansion:
"{ 42 }" == "{ 42 }"
ToStringVector.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString(vv) == "{ 42, 250 }" )
REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42, 250 }" )
with expansion:
"{ 42, 250 }" == "{ 42, 250 }"
@@ -9291,19 +9291,19 @@ ToStringVector.cpp:<line number>
ToStringVector.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString(vv) == "{ }" )
REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" )
with expansion:
"{ }" == "{ }"
ToStringVector.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString(vv) == "{ \"hello\" }" )
REQUIRE( ::Catch::Detail::stringify(vv) == "{ \"hello\" }" )
with expansion:
"{ "hello" }" == "{ "hello" }"
ToStringVector.cpp:<line number>:
PASSED:
REQUIRE( Catch::toString(vv) == "{ \"hello\", \"world\" }" )
REQUIRE( ::Catch::Detail::stringify(vv) == "{ \"hello\", \"world\" }" )
with expansion:
"{ "hello", "world" }"
==

View File

@@ -119,7 +119,7 @@ with expansion:
MiscTests.cpp:<line number>:
PASSED:
REQUIRE( (*__error()) == 1 )
REQUIRE( (*__errno_location ()) == 1 )
with expansion:
1 == 1

View File

@@ -715,13 +715,13 @@ MessageTests.cpp:<line number>
TrickyTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="stringify( has_maker )" time="{duration}"/>
<testcase classname="global" name="stringify( has_maker_and_toString )" time="{duration}"/>
<testcase classname="global" name="stringify( has_operator )" time="{duration}"/>
<testcase classname="global" name="toString on const wchar_t const pointer returns the string contents" time="{duration}"/>
<testcase classname="global" name="toString on const wchar_t pointer returns the string contents" time="{duration}"/>
<testcase classname="global" name="toString on wchar_t const pointer returns the string contents" time="{duration}"/>
<testcase classname="global" name="toString on wchar_t returns the string contents" time="{duration}"/>
<testcase classname="global" name="toString( has_maker )" time="{duration}"/>
<testcase classname="global" name="toString( has_maker_and_toString )" time="{duration}"/>
<testcase classname="global" name="toString( has_toString )" time="{duration}"/>
<testcase classname="global" name="toString( vectors&lt;has_maker )" time="{duration}"/>
<testcase classname="global" name="toString(enum w/operator&lt;&lt;)" time="{duration}"/>
<testcase classname="global" name="toString(enum)" time="{duration}"/>

View File

@@ -128,7 +128,7 @@
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MiscTests.cpp" >
<Original>
(*__error()) == 1
(*__errno_location ()) == 1
</Original>
<Expanded>
1 == 1
@@ -6214,7 +6214,7 @@ re>"
(std::pair&lt;int, int>( 1, 2 )) == aNicePair
</Original>
<Expanded>
std::pair( 1, 2 ) == std::pair( 1, 2 )
{ 1, 2 } == { 1, 2 }
</Expanded>
</Expression>
<OverallResult success="true"/>
@@ -6225,7 +6225,7 @@ re>"
p == 0
</Original>
<Expanded>
NULL == 0
0 == 0
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ConditionTests.cpp" >
@@ -6233,7 +6233,7 @@ re>"
p == pNULL
</Original>
<Expanded>
NULL == NULL
0 == 0
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ConditionTests.cpp" >
@@ -9516,7 +9516,7 @@ spanner <OverallResult success="true"/>
<TestCase name="pair&lt;pair&lt;int,const char *,pair&lt;std::string,int> > -> toString" tags="[pair][toString]" filename="projects/<exe-name>/ToStringPair.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringPair.cpp" >
<Original>
Catch::toString( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }"
::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }"
</Original>
<Expanded>
"{ { 42, "Arthur" }, { "Ford", 24 } }"
@@ -9532,7 +9532,7 @@ spanner <OverallResult success="true"/>
p == 0
</Original>
<Expanded>
NULL == 0
0 == 0
</Expanded>
</Expression>
<OverallResult success="true"/>
@@ -9743,7 +9743,7 @@ spanner <OverallResult success="true"/>
<TestCase name="std::pair&lt;int,const std::string> -> toString" tags="[pair][toString]" filename="projects/<exe-name>/ToStringPair.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringPair.cpp" >
<Original>
Catch::toString(value) == "{ 34, \"xyzzy\" }"
::Catch::Detail::stringify(value) == "{ 34, \"xyzzy\" }"
</Original>
<Expanded>
"{ 34, "xyzzy" }" == "{ 34, "xyzzy" }"
@@ -9754,7 +9754,7 @@ spanner <OverallResult success="true"/>
<TestCase name="std::pair&lt;int,std::string> -> toString" tags="[pair][toString]" filename="projects/<exe-name>/ToStringPair.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringPair.cpp" >
<Original>
Catch::toString( value ) == "{ 34, \"xyzzy\" }"
::Catch::Detail::stringify( value ) == "{ 34, \"xyzzy\" }"
</Original>
<Expanded>
"{ 34, "xyzzy" }" == "{ 34, "xyzzy" }"
@@ -9765,7 +9765,7 @@ spanner <OverallResult success="true"/>
<TestCase name="std::vector&lt;std::pair&lt;std::string,int> > -> toString" tags="[pair][toString]" filename="projects/<exe-name>/ToStringPair.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringPair.cpp" >
<Original>
Catch::toString( pr ) == "{ { \"green\", 55 } }"
::Catch::Detail::stringify( pr ) == "{ { \"green\", 55 } }"
</Original>
<Expanded>
"{ { "green", 55 } }"
@@ -9786,6 +9786,45 @@ spanner <OverallResult success="true"/>
</Expression>
<OverallResult success="false"/>
</TestCase>
<TestCase name="stringify( has_maker )" tags="[toString]" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Original>
::Catch::Detail::stringify( item ) == "StringMaker&lt;has_maker>"
</Original>
<Expanded>
"StringMaker&lt;has_maker>"
==
"StringMaker&lt;has_maker>"
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="stringify( has_maker_and_toString )" tags="[.][hide][toString]" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Original>
::Catch::Detail::stringify( item ) == "StringMaker&lt;has_maker_and_operator>"
</Original>
<Expanded>
"StringMaker&lt;has_maker_and_operator>"
==
"StringMaker&lt;has_maker_and_operator>"
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="stringify( has_operator )" tags="[toString]" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Original>
::Catch::Detail::stringify( item ) == "operator&lt;&lt;( has_operator )"
</Original>
<Expanded>
"operator&lt;&lt;( has_operator )"
==
"operator&lt;&lt;( has_operator )"
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="toString on const wchar_t const pointer returns the string contents" tags="[toString]" filename="projects/<exe-name>/MiscTests.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" >
<Original>
@@ -9830,49 +9869,10 @@ spanner <OverallResult success="true"/>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="toString( has_maker )" description="toString]" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Original>
Catch::toString( item ) == "StringMaker&lt;has_maker>"
</Original>
<Expanded>
"StringMaker&lt;has_maker>"
==
"StringMaker&lt;has_maker>"
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="toString( has_maker_and_toString )" tags="[.][hide][toString]" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Original>
Catch::toString( item ) == "toString( has_maker_and_toString )"
</Original>
<Expanded>
"toString( has_maker_and_toString )"
==
"toString( has_maker_and_toString )"
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="toString( has_toString )" tags="[toString]" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Original>
Catch::toString( item ) == "toString( has_toString )"
</Original>
<Expanded>
"toString( has_toString )"
==
"toString( has_toString )"
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="toString( vectors&lt;has_maker )" tags="[toString]" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringWhich.cpp" >
<Original>
Catch::toString( v ) == "{ StringMaker&lt;has_maker> }"
::Catch::Detail::stringify( v ) == "{ StringMaker&lt;has_maker> }"
</Original>
<Expanded>
"{ StringMaker&lt;has_maker> }"
@@ -9885,7 +9885,7 @@ spanner <OverallResult success="true"/>
<TestCase name="toString(enum w/operator&lt;&lt;)" tags="[enum][toString]" filename="projects/<exe-name>/EnumToString.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/EnumToString.cpp" >
<Original>
Catch::toString(e0) == "E2{0}"
::Catch::Detail::stringify(e0) == "E2{0}"
</Original>
<Expanded>
"E2{0}" == "E2{0}"
@@ -9893,7 +9893,7 @@ spanner <OverallResult success="true"/>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/EnumToString.cpp" >
<Original>
Catch::toString(e1) == "E2{1}"
::Catch::Detail::stringify(e1) == "E2{1}"
</Original>
<Expanded>
"E2{1}" == "E2{1}"
@@ -9904,7 +9904,7 @@ spanner <OverallResult success="true"/>
<TestCase name="toString(enum)" tags="[enum][toString]" filename="projects/<exe-name>/EnumToString.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/EnumToString.cpp" >
<Original>
Catch::toString(e0) == "0"
::Catch::Detail::stringify(e0) == "0"
</Original>
<Expanded>
"0" == "0"
@@ -9912,7 +9912,7 @@ spanner <OverallResult success="true"/>
</Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/EnumToString.cpp" >
<Original>
Catch::toString(e1) == "1"
::Catch::Detail::stringify(e1) == "1"
</Original>
<Expanded>
"1" == "1"
@@ -9923,7 +9923,7 @@ spanner <OverallResult success="true"/>
<TestCase name="vector&lt;int> -> toString" tags="[toString][vector]" filename="projects/<exe-name>/ToStringVector.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringVector.cpp" >
<Original>
Catch::toString(vv) == "{ }"
::Catch::Detail::stringify(vv) == "{ }"
</Original>
<Expanded>
"{ }" == "{ }"
@@ -9931,7 +9931,7 @@ spanner <OverallResult success="true"/>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringVector.cpp" >
<Original>
Catch::toString(vv) == "{ 42 }"
::Catch::Detail::stringify(vv) == "{ 42 }"
</Original>
<Expanded>
"{ 42 }" == "{ 42 }"
@@ -9939,7 +9939,7 @@ spanner <OverallResult success="true"/>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringVector.cpp" >
<Original>
Catch::toString(vv) == "{ 42, 250 }"
::Catch::Detail::stringify(vv) == "{ 42, 250 }"
</Original>
<Expanded>
"{ 42, 250 }" == "{ 42, 250 }"
@@ -9950,7 +9950,7 @@ spanner <OverallResult success="true"/>
<TestCase name="vector&lt;string> -> toString" tags="[toString][vector]" filename="projects/<exe-name>/ToStringVector.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringVector.cpp" >
<Original>
Catch::toString(vv) == "{ }"
::Catch::Detail::stringify(vv) == "{ }"
</Original>
<Expanded>
"{ }" == "{ }"
@@ -9958,7 +9958,7 @@ spanner <OverallResult success="true"/>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringVector.cpp" >
<Original>
Catch::toString(vv) == "{ \"hello\" }"
::Catch::Detail::stringify(vv) == "{ \"hello\" }"
</Original>
<Expanded>
"{ "hello" }" == "{ "hello" }"
@@ -9966,7 +9966,7 @@ spanner <OverallResult success="true"/>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringVector.cpp" >
<Original>
Catch::toString(vv) == "{ \"hello\", \"world\" }"
::Catch::Detail::stringify(vv) == "{ \"hello\", \"world\" }"
</Original>
<Expanded>
"{ "hello", "world" }"