mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 05:45:39 +02:00
Add MessageMatches matcher for exception (#2570)
This commit is contained in:
@@ -4282,6 +4282,32 @@ Matchers.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
SpecialException::what special exception has value of 2
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Exception message can be matched
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THROWS_MATCHES( throwsDerivedException(), DerivedException, MessageMatches( StartsWith( "Derived" ) ) )
|
||||
with expansion:
|
||||
DerivedException::what matches "starts with: "Derived""
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THROWS_MATCHES( throwsDerivedException(), DerivedException, MessageMatches( EndsWith( "::what" ) ) )
|
||||
with expansion:
|
||||
DerivedException::what matches "ends with: "::what""
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THROWS_MATCHES( throwsDerivedException(), DerivedException, MessageMatches( !StartsWith( "::what" ) ) )
|
||||
with expansion:
|
||||
DerivedException::what matches "not starts with: "::what""
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THROWS_MATCHES( throwsSpecialException( 2 ), SpecialException, MessageMatches( StartsWith( "Special" ) ) )
|
||||
with expansion:
|
||||
SpecialException::what matches "starts with: "Special""
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Exception messages can be tested for
|
||||
exact match
|
||||
@@ -17518,6 +17544,6 @@ Misc.tests.cpp:<line number>
|
||||
Misc.tests.cpp:<line number>: PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 394 | 304 passed | 83 failed | 7 failed as expected
|
||||
assertions: 2159 | 1989 passed | 143 failed | 27 failed as expected
|
||||
test cases: 395 | 305 passed | 83 failed | 7 failed as expected
|
||||
assertions: 2163 | 1993 passed | 143 failed | 27 failed as expected
|
||||
|
||||
|
Reference in New Issue
Block a user