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

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/CompilationTests.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2017-02-09 12:57:01 +0100
committerMartin Hořeňovský2017-02-09 12:57:01 +0100
commit73159ace3d84b3cf01a126d6edefde196cceb621 (patch)
tree0b56ba78f3030bc2755bd782e7ce697289980e98 /projects/SelfTest/CompilationTests.cpp
parent9952dda524e5578d808e2c267fff0799f228cbd2 (diff)
downloadcatch3-73159ace3d84b3cf01a126d6edefde196cceb621.tar.gz
REQUIRE_THROWS_AS now catches exception by const&
Prevents some warnings caused by catching complex types by value. Closes #542
Diffstat (limited to 'projects/SelfTest/CompilationTests.cpp')
-rw-r--r--projects/SelfTest/CompilationTests.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/projects/SelfTest/CompilationTests.cpp b/projects/SelfTest/CompilationTests.cpp
index f12372bf..635c62c8 100644
--- a/projects/SelfTest/CompilationTests.cpp
+++ b/projects/SelfTest/CompilationTests.cpp
@@ -22,3 +22,21 @@ TEST_CASE("#809") {
foo f; f.i = 42;
REQUIRE(42 == f);
}
+
+// ------------------------------------------------------------------
+// REQUIRE_THROWS_AS was changed to catch exceptions by const&
+// using type traits. This means that this should compile cleanly
+
+// Provides indirection to prevent unreachable-code warnings
+void throws_int(bool b) {
+ if (b) {
+ throw 1;
+ }
+}
+
+TEST_CASE("#542") {
+ CHECK_THROWS_AS(throws_int(true), int);
+ CHECK_THROWS_AS(throws_int(true), int&);
+ CHECK_THROWS_AS(throws_int(true), const int);
+ CHECK_THROWS_AS(throws_int(true), const int&);
+}