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

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/ExceptionTests.cpp
diff options
context:
space:
mode:
authorPhil Nash2015-07-15 23:02:25 +0100
committerPhil Nash2015-07-15 23:02:25 +0100
commit72868920bb44c07b632ac351f05485b5b189f970 (patch)
tree9cb6533cfcb3a2b15e30aa7d1240ac708a3aeb2a /projects/SelfTest/ExceptionTests.cpp
parent8342ae8dfb61ca5d90821a6cd0c320da25f7f0cb (diff)
downloadcatch3-72868920bb44c07b632ac351f05485b5b189f970.tar.gz
Exception message assertions now work with matchers
Diffstat (limited to 'projects/SelfTest/ExceptionTests.cpp')
-rw-r--r--projects/SelfTest/ExceptionTests.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp
index f3b7f41d..3826c58b 100644
--- a/projects/SelfTest/ExceptionTests.cpp
+++ b/projects/SelfTest/ExceptionTests.cpp
@@ -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" );
}