1 #define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER 2 #include "catch.hpp" 3 4 #include <tuple> 5 6 TEST_CASE( "tuple<>", "[toString][tuple]" ) 7 { 8 typedef std::tuple<> type; 9 CHECK( "{ }" == ::Catch::Detail::stringify(type{}) ); 10 type value {}; 11 CHECK( "{ }" == ::Catch::Detail::stringify(value) ); 12 } 13 14 TEST_CASE( "tuple<int>", "[toString][tuple]" ) 15 { 16 typedef std::tuple<int> type; 17 CHECK( "{ 0 }" == ::Catch::Detail::stringify(type{0}) ); 18 } 19 20 21 TEST_CASE( "tuple<float,int>", "[toString][tuple]" ) 22 { 23 typedef std::tuple<float,int> type; 24 CHECK( "1.2f" == ::Catch::Detail::stringify(float(1.2)) ); 25 CHECK( "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) ); 26 } 27 28 TEST_CASE( "tuple<string,string>", "[toString][tuple]" ) 29 { 30 typedef std::tuple<std::string,std::string> type; 31 CHECK( "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) ); 32 } 33 34 TEST_CASE( "tuple<tuple<int>,tuple<>,float>", "[toString][tuple]" ) 35 { 36 typedef std::tuple<std::tuple<int>,std::tuple<>,float> type; 37 type value { std::tuple<int>{42}, {}, 1.2f }; 38 CHECK( "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) ); 39 } 40 41 TEST_CASE( "tuple<nullptr,int,const char *>", "[toString][tuple]" ) 42 { 43 typedef std::tuple<std::nullptr_t,int,const char *> type; 44 type value { nullptr, 42, "Catch me" }; 45 CHECK( "{ nullptr, 42, \"Catch me\" }" == ::Catch::Detail::stringify(value) ); 46 } 47 48