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

summaryrefslogtreecommitdiffhomepage
path: root/projects
diff options
context:
space:
mode:
authorPhil Nash2015-07-13 15:03:04 +0100
committerPhil Nash2015-07-13 15:03:04 +0100
commit2104ca2aa49712dbfac022d5afe681305b8acb3f (patch)
tree9bf656a826f56116b69335246054122ecb687740 /projects
parent93a842e2f0e9c51296cfbc81c27004e515643050 (diff)
downloadcatch3-2104ca2aa49712dbfac022d5afe681305b8acb3f.tar.gz
Exception message testing now supports wildcards
- extracted WildcardPattern from TestSpec::NamePattern
Diffstat (limited to 'projects')
-rw-r--r--projects/SelfTest/Baselines/console.std.approved.txt6
-rw-r--r--projects/SelfTest/Baselines/console.sw.approved.txt53
-rw-r--r--projects/SelfTest/Baselines/junit.sw.approved.txt7
-rw-r--r--projects/SelfTest/Baselines/xml.sw.approved.txt72
-rw-r--r--projects/SelfTest/ExceptionTests.cpp16
-rw-r--r--projects/XCode/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj2
6 files changed, 146 insertions, 10 deletions
diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt
index de86a473..63530052 100644
--- a/projects/SelfTest/Baselines/console.std.approved.txt
+++ b/projects/SelfTest/Baselines/console.std.approved.txt
@@ -398,7 +398,7 @@ due to unexpected exception with message:
3.14
-------------------------------------------------------------------------------
-Exception messages can be tested for
+Mismatching exception messages failing the test
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
@@ -797,6 +797,6 @@ with expansion:
"first" == "second"
===============================================================================
-test cases: 156 | 116 passed | 39 failed | 1 failed as expected
-assertions: 767 | 674 passed | 80 failed | 13 failed as expected
+test cases: 157 | 117 passed | 39 failed | 1 failed as expected
+assertions: 774 | 681 passed | 80 failed | 13 failed as expected
diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt
index 6e191f56..1919c1c2 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -1279,6 +1279,7 @@ PASSED:
-------------------------------------------------------------------------------
Exception messages can be tested for
+ exact match
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
...............................................................................
@@ -1287,6 +1288,54 @@ ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
+-------------------------------------------------------------------------------
+Exception messages can be tested for
+ different case
+-------------------------------------------------------------------------------
+ExceptionTests.cpp:<line number>
+...............................................................................
+
+ExceptionTests.cpp:<line number>:
+PASSED:
+ REQUIRE_THROWS_WITH( thisThrows(), "expecteD Exception" )
+
+-------------------------------------------------------------------------------
+Exception messages can be tested for
+ wildcarded
+-------------------------------------------------------------------------------
+ExceptionTests.cpp:<line number>
+...............................................................................
+
+ExceptionTests.cpp:<line number>:
+PASSED:
+ REQUIRE_THROWS_WITH( thisThrows(), "expected*" )
+
+ExceptionTests.cpp:<line number>:
+PASSED:
+ REQUIRE_THROWS_WITH( thisThrows(), "*exception" )
+
+ExceptionTests.cpp:<line number>:
+PASSED:
+ REQUIRE_THROWS_WITH( thisThrows(), "*except*" )
+
+ExceptionTests.cpp:<line number>:
+PASSED:
+ REQUIRE_THROWS_WITH( thisThrows(), "*exCept*" )
+
+-------------------------------------------------------------------------------
+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" )
+
ExceptionTests.cpp:<line number>: FAILED:
REQUIRE_THROWS_WITH( thisThrows(), "should fail" )
with expansion:
@@ -7959,6 +8008,6 @@ with expansion:
true
===============================================================================
-test cases: 156 | 100 passed | 55 failed | 1 failed as expected
-assertions: 787 | 674 passed | 100 failed | 13 failed as expected
+test cases: 157 | 101 passed | 55 failed | 1 failed as expected
+assertions: 794 | 681 passed | 100 failed | 13 failed as expected
diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt
index 36e31fe8..95d4f9a2 100644
--- a/projects/SelfTest/Baselines/junit.sw.approved.txt
+++ b/projects/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,5 +1,5 @@
<testsuites>
- <testsuite name="all tests" errors="12" failures="88" tests="787" hostname="tbd" time="{duration}" timestamp="tbd">
+ <testsuite name="all tests" errors="12" failures="88" tests="794" hostname="tbd" time="{duration}" timestamp="tbd">
<testcase classname="global" name="toString(enum)" time="{duration}"/>
<testcase classname="global" name="toString(enum w/operator&lt;&lt;)" time="{duration}"/>
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
@@ -251,7 +251,10 @@ ExceptionTests.cpp:<line number>
</error>
</testcase>
<testcase classname="global" name="NotImplemented exception" time="{duration}"/>
- <testcase classname="global" name="Exception messages can be tested for" time="{duration}">
+ <testcase classname="Exception messages can be tested for" name="exact match" time="{duration}"/>
+ <testcase classname="Exception messages can be tested for" name="different case" time="{duration}"/>
+ <testcase classname="Exception messages can be tested for" name="wildcarded" time="{duration}"/>
+ <testcase classname="global" name="Mismatching exception messages failing the test" time="{duration}">
<failure message="expected exception" type="REQUIRE_THROWS_WITH">
ExceptionTests.cpp:<line number>
</failure>
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index 01144a0d..0d06a704 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -1597,6 +1597,74 @@
<OverallResult success="true"/>
</TestCase>
<TestCase name="Exception messages can be tested for">
+ <Section name="exact match">
+ <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
+ <Original>
+ thisThrows(), &quot;expected exception&quot;
+ </Original>
+ <Expanded>
+ thisThrows(), &quot;expected exception&quot;
+ </Expanded>
+ </Expression>
+ <OverallResults successes="1" failures="0" expectedFailures="0"/>
+ </Section>
+ <Section name="different case">
+ <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
+ <Original>
+ thisThrows(), &quot;expecteD Exception&quot;
+ </Original>
+ <Expanded>
+ thisThrows(), &quot;expecteD Exception&quot;
+ </Expanded>
+ </Expression>
+ <OverallResults successes="1" failures="0" expectedFailures="0"/>
+ </Section>
+ <Section name="wildcarded">
+ <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
+ <Original>
+ thisThrows(), &quot;expected*&quot;
+ </Original>
+ <Expanded>
+ thisThrows(), &quot;expected*&quot;
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
+ <Original>
+ thisThrows(), &quot;*exception&quot;
+ </Original>
+ <Expanded>
+ thisThrows(), &quot;*exception&quot;
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
+ <Original>
+ thisThrows(), &quot;*except*&quot;
+ </Original>
+ <Expanded>
+ thisThrows(), &quot;*except*&quot;
+ </Expanded>
+ </Expression>
+ <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
+ <Original>
+ thisThrows(), &quot;*exCept*&quot;
+ </Original>
+ <Expanded>
+ thisThrows(), &quot;*exCept*&quot;
+ </Expanded>
+ </Expression>
+ <OverallResults successes="4" failures="0" expectedFailures="0"/>
+ </Section>
+ <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(), &quot;expected exception&quot;
+ </Original>
+ <Expanded>
+ thisThrows(), &quot;expected exception&quot;
+ </Expanded>
+ </Expression>
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" >
<Original>
thisThrows(), &quot;expected exception&quot;
@@ -8239,7 +8307,7 @@ there&quot;
</Section>
<OverallResult success="true"/>
</TestCase>
- <OverallResults successes="674" failures="100" expectedFailures="13"/>
+ <OverallResults successes="681" failures="100" expectedFailures="13"/>
</Group>
- <OverallResults successes="674" failures="100" expectedFailures="13"/>
+ <OverallResults successes="681" failures="100" expectedFailures="13"/>
</Catch>
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" );
}
diff --git a/projects/XCode/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj b/projects/XCode/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj
index 047fa70e..47e8c66a 100644
--- a/projects/XCode/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj
+++ b/projects/XCode/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj
@@ -108,6 +108,7 @@
269831E719121CA500BB0CE0 /* catch_reporter_compact.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_compact.hpp; sourceTree = "<group>"; };
26AEAF1617BEA18E009E32C9 /* catch_platform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_platform.h; sourceTree = "<group>"; };
26DACF2F17206D3400A21326 /* catch_text.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_text.h; sourceTree = "<group>"; };
+ 26DFD3B11B53F84700FD6F16 /* catch_wildcard_pattern.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_wildcard_pattern.hpp; sourceTree = "<group>"; };
26E1B7D119213BC900812682 /* CmdLineTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CmdLineTests.cpp; path = ../../../SelfTest/CmdLineTests.cpp; sourceTree = "<group>"; };
4A084F1C15DACEEA0027E631 /* catch_test_case_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_info.hpp; sourceTree = "<group>"; };
4A3D7DD01503869D005F9203 /* catch_matchers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_matchers.hpp; sourceTree = "<group>"; };
@@ -470,6 +471,7 @@
2656C226192A77EF0040DB02 /* catch_suppress_warnings.h */,
2656C227192A78410040DB02 /* catch_reenable_warnings.h */,
263F7A4519A66608009474C2 /* catch_fatal_condition.hpp */,
+ 26DFD3B11B53F84700FD6F16 /* catch_wildcard_pattern.hpp */,
);
name = Infrastructure;
sourceTree = "<group>";