1 #define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER 2 #include "catch.hpp" 3 4 #if defined(CATCH_CONFIG_CPP17_OPTIONAL) 5 6 TEST_CASE( "std::optional<int> -> toString", "[toString][optional][approvals]" ) { 7 using type = std::optional<int>; 8 REQUIRE( "{ }" == ::Catch::Detail::stringify( type{} ) ); 9 REQUIRE( "0" == ::Catch::Detail::stringify( type{ 0 } ) ); 10 } 11 12 TEST_CASE( "std::optional<std::string> -> toString", "[toString][optional][approvals]" ) { 13 using type = std::optional<std::string>; 14 REQUIRE( "{ }" == ::Catch::Detail::stringify( type{} ) ); 15 REQUIRE( "\"abc\"" == ::Catch::Detail::stringify( type{ "abc" } ) ); 16 } 17 18 TEST_CASE( "std::vector<std::optional<int> > -> toString", "[toString][optional][approvals]" ) { 19 using type = std::vector<std::optional<int> >; 20 REQUIRE( "{ 0, { }, 2 }" == ::Catch::Detail::stringify( type{ 0, {}, 2 } ) ); 21 } 22 23 #endif // CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL 24