diff options
| author | Martin Hořeňovský | 2022-11-01 15:01:43 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-11-04 19:24:44 +0100 |
| commit | ec59cd8736b7ee8fcd69c76c71c2a0b72293b00c (patch) | |
| tree | 1cb8b66b56e6fe4fe6307e88e32c18d69c2a89a7 /tests/SelfTest/UsageTests | |
| parent | d7f8c36e4cb856ee632b4ca01f8d5847984aa276 (diff) | |
| download | catch3-ec59cd8736b7ee8fcd69c76c71c2a0b72293b00c.tar.gz | |
Support decomposing types that only compare with literal 0
This is primarily done to support new `std::*_ordering` types,
but the refactoring also supports any other type with this
property.
The compilation overhead is surprisingly low. Testing it with
clang on a Linux machine, compiling our SelfTest project takes
only 2-3% longer with these changes than it takes otherwise.
Closes #2555
Diffstat (limited to 'tests/SelfTest/UsageTests')
| -rw-r--r-- | tests/SelfTest/UsageTests/Compilation.tests.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/SelfTest/UsageTests/Compilation.tests.cpp b/tests/SelfTest/UsageTests/Compilation.tests.cpp index 5998ce62..a61a9674 100644 --- a/tests/SelfTest/UsageTests/Compilation.tests.cpp +++ b/tests/SelfTest/UsageTests/Compilation.tests.cpp @@ -6,6 +6,8 @@ // SPDX-License-Identifier: BSL-1.0 +#include <helpers/type_with_lit_0_comparisons.hpp> + #include <type_traits> // Setup for #1403 -- look for global overloads of operator << for classes @@ -310,3 +312,20 @@ TEST_CASE("ADL universal operators don't hijack expression deconstruction", "[co REQUIRE(0 & adl::always_true{}); REQUIRE(0 ^ adl::always_true{}); } + +TEST_CASE( "#2555 - types that can only be compared with 0 literal (not int/long) are supported", "[compilation][approvals]" ) { + REQUIRE( TypeWithLit0Comparisons{} < 0 ); + REQUIRE_FALSE( 0 < TypeWithLit0Comparisons{} ); + REQUIRE( TypeWithLit0Comparisons{} <= 0 ); + REQUIRE_FALSE( 0 > TypeWithLit0Comparisons{} ); + + REQUIRE( TypeWithLit0Comparisons{} > 0 ); + REQUIRE_FALSE( 0 > TypeWithLit0Comparisons{} ); + REQUIRE( TypeWithLit0Comparisons{} >= 0 ); + REQUIRE_FALSE( 0 >= TypeWithLit0Comparisons{} ); + + REQUIRE( TypeWithLit0Comparisons{} == 0 ); + REQUIRE_FALSE( 0 == TypeWithLit0Comparisons{} ); + REQUIRE( TypeWithLit0Comparisons{} != 0 ); + REQUIRE_FALSE( 0 != TypeWithLit0Comparisons{} ); +} |