mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
REQUIRE_THROWS_AS now catches exception by const&
Prevents some warnings caused by catching complex types by value. Closes #542
This commit is contained in:
@@ -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&);
|
||||
}
|
||||
|
Reference in New Issue
Block a user