Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
diff options
context:
space:
mode:
authorPhil Nash2018-01-08 11:13:29 +0000
committerPhil Nash2018-01-08 11:13:29 +0000
commit161dd4ed2449c7b02ffdfda607ffb0924d916c3c (patch)
tree094b03b0135710bf1ef18d4c95afa2d56d4805ba /projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
parent13ea4225e7c45214b0c6faf20cd65bb680937f4d (diff)
parent2c43620d9baed1fdcaa9146af1d3eb90520cbe92 (diff)
downloadcatch3-161dd4ed2449c7b02ffdfda607ffb0924d916c3c.tar.gz
Merge commit '2c43620d9baed1fdcaa9146af1d3eb90520cbe92'
Diffstat (limited to 'projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp')
-rw-r--r--projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp b/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
index 743882b1..3c5a3d94 100644
--- a/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
+++ b/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
@@ -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\" }" );
+ }
+}