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

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest
diff options
context:
space:
mode:
authorlbckmnn2022-12-12 00:40:47 +0100
committerGitHub2022-12-12 00:40:47 +0100
commit9c0533a90504b2b1c308dc7cc77ff194f81046e2 (patch)
tree8cd45ddd221a06f4df00b2f977ee6436cd2fe724 /tests/SelfTest
parented02710b83c2a3ddbca20b86f3d26d2fb99d2d02 (diff)
downloadcatch3-9c0533a90504b2b1c308dc7cc77ff194f81046e2.tar.gz
Add MessageMatches matcher for exception (#2570)
Diffstat (limited to 'tests/SelfTest')
-rw-r--r--tests/SelfTest/Baselines/automake.sw.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/automake.sw.multi.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/compact.sw.approved.txt8
-rw-r--r--tests/SelfTest/Baselines/compact.sw.multi.approved.txt8
-rw-r--r--tests/SelfTest/Baselines/console.std.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/console.sw.approved.txt30
-rw-r--r--tests/SelfTest/Baselines/console.sw.multi.approved.txt30
-rw-r--r--tests/SelfTest/Baselines/junit.sw.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/junit.sw.multi.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/tap.sw.approved.txt10
-rw-r--r--tests/SelfTest/Baselines/tap.sw.multi.approved.txt10
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.approved.txt2
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt2
-rw-r--r--tests/SelfTest/Baselines/xml.sw.approved.txt39
-rw-r--r--tests/SelfTest/Baselines/xml.sw.multi.approved.txt39
-rw-r--r--tests/SelfTest/UsageTests/Matchers.tests.cpp15
18 files changed, 189 insertions, 18 deletions
diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt
index e29de92b..332439a7 100644
--- a/tests/SelfTest/Baselines/automake.sw.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.approved.txt
@@ -142,6 +142,7 @@ Nor would this
:test-result: PASS Exception as a value (e.g. in REQUIRE_THROWS_MATCHES) can be stringified
:test-result: FAIL Exception matchers that fail
:test-result: PASS Exception matchers that succeed
+:test-result: PASS Exception message can be matched
:test-result: PASS Exception messages can be tested for
:test-result: PASS Exceptions matchers
:test-result: FAIL Expected exceptions that don't throw or unexpected exceptions fail the test
diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
index 3ac53920..a7461ae5 100644
--- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
@@ -140,6 +140,7 @@
:test-result: PASS Exception as a value (e.g. in REQUIRE_THROWS_MATCHES) can be stringified
:test-result: FAIL Exception matchers that fail
:test-result: PASS Exception matchers that succeed
+:test-result: PASS Exception message can be matched
:test-result: PASS Exception messages can be tested for
:test-result: PASS Exceptions matchers
:test-result: FAIL Expected exceptions that don't throw or unexpected exceptions fail the test
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index 5073c080..ff6b2875 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -572,6 +572,10 @@ Matchers.tests.cpp:<line number>: failed: throwsSpecialException( 3 ), SpecialEx
Matchers.tests.cpp:<line number>: failed: throwsSpecialException( 4 ), SpecialException, ExceptionMatcher{ 1 } for: SpecialException::what special exception has value of 1
Matchers.tests.cpp:<line number>: passed: throwsSpecialException( 1 ), SpecialException, ExceptionMatcher{ 1 } for: SpecialException::what special exception has value of 1
Matchers.tests.cpp:<line number>: passed: throwsSpecialException( 2 ), SpecialException, ExceptionMatcher{ 2 } for: SpecialException::what special exception has value of 2
+Matchers.tests.cpp:<line number>: passed: throwsDerivedException(), DerivedException, MessageMatches( StartsWith( "Derived" ) ) for: DerivedException::what matches "starts with: "Derived""
+Matchers.tests.cpp:<line number>: passed: throwsDerivedException(), DerivedException, MessageMatches( EndsWith( "::what" ) ) for: DerivedException::what matches "ends with: "::what""
+Matchers.tests.cpp:<line number>: passed: throwsDerivedException(), DerivedException, MessageMatches( !StartsWith( "::what" ) ) for: DerivedException::what matches "not starts with: "::what""
+Matchers.tests.cpp:<line number>: passed: throwsSpecialException( 2 ), SpecialException, MessageMatches( StartsWith( "Special" ) ) for: SpecialException::what matches "starts with: "Special""
Exception.tests.cpp:<line number>: passed: thisThrows(), "expected exception" for: "expected exception" equals: "expected exception"
Exception.tests.cpp:<line number>: passed: thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) for: "expected exception" equals: "expected exception" (case insensitive)
Exception.tests.cpp:<line number>: passed: thisThrows(), StartsWith( "expected" ) for: "expected exception" starts with: "expected"
@@ -2459,7 +2463,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
Misc.tests.cpp:<line number>: passed:
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
diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
index af348dda..d11bdbae 100644
--- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
@@ -570,6 +570,10 @@ Matchers.tests.cpp:<line number>: failed: throwsSpecialException( 3 ), SpecialEx
Matchers.tests.cpp:<line number>: failed: throwsSpecialException( 4 ), SpecialException, ExceptionMatcher{ 1 } for: SpecialException::what special exception has value of 1
Matchers.tests.cpp:<line number>: passed: throwsSpecialException( 1 ), SpecialException, ExceptionMatcher{ 1 } for: SpecialException::what special exception has value of 1
Matchers.tests.cpp:<line number>: passed: throwsSpecialException( 2 ), SpecialException, ExceptionMatcher{ 2 } for: SpecialException::what special exception has value of 2
+Matchers.tests.cpp:<line number>: passed: throwsDerivedException(), DerivedException, MessageMatches( StartsWith( "Derived" ) ) for: DerivedException::what matches "starts with: "Derived""
+Matchers.tests.cpp:<line number>: passed: throwsDerivedException(), DerivedException, MessageMatches( EndsWith( "::what" ) ) for: DerivedException::what matches "ends with: "::what""
+Matchers.tests.cpp:<line number>: passed: throwsDerivedException(), DerivedException, MessageMatches( !StartsWith( "::what" ) ) for: DerivedException::what matches "not starts with: "::what""
+Matchers.tests.cpp:<line number>: passed: throwsSpecialException( 2 ), SpecialException, MessageMatches( StartsWith( "Special" ) ) for: SpecialException::what matches "starts with: "Special""
Exception.tests.cpp:<line number>: passed: thisThrows(), "expected exception" for: "expected exception" equals: "expected exception"
Exception.tests.cpp:<line number>: passed: thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) for: "expected exception" equals: "expected exception" (case insensitive)
Exception.tests.cpp:<line number>: passed: thisThrows(), StartsWith( "expected" ) for: "expected exception" starts with: "expected"
@@ -2451,7 +2455,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
Misc.tests.cpp:<line number>: passed:
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
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index 5ad8447a..39fd845b 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -1394,6 +1394,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
-test cases: 394 | 318 passed | 69 failed | 7 failed as expected
-assertions: 2144 | 1989 passed | 128 failed | 27 failed as expected
+test cases: 395 | 319 passed | 69 failed | 7 failed as expected
+assertions: 2148 | 1993 passed | 128 failed | 27 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index 1ef94ee5..57fa6239 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -4283,6 +4283,32 @@ 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
diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
index c281374f..6e5faa96 100644
--- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
@@ -4281,6 +4281,32 @@ 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
-------------------------------------------------------------------------------
@@ -17510,6 +17536,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
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index bd983051..e521aec6 100644
--- a/tests/SelfTest/Baselines/junit.sw.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
- <testsuite name="<exe-name>" errors="17" failures="126" tests="2159" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="17" failures="126" tests="2163" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@@ -634,6 +634,7 @@ Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Exception matchers that succeed" time="{duration}" status="run"/>
+ <testcase classname="<exe-name>.global" name="Exception message can be matched" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Exception messages can be tested for/exact match" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Exception messages can be tested for/different case" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Exception messages can be tested for/wildcarded" time="{duration}" status="run"/>
diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
index 3231c3e8..cde93ecf 100644
--- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
- <testsuite name="<exe-name>" errors="17" failures="126" tests="2159" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="17" failures="126" tests="2163" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@@ -633,6 +633,7 @@ Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Exception matchers that succeed" time="{duration}" status="run"/>
+ <testcase classname="<exe-name>.global" name="Exception message can be matched" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Exception messages can be tested for/exact match" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Exception messages can be tested for/different case" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Exception messages can be tested for/wildcarded" time="{duration}" status="run"/>
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index 122e3dda..e778d549 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -1156,6 +1156,7 @@ Matchers.tests.cpp:<line number>
</failure>
</testCase>
<testCase name="Exception matchers that succeed" duration="{duration}"/>
+ <testCase name="Exception message can be matched" duration="{duration}"/>
<testCase name="Exceptions matchers" duration="{duration}"/>
<testCase name="Floating point matchers: double/Relative" duration="{duration}"/>
<testCase name="Floating point matchers: double/Relative/Some subnormal values" duration="{duration}"/>
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
index 8025e455..47fab5b5 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
@@ -1155,6 +1155,7 @@ Matchers.tests.cpp:<line number>
</failure>
</testCase>
<testCase name="Exception matchers that succeed" duration="{duration}"/>
+ <testCase name="Exception message can be matched" duration="{duration}"/>
<testCase name="Exceptions matchers" duration="{duration}"/>
<testCase name="Floating point matchers: double/Relative" duration="{duration}"/>
<testCase name="Floating point matchers: double/Relative/Some subnormal values" duration="{duration}"/>
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index 1832282a..595c1ae7 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -1076,6 +1076,14 @@ not ok {test-number} - throwsSpecialException( 4 ), SpecialException, ExceptionM
ok {test-number} - throwsSpecialException( 1 ), SpecialException, ExceptionMatcher{ 1 } for: SpecialException::what special exception has value of 1
# Exception matchers that succeed
ok {test-number} - throwsSpecialException( 2 ), SpecialException, ExceptionMatcher{ 2 } for: SpecialException::what special exception has value of 2
+# Exception message can be matched
+ok {test-number} - throwsDerivedException(), DerivedException, MessageMatches( StartsWith( "Derived" ) ) for: DerivedException::what matches "starts with: "Derived""
+# Exception message can be matched
+ok {test-number} - throwsDerivedException(), DerivedException, MessageMatches( EndsWith( "::what" ) ) for: DerivedException::what matches "ends with: "::what""
+# Exception message can be matched
+ok {test-number} - throwsDerivedException(), DerivedException, MessageMatches( !StartsWith( "::what" ) ) for: DerivedException::what matches "not starts with: "::what""
+# Exception message can be matched
+ok {test-number} - throwsSpecialException( 2 ), SpecialException, MessageMatches( StartsWith( "Special" ) ) for: SpecialException::what matches "starts with: "Special""
# Exception messages can be tested for
ok {test-number} - thisThrows(), "expected exception" for: "expected exception" equals: "expected exception"
# Exception messages can be tested for
@@ -4322,5 +4330,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
-1..2159
+1..2163
diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
index 4446141d..b0fc4c6c 100644
--- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
@@ -1074,6 +1074,14 @@ not ok {test-number} - throwsSpecialException( 4 ), SpecialException, ExceptionM
ok {test-number} - throwsSpecialException( 1 ), SpecialException, ExceptionMatcher{ 1 } for: SpecialException::what special exception has value of 1
# Exception matchers that succeed
ok {test-number} - throwsSpecialException( 2 ), SpecialException, ExceptionMatcher{ 2 } for: SpecialException::what special exception has value of 2
+# Exception message can be matched
+ok {test-number} - throwsDerivedException(), DerivedException, MessageMatches( StartsWith( "Derived" ) ) for: DerivedException::what matches "starts with: "Derived""
+# Exception message can be matched
+ok {test-number} - throwsDerivedException(), DerivedException, MessageMatches( EndsWith( "::what" ) ) for: DerivedException::what matches "ends with: "::what""
+# Exception message can be matched
+ok {test-number} - throwsDerivedException(), DerivedException, MessageMatches( !StartsWith( "::what" ) ) for: DerivedException::what matches "not starts with: "::what""
+# Exception message can be matched
+ok {test-number} - throwsSpecialException( 2 ), SpecialException, MessageMatches( StartsWith( "Special" ) ) for: SpecialException::what matches "starts with: "Special""
# Exception messages can be tested for
ok {test-number} - thisThrows(), "expected exception" for: "expected exception" equals: "expected exception"
# Exception messages can be tested for
@@ -4314,5 +4322,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
-1..2159
+1..2163
diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt
index 7049f2b6..58ad2aed 100644
--- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt
+++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt
@@ -345,6 +345,8 @@ Matchers.tests.cpp:<line number>|nexpression failed|n REQUIRE_THROWS_MATCHES( t
##teamcity[testFinished name='Exception matchers that fail' duration="{duration}"]
##teamcity[testStarted name='Exception matchers that succeed']
##teamcity[testFinished name='Exception matchers that succeed' duration="{duration}"]
+##teamcity[testStarted name='Exception message can be matched']
+##teamcity[testFinished name='Exception message can be matched' duration="{duration}"]
##teamcity[testStarted name='Exception messages can be tested for']
##teamcity[testFinished name='Exception messages can be tested for' duration="{duration}"]
##teamcity[testStarted name='Exceptions matchers']
diff --git a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt
index 96de7dd8..2f539ced 100644
--- a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt
@@ -345,6 +345,8 @@ Matchers.tests.cpp:<line number>|nexpression failed|n REQUIRE_THROWS_MATCHES( t
##teamcity[testFinished name='Exception matchers that fail' duration="{duration}"]
##teamcity[testStarted name='Exception matchers that succeed']
##teamcity[testFinished name='Exception matchers that succeed' duration="{duration}"]
+##teamcity[testStarted name='Exception message can be matched']
+##teamcity[testFinished name='Exception message can be matched' duration="{duration}"]
##teamcity[testStarted name='Exception messages can be tested for']
##teamcity[testFinished name='Exception messages can be tested for' duration="{duration}"]
##teamcity[testStarted name='Exceptions matchers']
diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt
index 4ff2e4f2..cb49412e 100644
--- a/tests/SelfTest/Baselines/xml.sw.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.approved.txt
@@ -4794,6 +4794,41 @@ C
</Expression>
<OverallResult success="true"/>
</TestCase>
+ <TestCase name="Exception message can be matched" tags="[!throws][exceptions][matchers]" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+ <Expression success="true" type="REQUIRE_THROWS_MATCHES" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+ <Original>
+ throwsDerivedException(), DerivedException, MessageMatches( StartsWith( "Derived" ) )
+ </Original>
+ <Expanded>
+ DerivedException::what matches "starts with: "Derived""
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE_THROWS_MATCHES" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+ <Original>
+ throwsDerivedException(), DerivedException, MessageMatches( EndsWith( "::what" ) )
+ </Original>
+ <Expanded>
+ DerivedException::what matches "ends with: "::what""
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE_THROWS_MATCHES" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+ <Original>
+ throwsDerivedException(), DerivedException, MessageMatches( !StartsWith( "::what" ) )
+ </Original>
+ <Expanded>
+ DerivedException::what matches "not starts with: "::what""
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE_THROWS_MATCHES" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+ <Original>
+ throwsSpecialException( 2 ), SpecialException, MessageMatches( StartsWith( "Special" ) )
+ </Original>
+ <Expanded>
+ SpecialException::what matches "starts with: "Special""
+ </Expanded>
+ </Expression>
+ <OverallResult success="true"/>
+ </TestCase>
<TestCase name="Exception messages can be tested for" tags="[!throws]" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" >
<Section name="exact match" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" >
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" >
@@ -20483,6 +20518,6 @@ loose text artifact
</Section>
<OverallResult success="true"/>
</TestCase>
- <OverallResults successes="1989" failures="143" expectedFailures="27"/>
- <OverallResultsCases successes="304" failures="83" expectedFailures="7"/>
+ <OverallResults successes="1993" failures="143" expectedFailures="27"/>
+ <OverallResultsCases successes="305" failures="83" expectedFailures="7"/>
</Catch2TestRun>
diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
index a0096170..b6146646 100644
--- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
@@ -4794,6 +4794,41 @@ C
</Expression>
<OverallResult success="true"/>
</TestCase>
+ <TestCase name="Exception message can be matched" tags="[!throws][exceptions][matchers]" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+ <Expression success="true" type="REQUIRE_THROWS_MATCHES" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+ <Original>
+ throwsDerivedException(), DerivedException, MessageMatches( StartsWith( "Derived" ) )
+ </Original>
+ <Expanded>
+ DerivedException::what matches "starts with: "Derived""
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE_THROWS_MATCHES" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+ <Original>
+ throwsDerivedException(), DerivedException, MessageMatches( EndsWith( "::what" ) )
+ </Original>
+ <Expanded>
+ DerivedException::what matches "ends with: "::what""
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE_THROWS_MATCHES" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+ <Original>
+ throwsDerivedException(), DerivedException, MessageMatches( !StartsWith( "::what" ) )
+ </Original>
+ <Expanded>
+ DerivedException::what matches "not starts with: "::what""
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE_THROWS_MATCHES" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
+ <Original>
+ throwsSpecialException( 2 ), SpecialException, MessageMatches( StartsWith( "Special" ) )
+ </Original>
+ <Expanded>
+ SpecialException::what matches "starts with: "Special""
+ </Expanded>
+ </Expression>
+ <OverallResult success="true"/>
+ </TestCase>
<TestCase name="Exception messages can be tested for" tags="[!throws]" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" >
<Section name="exact match" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" >
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="tests/<exe-name>/UsageTests/Exception.tests.cpp" >
@@ -20482,6 +20517,6 @@ There is no extra whitespace here
</Section>
<OverallResult success="true"/>
</TestCase>
- <OverallResults successes="1989" failures="143" expectedFailures="27"/>
- <OverallResultsCases successes="304" failures="83" expectedFailures="7"/>
+ <OverallResults successes="1993" failures="143" expectedFailures="27"/>
+ <OverallResultsCases successes="305" failures="83" expectedFailures="7"/>
</Catch2TestRun>
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;