Added test for stringifying std::arrays

This commit is contained in:
Phil Nash 2018-01-04 10:52:55 +00:00
parent 32eb90b9bd
commit 8be1df243e
6 changed files with 71 additions and 8 deletions

View File

@ -874,6 +874,9 @@ Xml.tests.cpp:<line number>: passed: encode( stringWithQuotes, Catch::XmlEncode:
"don't &quot;quote&quot; me on that" "don't &quot;quote&quot; me on that"
Xml.tests.cpp:<line number>: passed: encode( "[/x01]" ) == "[//x01]" for: "[/x01]" == "[/x01]" Xml.tests.cpp:<line number>: passed: encode( "[/x01]" ) == "[//x01]" for: "[/x01]" == "[/x01]"
Xml.tests.cpp:<line number>: passed: encode( "[/x7F]" ) == "[//x7F]" for: "[/x7F]" == "[/x7F]" Xml.tests.cpp:<line number>: passed: encode( "[/x7F]" ) == "[//x7F]" for: "[/x7F]" == "[/x7F]"
ToStringVector.tests.cpp:<line number>: passed: Catch::Detail::stringify( empty ) == "{ }" for: "{ }" == "{ }"
ToStringVector.tests.cpp:<line number>: passed: Catch::Detail::stringify( oneValue ) == "{ 42 }" for: "{ 42 }" == "{ 42 }"
ToStringVector.tests.cpp:<line number>: passed: Catch::Detail::stringify( twoValues ) == "{ 42, 250 }" for: "{ 42, 250 }" == "{ 42, 250 }"
Misc.tests.cpp:<line number>: passed: x == 0 for: 0 == 0 Misc.tests.cpp:<line number>: passed: x == 0 for: 0 == 0
Tricky.tests.cpp:<line number>: passed: obj.prop != 0 for: 0x<hex digits> != 0 Tricky.tests.cpp:<line number>: passed: obj.prop != 0 for: 0x<hex digits> != 0
Misc.tests.cpp:<line number>: passed: flag for: true Misc.tests.cpp:<line number>: passed: flag for: true

View File

@ -1064,6 +1064,6 @@ with expansion:
"first" == "second" "first" == "second"
=============================================================================== ===============================================================================
test cases: 194 | 143 passed | 47 failed | 4 failed as expected test cases: 195 | 144 passed | 47 failed | 4 failed as expected
assertions: 980 | 854 passed | 105 failed | 21 failed as expected assertions: 983 | 857 passed | 105 failed | 21 failed as expected

View File

@ -6852,6 +6852,30 @@ PASSED:
with expansion: with expansion:
"[\x7F]" == "[\x7F]" "[\x7F]" == "[\x7F]"
-------------------------------------------------------------------------------
array<int, N> -> toString
-------------------------------------------------------------------------------
ToStringVector.tests.cpp:<line number>
...............................................................................
ToStringVector.tests.cpp:<line number>:
PASSED:
REQUIRE( Catch::Detail::stringify( empty ) == "{ }" )
with expansion:
"{ }" == "{ }"
ToStringVector.tests.cpp:<line number>:
PASSED:
REQUIRE( Catch::Detail::stringify( oneValue ) == "{ 42 }" )
with expansion:
"{ 42 }" == "{ 42 }"
ToStringVector.tests.cpp:<line number>:
PASSED:
REQUIRE( Catch::Detail::stringify( twoValues ) == "{ 42, 250 }" )
with expansion:
"{ 42, 250 }" == "{ 42, 250 }"
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
atomic if atomic if
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -8222,6 +8246,6 @@ Misc.tests.cpp:<line number>:
PASSED: PASSED:
=============================================================================== ===============================================================================
test cases: 194 | 141 passed | 49 failed | 4 failed as expected test cases: 195 | 142 passed | 49 failed | 4 failed as expected
assertions: 979 | 850 passed | 108 failed | 21 failed as expected assertions: 982 | 853 passed | 108 failed | 21 failed as expected

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact <testsuitesloose text artifact
> >
<testsuite name="<exe-name>" errors="15" failures="94" tests="980" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <testsuite name="<exe-name>" errors="15" failures="94" tests="983" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/> <testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/> <testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1027" time="{duration}"/> <testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
@ -698,6 +698,7 @@ Exception.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="XmlEncode/string with quotes" time="{duration}"/> <testcase classname="<exe-name>.global" name="XmlEncode/string with quotes" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/string with control char (1)" time="{duration}"/> <testcase classname="<exe-name>.global" name="XmlEncode/string with control char (1)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/string with control char (x7F)" time="{duration}"/> <testcase classname="<exe-name>.global" name="XmlEncode/string with control char (x7F)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="array&lt;int, N> -> toString" time="{duration}"/>
<testcase classname="<exe-name>.global" name="atomic if" time="{duration}"/> <testcase classname="<exe-name>.global" name="atomic if" time="{duration}"/>
<testcase classname="<exe-name>.global" name="boolean member" time="{duration}"/> <testcase classname="<exe-name>.global" name="boolean member" time="{duration}"/>
<testcase classname="<exe-name>.global" name="checkedElse" time="{duration}"/> <testcase classname="<exe-name>.global" name="checkedElse" time="{duration}"/>

View File

@ -7749,6 +7749,33 @@ Message from section two
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="array&lt;int, N> -> toString" tags="[array][containers][toString]" filename="projects/<exe-name>/UsageTests/ToStringVector.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringVector.tests.cpp" >
<Original>
Catch::Detail::stringify( empty ) == "{ }"
</Original>
<Expanded>
"{ }" == "{ }"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringVector.tests.cpp" >
<Original>
Catch::Detail::stringify( oneValue ) == "{ 42 }"
</Original>
<Expanded>
"{ 42 }" == "{ 42 }"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringVector.tests.cpp" >
<Original>
Catch::Detail::stringify( twoValues ) == "{ 42, 250 }"
</Original>
<Expanded>
"{ 42, 250 }" == "{ 42, 250 }"
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="atomic if" tags="[0][failing]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > <TestCase name="atomic if" tags="[0][failing]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original> <Original>
@ -9141,7 +9168,7 @@ loose text artifact
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<OverallResults successes="850" failures="109" expectedFailures="21"/> <OverallResults successes="853" failures="109" expectedFailures="21"/>
</Group> </Group>
<OverallResults successes="850" failures="108" expectedFailures="21"/> <OverallResults successes="853" failures="108" expectedFailures="21"/>
</Catch> </Catch>

View File

@ -1,6 +1,6 @@
#include "catch.hpp" #include "catch.hpp"
#include <vector> #include <vector>
#include <array>
// vedctor // vedctor
TEST_CASE( "vector<int> -> toString", "[toString][vector]" ) TEST_CASE( "vector<int> -> toString", "[toString][vector]" )
@ -76,3 +76,11 @@ TEST_CASE( "vector<bool> -> toString", "[toString][containers][vector]" ) {
bools.push_back(false); bools.push_back(false);
REQUIRE( ::Catch::Detail::stringify(bools) == "{ true, false }"); REQUIRE( ::Catch::Detail::stringify(bools) == "{ true, false }");
} }
TEST_CASE( "array<int, N> -> toString", "[toString][containers][array]" ) {
std::array<int, 0> empty;
REQUIRE( Catch::Detail::stringify( empty ) == "{ }" );
std::array<int, 1> oneValue = {{ 42 }};
REQUIRE( Catch::Detail::stringify( oneValue ) == "{ 42 }" );
std::array<int, 2> twoValues = {{ 42, 250 }};
REQUIRE( Catch::Detail::stringify( twoValues ) == "{ 42, 250 }" );
}