diff --git a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp index 38adcbac..ca72d733 100644 --- a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #if defined(_MSC_VER) #pragma warning(push) @@ -55,3 +56,30 @@ TEST_CASE( "CaseInsensitiveEqualsTo is case insensitive", REQUIRE_FALSE( eq( "a", "B" ) ); } } + +TEST_CASE("Optional comparison ops", "[optional][approvals]") { + using Catch::Optional; + + Optional a, b; + + SECTION( "Empty optionals are equal" ) { + REQUIRE( a == b ); + REQUIRE_FALSE( a != b ); + } + SECTION( "Empty and non-empty optionals are never equal" ) { + a = 1; + REQUIRE_FALSE( a == b ); + REQUIRE( a != b ); + } + SECTION( + "non-empty optionals are equal if the contained elements are equal") { + a = 1; + b = 2; + REQUIRE( a != b ); + REQUIRE_FALSE( a == b ); + + a = 2; + REQUIRE( a == b ); + REQUIRE_FALSE( a != b ); + } +}