From c3d80cf5ebd3d1e0868b02a877f6f880ab698da9 Mon Sep 17 00:00:00 2001 From: mat tso Date: Mon, 7 Mar 2016 22:12:39 +0100 Subject: [PATCH] Publish toString support for pairs Catch::toString support for pairs was implemented and tested but not accessible from the include folder (thus in releases). --- include/internal/catch_tostring.h | 13 +++++++++++++ projects/SelfTest/ToStringPair.cpp | 17 ----------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index e6f7ec9d..f1301dcc 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -186,6 +186,19 @@ std::string toString( std::vector const& v ) { return Detail::rangeToString( v.begin(), v.end() ); } +// toString for pairs +template +struct StringMaker > { + static std::string convert( const std::pair& pair ) { + std::ostringstream oss; + oss << "{ " + << toString( pair.first ) + << ", " + << toString( pair.second ) + << " }"; + return oss.str(); + } +}; #ifdef CATCH_CONFIG_CPP11_TUPLE diff --git a/projects/SelfTest/ToStringPair.cpp b/projects/SelfTest/ToStringPair.cpp index 8f510700..85975c7e 100644 --- a/projects/SelfTest/ToStringPair.cpp +++ b/projects/SelfTest/ToStringPair.cpp @@ -1,23 +1,6 @@ #include "catch.hpp" // === Pair === -namespace Catch { - // Note: If we put this in the right place in catch_tostring, then - // we can make it an overload of Catch::toString - template - struct StringMaker > { - static std::string convert( const std::pair& pair ) { - std::ostringstream oss; - oss << "{ " - << toString( pair.first ) - << ", " - << toString( pair.second ) - << " }"; - return oss.str(); - } - }; -} - TEST_CASE( "std::pair -> toString", "[toString][pair]" ) { std::pair value( 34, "xyzzy" ); REQUIRE( Catch::toString( value ) == "{ 34, \"xyzzy\" }" );