diff options
| author | lbckmnn | 2022-12-12 00:40:47 +0100 |
|---|---|---|
| committer | GitHub | 2022-12-12 00:40:47 +0100 |
| commit | 9c0533a90504b2b1c308dc7cc77ff194f81046e2 (patch) | |
| tree | 8cd45ddd221a06f4df00b2f977ee6436cd2fe724 /tests/SelfTest/UsageTests | |
| parent | ed02710b83c2a3ddbca20b86f3d26d2fb99d2d02 (diff) | |
| download | catch3-9c0533a90504b2b1c308dc7cc77ff194f81046e2.tar.gz | |
Add MessageMatches matcher for exception (#2570)
Diffstat (limited to 'tests/SelfTest/UsageTests')
| -rw-r--r-- | tests/SelfTest/UsageTests/Matchers.tests.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/SelfTest/UsageTests/Matchers.tests.cpp b/tests/SelfTest/UsageTests/Matchers.tests.cpp index 1ce3158b..b2239572 100644 --- a/tests/SelfTest/UsageTests/Matchers.tests.cpp +++ b/tests/SelfTest/UsageTests/Matchers.tests.cpp @@ -660,6 +660,21 @@ TEST_CASE( "Exceptions matchers", "[matchers][exceptions][!throws]" ) { Message( "SpecialException::what" ) ); } +TEST_CASE( "Exception message can be matched", "[matchers][exceptions][!throws]" ) { + REQUIRE_THROWS_MATCHES( throwsDerivedException(), + DerivedException, + MessageMatches( StartsWith( "Derived" ) ) ); + REQUIRE_THROWS_MATCHES( throwsDerivedException(), + DerivedException, + MessageMatches( EndsWith( "::what" ) ) ); + REQUIRE_THROWS_MATCHES( throwsDerivedException(), + DerivedException, + MessageMatches( !StartsWith( "::what" ) ) ); + REQUIRE_THROWS_MATCHES( throwsSpecialException( 2 ), + SpecialException, + MessageMatches( StartsWith( "Special" ) ) ); +} + struct CheckedTestingMatcher : Catch::Matchers::MatcherBase<int> { mutable bool matchCalled = false; bool matchSucceeds = false; |