mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Added tests for stringifying map and set
This commit is contained in:
parent
af3f2499bc
commit
e41e8e8384
@ -944,8 +944,18 @@ String.tests.cpp:<line number>: passed: Catch::replaceInPlace( s, "'", "|'" ) fo
|
||||
String.tests.cpp:<line number>: passed: s == "didn|'t" for: "didn|'t" == "didn|'t"
|
||||
Misc.tests.cpp:<line number>: failed: false with 1 message: '3'
|
||||
Message.tests.cpp:<line number>: failed: false with 2 messages: 'hi' and 'i := 7'
|
||||
ToStringGeneral.tests.cpp:<line number>: passed: Catch::Detail::stringify( emptyMap ) == "{ }" for: "{ }" == "{ }"
|
||||
ToStringGeneral.tests.cpp:<line number>: passed: Catch::Detail::stringify( map ) == "{ { /"one/", 1 } }" for: "{ { "one", 1 } }" == "{ { "one", 1 } }"
|
||||
ToStringGeneral.tests.cpp:<line number>: passed: Catch::Detail::stringify( map ) == "{ { /"abc/", 1 }, { /"def/", 2 }, { /"ghi/", 3 } }" for: "{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }"
|
||||
==
|
||||
"{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }"
|
||||
ToStringPair.tests.cpp:<line number>: passed: ::Catch::Detail::stringify(value) == "{ 34, /"xyzzy/" }" for: "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }"
|
||||
ToStringPair.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( value ) == "{ 34, /"xyzzy/" }" for: "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }"
|
||||
ToStringGeneral.tests.cpp:<line number>: passed: Catch::Detail::stringify( emptySet ) == "{ }" for: "{ }" == "{ }"
|
||||
ToStringGeneral.tests.cpp:<line number>: passed: Catch::Detail::stringify( set ) == "{ /"one/" }" for: "{ "one" }" == "{ "one" }"
|
||||
ToStringGeneral.tests.cpp:<line number>: passed: Catch::Detail::stringify( set ) == "{ /"abc/", /"def/", /"ghi/" }" for: "{ "abc", "def", "ghi" }"
|
||||
==
|
||||
"{ "abc", "def", "ghi" }"
|
||||
ToStringPair.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( pr ) == "{ { /"green/", 55 } }" for: "{ { "green", 55 } }"
|
||||
==
|
||||
"{ { "green", 55 } }"
|
||||
|
@ -1080,6 +1080,6 @@ with expansion:
|
||||
"{?}" == "1"
|
||||
|
||||
===============================================================================
|
||||
test cases: 191 | 139 passed | 48 failed | 4 failed as expected
|
||||
assertions: 971 | 843 passed | 107 failed | 21 failed as expected
|
||||
test cases: 193 | 141 passed | 48 failed | 4 failed as expected
|
||||
assertions: 977 | 849 passed | 107 failed | 21 failed as expected
|
||||
|
||||
|
@ -7488,6 +7488,47 @@ with messages:
|
||||
hi
|
||||
i := 7
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
std::map is convertible string
|
||||
empty
|
||||
-------------------------------------------------------------------------------
|
||||
ToStringGeneral.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ToStringGeneral.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( Catch::Detail::stringify( emptyMap ) == "{ }" )
|
||||
with expansion:
|
||||
"{ }" == "{ }"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
std::map is convertible string
|
||||
single item
|
||||
-------------------------------------------------------------------------------
|
||||
ToStringGeneral.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ToStringGeneral.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( Catch::Detail::stringify( map ) == "{ { \"one\", 1 } }" )
|
||||
with expansion:
|
||||
"{ { "one", 1 } }" == "{ { "one", 1 } }"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
std::map is convertible string
|
||||
several items
|
||||
-------------------------------------------------------------------------------
|
||||
ToStringGeneral.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ToStringGeneral.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( Catch::Detail::stringify( map ) == "{ { \"abc\", 1 }, { \"def\", 2 }, { \"ghi\", 3 } }" )
|
||||
with expansion:
|
||||
"{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }"
|
||||
==
|
||||
"{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
std::pair<int,const std::string> -> toString
|
||||
-------------------------------------------------------------------------------
|
||||
@ -7512,6 +7553,47 @@ PASSED:
|
||||
with expansion:
|
||||
"{ 34, "xyzzy" }" == "{ 34, "xyzzy" }"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
std::set is convertible string
|
||||
empty
|
||||
-------------------------------------------------------------------------------
|
||||
ToStringGeneral.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ToStringGeneral.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( Catch::Detail::stringify( emptySet ) == "{ }" )
|
||||
with expansion:
|
||||
"{ }" == "{ }"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
std::set is convertible string
|
||||
single item
|
||||
-------------------------------------------------------------------------------
|
||||
ToStringGeneral.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ToStringGeneral.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( Catch::Detail::stringify( set ) == "{ \"one\" }" )
|
||||
with expansion:
|
||||
"{ "one" }" == "{ "one" }"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
std::set is convertible string
|
||||
several items
|
||||
-------------------------------------------------------------------------------
|
||||
ToStringGeneral.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ToStringGeneral.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( Catch::Detail::stringify( set ) == "{ \"abc\", \"def\", \"ghi\" }" )
|
||||
with expansion:
|
||||
"{ "abc", "def", "ghi" }"
|
||||
==
|
||||
"{ "abc", "def", "ghi" }"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
std::vector<std::pair<std::string,int> > -> toString
|
||||
-------------------------------------------------------------------------------
|
||||
@ -8114,6 +8196,6 @@ Misc.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 191 | 137 passed | 50 failed | 4 failed as expected
|
||||
assertions: 970 | 839 passed | 110 failed | 21 failed as expected
|
||||
test cases: 193 | 139 passed | 50 failed | 4 failed as expected
|
||||
assertions: 976 | 845 passed | 110 failed | 21 failed as expected
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuitesloose text artifact
|
||||
>
|
||||
<testsuite name="<exe-name>" errors="15" failures="96" tests="971" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="15" failures="96" tests="977" 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="#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}"/>
|
||||
@ -799,8 +799,14 @@ i := 7
|
||||
Message.tests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="<exe-name>.global" name="std::map is convertible string/empty" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="std::map is convertible string/single item" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="std::map is convertible string/several items" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="std::pair<int,const std::string> -> toString" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="std::pair<int,std::string> -> toString" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="std::set is convertible string/empty" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="std::set is convertible string/single item" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="std::set is convertible string/several items" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="std::vector<std::pair<std::string,int> > -> toString" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="string literals of different sizes can be compared" time="{duration}">
|
||||
<failure message=""first" == "second"" type="REQUIRE">
|
||||
|
@ -8429,6 +8429,44 @@ loose text artifact
|
||||
</Expression>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="std::map is convertible string" tags="[toString]" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Section name="empty" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Original>
|
||||
Catch::Detail::stringify( emptyMap ) == "{ }"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"{ }" == "{ }"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="single item" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Original>
|
||||
Catch::Detail::stringify( map ) == "{ { \"one\", 1 } }"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"{ { "one", 1 } }" == "{ { "one", 1 } }"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="several items" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Original>
|
||||
Catch::Detail::stringify( map ) == "{ { \"abc\", 1 }, { \"def\", 2 }, { \"ghi\", 3 } }"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }"
|
||||
==
|
||||
"{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="std::pair<int,const std::string> -> toString" tags="[pair][toString]" filename="projects/<exe-name>/UsageTests/ToStringPair.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringPair.tests.cpp" >
|
||||
<Original>
|
||||
@ -8451,6 +8489,44 @@ loose text artifact
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="std::set is convertible string" tags="[toString]" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Section name="empty" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Original>
|
||||
Catch::Detail::stringify( emptySet ) == "{ }"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"{ }" == "{ }"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="single item" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Original>
|
||||
Catch::Detail::stringify( set ) == "{ \"one\" }"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"{ "one" }" == "{ "one" }"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="several items" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Original>
|
||||
Catch::Detail::stringify( set ) == "{ \"abc\", \"def\", \"ghi\" }"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"{ "abc", "def", "ghi" }"
|
||||
==
|
||||
"{ "abc", "def", "ghi" }"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="std::vector<std::pair<std::string,int> > -> toString" tags="[pair][toString]" filename="projects/<exe-name>/UsageTests/ToStringPair.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringPair.tests.cpp" >
|
||||
<Original>
|
||||
@ -9038,7 +9114,7 @@ loose text artifact
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="839" failures="111" expectedFailures="21"/>
|
||||
<OverallResults successes="845" failures="111" expectedFailures="21"/>
|
||||
</Group>
|
||||
<OverallResults successes="839" failures="110" expectedFailures="21"/>
|
||||
<OverallResults successes="845" failures="110" expectedFailures="21"/>
|
||||
</Catch>
|
||||
|
@ -5,8 +5,11 @@
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
TEST_CASE( "Character pretty printing" ){
|
||||
SECTION("Specifically escaped"){
|
||||
@ -51,3 +54,49 @@ TEST_CASE( "Capture and info messages" ) {
|
||||
REQUIRE(true);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "std::map is convertible string", "[toString]" ) {
|
||||
|
||||
SECTION( "empty" ) {
|
||||
std::map<std::string, int> emptyMap;
|
||||
|
||||
REQUIRE( Catch::Detail::stringify( emptyMap ) == "{ }" );
|
||||
}
|
||||
|
||||
SECTION( "single item" ) {
|
||||
std::map<std::string, int> map = { { "one", 1 } };
|
||||
|
||||
REQUIRE( Catch::Detail::stringify( map ) == "{ { \"one\", 1 } }" );
|
||||
}
|
||||
|
||||
SECTION( "several items" ) {
|
||||
std::map<std::string, int> map = {
|
||||
{ "abc", 1 },
|
||||
{ "def", 2 },
|
||||
{ "ghi", 3 }
|
||||
};
|
||||
|
||||
REQUIRE( Catch::Detail::stringify( map ) == "{ { \"abc\", 1 }, { \"def\", 2 }, { \"ghi\", 3 } }" );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "std::set is convertible string", "[toString]" ) {
|
||||
|
||||
SECTION( "empty" ) {
|
||||
std::set<std::string> emptySet;
|
||||
|
||||
REQUIRE( Catch::Detail::stringify( emptySet ) == "{ }" );
|
||||
}
|
||||
|
||||
SECTION( "single item" ) {
|
||||
std::set<std::string> set = { "one" };
|
||||
|
||||
REQUIRE( Catch::Detail::stringify( set ) == "{ \"one\" }" );
|
||||
}
|
||||
|
||||
SECTION( "several items" ) {
|
||||
std::set<std::string> set = { "abc", "def", "ghi" };
|
||||
|
||||
REQUIRE( Catch::Detail::stringify( set ) == "{ \"abc\", \"def\", \"ghi\" }" );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user