mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
Exception message assertions now work with matchers
This commit is contained in:
@@ -798,5 +798,5 @@ with expansion:
|
||||
|
||||
===============================================================================
|
||||
test cases: 157 | 117 passed | 39 failed | 1 failed as expected
|
||||
assertions: 774 | 681 passed | 80 failed | 13 failed as expected
|
||||
assertions: 773 | 680 passed | 80 failed | 13 failed as expected
|
||||
|
||||
|
@@ -1297,7 +1297,7 @@ ExceptionTests.cpp:<line number>
|
||||
|
||||
ExceptionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expecteD Exception" )
|
||||
REQUIRE_THROWS_WITH( thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) )
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Exception messages can be tested for
|
||||
@@ -1308,19 +1308,19 @@ ExceptionTests.cpp:<line number>
|
||||
|
||||
ExceptionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expected*" )
|
||||
REQUIRE_THROWS_WITH( thisThrows(), StartsWith( "expected" ) )
|
||||
|
||||
ExceptionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "*exception" )
|
||||
REQUIRE_THROWS_WITH( thisThrows(), EndsWith( "exception" ) )
|
||||
|
||||
ExceptionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "*except*" )
|
||||
REQUIRE_THROWS_WITH( thisThrows(), Contains( "except" ) )
|
||||
|
||||
ExceptionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "*exCept*" )
|
||||
REQUIRE_THROWS_WITH( thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) )
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Mismatching exception messages failing the test
|
||||
@@ -1328,10 +1328,6 @@ Mismatching exception messages failing the test
|
||||
ExceptionTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ExceptionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
|
||||
|
||||
ExceptionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
|
||||
@@ -8009,5 +8005,5 @@ with expansion:
|
||||
|
||||
===============================================================================
|
||||
test cases: 157 | 101 passed | 55 failed | 1 failed as expected
|
||||
assertions: 794 | 681 passed | 100 failed | 13 failed as expected
|
||||
assertions: 793 | 680 passed | 100 failed | 13 failed as expected
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<testsuites>
|
||||
<testsuite name="all tests" errors="12" failures="88" tests="794" hostname="tbd" time="{duration}" timestamp="tbd">
|
||||
<testsuite name="all tests" errors="12" failures="88" tests="793" hostname="tbd" time="{duration}" timestamp="tbd">
|
||||
<testcase classname="global" name="toString(enum)" time="{duration}"/>
|
||||
<testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/>
|
||||
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
|
||||
|
@@ -1611,10 +1611,10 @@
|
||||
<Section name="different case">
|
||||
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
|
||||
<Original>
|
||||
thisThrows(), "expecteD Exception"
|
||||
thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No )
|
||||
</Original>
|
||||
<Expanded>
|
||||
thisThrows(), "expecteD Exception"
|
||||
thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
@@ -1622,34 +1622,34 @@
|
||||
<Section name="wildcarded">
|
||||
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
|
||||
<Original>
|
||||
thisThrows(), "expected*"
|
||||
thisThrows(), StartsWith( "expected" )
|
||||
</Original>
|
||||
<Expanded>
|
||||
thisThrows(), "expected*"
|
||||
thisThrows(), StartsWith( "expected" )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
|
||||
<Original>
|
||||
thisThrows(), "*exception"
|
||||
thisThrows(), EndsWith( "exception" )
|
||||
</Original>
|
||||
<Expanded>
|
||||
thisThrows(), "*exception"
|
||||
thisThrows(), EndsWith( "exception" )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
|
||||
<Original>
|
||||
thisThrows(), "*except*"
|
||||
thisThrows(), Contains( "except" )
|
||||
</Original>
|
||||
<Expanded>
|
||||
thisThrows(), "*except*"
|
||||
thisThrows(), Contains( "except" )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
|
||||
<Original>
|
||||
thisThrows(), "*exCept*"
|
||||
thisThrows(), Contains( "exCept", Catch::CaseSensitive::No )
|
||||
</Original>
|
||||
<Expanded>
|
||||
thisThrows(), "*exCept*"
|
||||
thisThrows(), Contains( "exCept", Catch::CaseSensitive::No )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
||||
@@ -1657,14 +1657,6 @@
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Mismatching exception messages failing the test">
|
||||
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
|
||||
<Original>
|
||||
thisThrows(), "expected exception"
|
||||
</Original>
|
||||
<Expanded>
|
||||
thisThrows(), "expected exception"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
|
||||
<Original>
|
||||
thisThrows(), "expected exception"
|
||||
@@ -8307,7 +8299,7 @@ there"
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="681" failures="100" expectedFailures="13"/>
|
||||
<OverallResults successes="680" failures="100" expectedFailures="13"/>
|
||||
</Group>
|
||||
<OverallResults successes="681" failures="100" expectedFailures="13"/>
|
||||
<OverallResults successes="680" failures="100" expectedFailures="13"/>
|
||||
</Catch>
|
||||
|
@@ -154,20 +154,21 @@ TEST_CASE( "NotImplemented exception", "" )
|
||||
}
|
||||
|
||||
TEST_CASE( "Exception messages can be tested for", "" ) {
|
||||
using namespace Catch::Matchers;
|
||||
SECTION( "exact match" )
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
|
||||
SECTION( "different case" )
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expecteD Exception" );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) );
|
||||
SECTION( "wildcarded" ) {
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expected*" );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "*exception" );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "*except*" );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "*exCept*" );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), StartsWith( "expected" ) );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), EndsWith( "exception" ) );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), Contains( "except" ) );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "Mismatching exception messages failing the test", "[.][failing]" ) {
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "should fail" );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
|
||||
}
|
||||
|
Reference in New Issue
Block a user