From c571f0a5974b9ec0f20878ccbd3804eed8f5775a Mon Sep 17 00:00:00 2001 From: Andy Sawyer Date: Thu, 4 Sep 2014 21:19:02 +0100 Subject: [PATCH] Test toString(pair) --- projects/SelfTest/ToStringPair.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/projects/SelfTest/ToStringPair.cpp b/projects/SelfTest/ToStringPair.cpp index 355cf1d1..df508092 100644 --- a/projects/SelfTest/ToStringPair.cpp +++ b/projects/SelfTest/ToStringPair.cpp @@ -31,3 +31,22 @@ TEST_CASE( "pair > -> toString", "[t std::pair pair( left, right ); REQUIRE( Catch::toString( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" ); } + +// More contrivance: A pair of vectors... +TEST_CASE( "toString( pair )", "[toString][pair][vector]" ) +{ + typedef std::pair,std::vector > type; + + int aint[] = { 4, 2 }; + std::vector vint( std::begin(aint), std::end(aint) ); + CHECK( "{ 4, 2 }" == Catch::toString(vint) ); + + float afloat[] = { 0.4f, 0.2f }; + std::vector vfloat( std::begin(afloat), std::end(afloat) ); + CHECK( "{ 0.4f, 0.2f }" == Catch::toString(vfloat) ); + + type value( vint, vfloat ); + CHECK( "{ { 4, 2 }, { 0.4f, 0.2f } }" == Catch::toString(value) ); +} + +