Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest/UsageTests/Compilation.tests.cpp
diff options
context:
space:
mode:
authorAlCash072020-12-19 15:36:19 -0800
committerMartin Hořeňovský2021-06-08 23:36:06 +0200
commitc77ba5314a82b468f9591b7ec7e90ada67a7c664 (patch)
tree534aadbc889602721da2c80dd26e7e179f99e642 /tests/SelfTest/UsageTests/Compilation.tests.cpp
parent65c9a1d31a338f28ef93cd61c475efc40f6cc42e (diff)
downloadcatch3-c77ba5314a82b468f9591b7ec7e90ada67a7c664.tar.gz
Fix decomposing in presence of universal ADL-found operators
Closes #2121
Diffstat (limited to 'tests/SelfTest/UsageTests/Compilation.tests.cpp')
-rw-r--r--tests/SelfTest/UsageTests/Compilation.tests.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/SelfTest/UsageTests/Compilation.tests.cpp b/tests/SelfTest/UsageTests/Compilation.tests.cpp
index 5f8c82a3..cce190f2 100644
--- a/tests/SelfTest/UsageTests/Compilation.tests.cpp
+++ b/tests/SelfTest/UsageTests/Compilation.tests.cpp
@@ -277,3 +277,42 @@ namespace {
TEST_CASE("Immovable types are supported in basic assertions", "[compilation][.approvals]") {
REQUIRE(ImmovableType{} == ImmovableType{});
}
+
+namespace adl {
+
+struct always_true {
+ explicit operator bool() const { return true; }
+};
+
+#define COMPILATION_TEST_DEFINE_UNIVERSAL_OPERATOR(op) \
+template <class T, class U> \
+auto operator op (T&&, U&&) { \
+ return always_true{}; \
+}
+
+COMPILATION_TEST_DEFINE_UNIVERSAL_OPERATOR(==)
+COMPILATION_TEST_DEFINE_UNIVERSAL_OPERATOR(!=)
+COMPILATION_TEST_DEFINE_UNIVERSAL_OPERATOR(<)
+COMPILATION_TEST_DEFINE_UNIVERSAL_OPERATOR(>)
+COMPILATION_TEST_DEFINE_UNIVERSAL_OPERATOR(<=)
+COMPILATION_TEST_DEFINE_UNIVERSAL_OPERATOR(>=)
+COMPILATION_TEST_DEFINE_UNIVERSAL_OPERATOR(|)
+COMPILATION_TEST_DEFINE_UNIVERSAL_OPERATOR(&)
+COMPILATION_TEST_DEFINE_UNIVERSAL_OPERATOR(^)
+
+#undef COMPILATION_TEST_DEFINE_UNIVERSAL_OPERATOR
+
+}
+
+TEST_CASE("ADL universal operators don't hijack expression deconstruction", "[compilation][.approvals]") {
+ REQUIRE(adl::always_true{});
+ REQUIRE(0 == adl::always_true{});
+ REQUIRE(0 != adl::always_true{});
+ REQUIRE(0 < adl::always_true{});
+ REQUIRE(0 > adl::always_true{});
+ REQUIRE(0 <= adl::always_true{});
+ REQUIRE(0 >= adl::always_true{});
+ REQUIRE(0 | adl::always_true{});
+ REQUIRE(0 & adl::always_true{});
+ REQUIRE(0 ^ adl::always_true{});
+}