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

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-11-05 00:42:09 +0100
committerMartin Hořeňovský2022-11-05 20:43:52 +0100
commit3b139ae51a52382d4a86764d7b44e1c3d2eb3eca (patch)
treeb5605cfc5d3834ae41787cc8e52d5a8be6a89e19 /tests/SelfTest
parent5f9d4ef3319f2b13011161662ca2b02d0feb4667 (diff)
downloadcatch3-3b139ae51a52382d4a86764d7b44e1c3d2eb3eca.tar.gz
Decomposer checks for 0 when assuming an int arg was 0 literal
Diffstat (limited to 'tests/SelfTest')
-rw-r--r--tests/SelfTest/IntrospectiveTests/Details.tests.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp
index 8a87dc24..a5a43926 100644
--- a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp
@@ -11,6 +11,8 @@
#include <catch2/internal/catch_case_insensitive_comparisons.hpp>
#include <catch2/internal/catch_optional.hpp>
+#include <helpers/type_with_lit_0_comparisons.hpp>
+
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4702) // unreachable code in the macro expansions
@@ -86,3 +88,44 @@ TEST_CASE("Optional comparison ops", "[optional][approvals]") {
REQUIRE_FALSE( a != b );
}
}
+
+TEST_CASE( "Decomposer checks that the argument is 0 when handling "
+ "only-0-comparable types",
+ "[decomposition][approvals]" ) {
+ TypeWithLit0Comparisons t{};
+
+ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
+ CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
+
+ REQUIRE_THROWS( Catch::Decomposer{} <= t == 42 );
+ REQUIRE_THROWS( Catch::Decomposer{} <= 42 == t );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= t == 0 );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= 0 == t );
+
+ REQUIRE_THROWS( Catch::Decomposer{} <= t != 42 );
+ REQUIRE_THROWS( Catch::Decomposer{} <= 42 != t );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= t != 0 );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= 0 != t );
+
+ REQUIRE_THROWS( Catch::Decomposer{} <= t < 42 );
+ REQUIRE_THROWS( Catch::Decomposer{} <= 42 < t );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= t < 0 );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= 0 < t );
+
+ REQUIRE_THROWS( Catch::Decomposer{} <= t <= 42 );
+ REQUIRE_THROWS( Catch::Decomposer{} <= 42 <= t );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= t <= 0 );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= 0 <= t );
+
+ REQUIRE_THROWS( Catch::Decomposer{} <= t > 42 );
+ REQUIRE_THROWS( Catch::Decomposer{} <= 42 > t );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= t > 0 );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= 0 > t );
+
+ REQUIRE_THROWS( Catch::Decomposer{} <= t >= 42 );
+ REQUIRE_THROWS( Catch::Decomposer{} <= 42 >= t );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= t >= 0 );
+ REQUIRE_NOTHROW( Catch::Decomposer{} <= 0 >= t );
+
+ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
+}