mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	Added tests for stringifying map and set
This commit is contained in:
		| @@ -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\" }" ); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash