diff options
| author | Phil Nash | 2015-07-13 15:03:04 +0100 |
|---|---|---|
| committer | Phil Nash | 2015-07-13 15:03:04 +0100 |
| commit | 2104ca2aa49712dbfac022d5afe681305b8acb3f (patch) | |
| tree | 9bf656a826f56116b69335246054122ecb687740 /projects/SelfTest/ExceptionTests.cpp | |
| parent | 93a842e2f0e9c51296cfbc81c27004e515643050 (diff) | |
| download | catch3-2104ca2aa49712dbfac022d5afe681305b8acb3f.tar.gz | |
Exception message testing now supports wildcards
- extracted WildcardPattern from TestSpec::NamePattern
Diffstat (limited to 'projects/SelfTest/ExceptionTests.cpp')
| -rw-r--r-- | projects/SelfTest/ExceptionTests.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp index eb24160b..f3b7f41d 100644 --- a/projects/SelfTest/ExceptionTests.cpp +++ b/projects/SelfTest/ExceptionTests.cpp @@ -153,7 +153,21 @@ TEST_CASE( "NotImplemented exception", "" ) REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) ); } -TEST_CASE( "Exception messages can be tested for", "[.][failing]" ) { +TEST_CASE( "Exception messages can be tested for", "" ) { + SECTION( "exact match" ) + REQUIRE_THROWS_WITH( thisThrows(), "expected exception" ); + SECTION( "different case" ) + REQUIRE_THROWS_WITH( thisThrows(), "expecteD Exception" ); + SECTION( "wildcarded" ) { + REQUIRE_THROWS_WITH( thisThrows(), "expected*" ); + REQUIRE_THROWS_WITH( thisThrows(), "*exception" ); + REQUIRE_THROWS_WITH( thisThrows(), "*except*" ); + REQUIRE_THROWS_WITH( thisThrows(), "*exCept*" ); + } +} + +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" ); } |