forked from intel/compile-time-init-build
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A building block for intel#456. Two matchers are three-way comparable, yielding a partial ordering. X => Y means that X > Y (intuition: "greater than" means "more strongly constrained match"). X => Y and Y => X means that X and Y are equivalent.
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "test_matcher.hpp" | ||
|
||
#include <match/ops.hpp> | ||
|
||
#include <catch2/catch_test_macros.hpp> | ||
|
||
#include <compare> | ||
#include <type_traits> | ||
|
||
TEST_CASE("less than", "[match equivalence]") { | ||
using T = test_m<0>; | ||
using U = match::and_t<T, test_m<1>>; | ||
constexpr auto result = T{} <=> U{}; | ||
static_assert(result == std::partial_ordering::less); | ||
static_assert(T{} < U{}); | ||
} | ||
|
||
TEST_CASE("greater than", "[match equivalence]") { | ||
using T = test_m<0>; | ||
using U = match::or_t<T, test_m<1>>; | ||
constexpr auto result = T{} <=> U{}; | ||
static_assert(result == std::partial_ordering::greater); | ||
static_assert(T{} > U{}); | ||
} | ||
|
||
TEST_CASE("equivalent", "[match equivalence]") { | ||
using T = test_m<0>; | ||
constexpr auto result = T{} <=> T{}; | ||
static_assert(result == std::partial_ordering::equivalent); | ||
} | ||
|
||
TEST_CASE("unorderable", "[match equivalence]") { | ||
using T = test_m<0>; | ||
using U = test_m<1>; | ||
constexpr auto result = T{} <=> U{}; | ||
static_assert(result == std::partial_ordering::unordered); | ||
} |