From 2f854336d9f16af0cd379ba0e69818c4b7fe0747 Mon Sep 17 00:00:00 2001 From: Andy Sawyer Date: Thu, 4 Sep 2014 21:17:50 +0100 Subject: [PATCH] Test for pair/tuple combinations --- projects/SelfTest/ToStringTuple.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/projects/SelfTest/ToStringTuple.cpp b/projects/SelfTest/ToStringTuple.cpp index 012ee665..891cb8d8 100644 --- a/projects/SelfTest/ToStringTuple.cpp +++ b/projects/SelfTest/ToStringTuple.cpp @@ -44,5 +44,34 @@ TEST_CASE( "tuple", "[toString][tuple]" ) CHECK( "{ nullptr, 42, \"Catch me\" }" == Catch::toString(value) ); } +TEST_CASE( "toString( tuple )", "[toString][tuple][pair]" ) +{ + typedef std::tuple, + std::pair, + std::pair> + type; + std::pair p1{ 12, 34 }; + CHECK( "{ 12, 34 }" == Catch::toString(p1) ); + std::pair p2{ 23, 45 }; + CHECK( "{ 23, 45 }" == Catch::toString(p2) ); + std::pair p3{ 24, 68 }; + CHECK( "{ 24, 68 }" == Catch::toString(p3) ); + type value{ p1, p2, p3 }; + CHECK( "{ { 12, 34 }, { 23, 45 }, { 24, 68 } }" == Catch::toString(value) ); +} + +TEST_CASE( "toString( pair )", "[toString][tuple][pair]" ) +{ + typedef std::pair, + std::tuple + > type; + std::tuple tuple1{ 12, 34, 56 }; + CHECK( "{ 12, 34, 56 }" == Catch::toString(tuple1) ); + std::tuple tuple2{ 23, 45, 67 }; + CHECK( "{ 23, 45, 67 }" == Catch::toString(tuple2) ); + type value{ tuple1, tuple2 }; + CHECK( "{ { 12, 34, 56 }, { 23, 45, 67 } }" == Catch::toString(value) ); +} + #endif /* #ifdef CATCH_CPP11_OR_GREATER */