mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Add tests for Optional's op== and !=
This commit is contained in:
parent
f0a89b7345
commit
72a09de236
@ -6,6 +6,7 @@
|
|||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <catch2/internal/catch_enforce.hpp>
|
#include <catch2/internal/catch_enforce.hpp>
|
||||||
#include <catch2/internal/catch_case_insensitive_comparisons.hpp>
|
#include <catch2/internal/catch_case_insensitive_comparisons.hpp>
|
||||||
|
#include <catch2/internal/catch_optional.hpp>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
@ -55,3 +56,30 @@ TEST_CASE( "CaseInsensitiveEqualsTo is case insensitive",
|
|||||||
REQUIRE_FALSE( eq( "a", "B" ) );
|
REQUIRE_FALSE( eq( "a", "B" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Optional comparison ops", "[optional][approvals]") {
|
||||||
|
using Catch::Optional;
|
||||||
|
|
||||||
|
Optional<int> 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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user