From 938e9f740eeedb8de8e179e00e0b764314ea181b Mon Sep 17 00:00:00 2001 From: Martin Moene Date: Sun, 13 Nov 2022 20:05:48 +0100 Subject: [PATCH] Add test for expected relational operators (#51, thanks @Crzyrndm) --- README.md | 1 + test/expected.t.cpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 69fa892..0470d20 100644 --- a/README.md +++ b/README.md @@ -450,6 +450,7 @@ expected: Allows to observe its error as unexpected expected: Allows to query if it contains an exception of a specific base type expected: Throws bad_expected_access on value access when disengaged operators: Provides expected relational operators +operators: Provides expected relational operators (void) swap: Allows expected to be swapped std::hash: Allows to compute hash value for expected tweak header: reads tweak header if supported [tweak] diff --git a/test/expected.t.cpp b/test/expected.t.cpp index fe43e25..905df9c 100644 --- a/test/expected.t.cpp +++ b/test/expected.t.cpp @@ -647,6 +647,7 @@ CASE( "expected: Allows to move-construct from expected: value" ) EXPECT( b ); EXPECT( b.value() == 7 ); + EXPECT( a ); // postcondition: unchanged! } CASE( "expected: Allows to move-construct from expected: error" ) @@ -1247,6 +1248,7 @@ CASE( "expected: Allows to move-construct from expected: value" ) expected b{ std::move( a ) }; EXPECT( b ); + EXPECT( a ); // postcondition: unchanged! } CASE( "expected: Allows to move-construct from expected: error" ) @@ -1589,6 +1591,25 @@ CASE( "operators: Provides expected relational operators" ) } } +CASE( "operators: Provides expected relational operators (void)" ) +{ + SETUP( "" ) { + expected ev1; + expected ev2; + expected evu{ unexpect }; + + // compare engaged expected with engaged expected + + SECTION( " engaged == engaged" ) { EXPECT( ev1 == ev2 ); } + SECTION( "!(engaged != engaged)" ) { EXPECT_NOT( ev1 != ev2 ); } + + // compare engaged expected with disengaged expected + + SECTION( " engaged != disengaged" ) { EXPECT( ev1 != evu ); } + SECTION( "!(engaged == disengaged)" ) { EXPECT_NOT( ev1 == evu ); } + } +} + // ----------------------------------------------------------------------- // expected: specialized algorithms