ToStringOptional.tests.cpp 915 B

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