Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Secondary fix for #270 (addresses same issue with CHECK)

Commit
1bccc03213b374e30b7bcfddcddffa8d7de1b680
Author
Phil Nash ·
Parents
a176b9373813

Files · Download .tar.gz

Changes

 include/internal/catch_capture.hpp                   |  2 +-
 projects/SelfTest/Baselines/console.std.approved.txt | 17 +++++++++++++++--
 projects/SelfTest/Baselines/console.sw.approved.txt  | 17 +++++++++++++++--
 projects/SelfTest/Baselines/junit.sw.approved.txt    | 10 ++++++++--
 projects/SelfTest/Baselines/xml.sw.approved.txt      | 20 +++++++++++++++++---
 projects/SelfTest/ExceptionTests.cpp                 |  8 +++++++-
 6 files changed, 63 insertions(+), 11 deletions(-)

diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index 41b7670d..451bc41c 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -87,7 +87,7 @@ struct TestFailureException{};
             throw; \
         } catch( ... ) { \
             INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), \
-                resultDisposition, expr ); \
+                Catch::ResultDisposition::Normal, expr ); \
         } \
     } while( Catch::isTrue( false ) )
 
diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt
index 20634449..5f23df59 100644
--- a/projects/SelfTest/Baselines/console.std.approved.txt
+++ b/projects/SelfTest/Baselines/console.std.approved.txt
@@ -332,7 +332,8 @@ due to unexpected exception with message:
   expected exception
 
 -------------------------------------------------------------------------------
-When unchecked exceptions are thrown during a require the test should fail
+When unchecked exceptions are thrown during a REQUIRE the test should abort
+fail
 -------------------------------------------------------------------------------
 ExceptionTests.cpp:<line number>
 ...............................................................................
@@ -342,6 +343,18 @@ ExceptionTests.cpp:<line number>: FAILED:
 due to unexpected exception with message:
   expected exception
 
+-------------------------------------------------------------------------------
+When unchecked exceptions are thrown during a CHECK the test should abort and
+fail
+-------------------------------------------------------------------------------
+ExceptionTests.cpp:<line number>
+...............................................................................
+
+ExceptionTests.cpp:<line number>: FAILED:
+  CHECK( thisThrows() == 0 )
+due to unexpected exception with message:
+  expected exception
+
 -------------------------------------------------------------------------------
 Unexpected custom exceptions can be translated
 -------------------------------------------------------------------------------
@@ -761,5 +774,5 @@ with expansion:
   "first" == "second"
 
 ===============================================================================
-123 test cases - 37 failed (659 assertions - 92 failed)
+124 test cases - 38 failed (660 assertions - 93 failed)
 
diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt
index 0999e0f8..12f74797 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -1111,7 +1111,8 @@ due to unexpected exception with message:
   expected exception
 
 -------------------------------------------------------------------------------
-When unchecked exceptions are thrown during a require the test should fail
+When unchecked exceptions are thrown during a REQUIRE the test should abort
+fail
 -------------------------------------------------------------------------------
 ExceptionTests.cpp:<line number>
 ...............................................................................
@@ -1121,6 +1122,18 @@ ExceptionTests.cpp:<line number>: FAILED:
 due to unexpected exception with message:
   expected exception
 
+-------------------------------------------------------------------------------
+When unchecked exceptions are thrown during a CHECK the test should abort and
+fail
+-------------------------------------------------------------------------------
+ExceptionTests.cpp:<line number>
+...............................................................................
+
+ExceptionTests.cpp:<line number>: FAILED:
+  CHECK( thisThrows() == 0 )
+due to unexpected exception with message:
+  expected exception
+
 -------------------------------------------------------------------------------
 When unchecked exceptions are thrown, but caught, they do not affect the test
 -------------------------------------------------------------------------------
@@ -6969,5 +6982,5 @@ with expansion:
   true
 
 ===============================================================================
-123 test cases - 52 failed (678 assertions - 111 failed)
+124 test cases - 53 failed (679 assertions - 112 failed)
 
diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt
index 7e171097..90b2c6c3 100644
--- a/projects/SelfTest/Baselines/junit.sw.approved.txt
+++ b/projects/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,5 +1,5 @@
 <testsuites>
-  <testsuite name="~_" errors="11" failures="100" tests="678" hostname="tbd" time="{duration}" timestamp="tbd">
+  <testsuite name="~_" errors="12" failures="100" tests="679" hostname="tbd" time="{duration}" timestamp="tbd">
     <testcase classname="global" name="Some simple comparisons between doubles" time="{duration}"/>
     <testcase classname="global" name="Approximate comparisons with different epsilons" time="{duration}"/>
     <testcase classname="global" name="Approximate comparisons with floats" time="{duration}"/>
@@ -210,9 +210,15 @@ expected exception
 ExceptionTests.cpp:<line number>
       </error>
     </testcase>
-    <testcase classname="global" name="When unchecked exceptions are thrown during a require the test should fail" time="{duration}">
+    <testcase classname="global" name="When unchecked exceptions are thrown during a REQUIRE the test should abort fail" time="{duration}">
       <error message="thisThrows() == 0" type="REQUIRE">
 expected exception
+ExceptionTests.cpp:<line number>
+      </error>
+    </testcase>
+    <testcase classname="global" name="When unchecked exceptions are thrown during a CHECK the test should abort and fail" time="{duration}">
+      <error message="thisThrows() == 0" type="CHECK">
+expected exception
 ExceptionTests.cpp:<line number>
       </error>
     </testcase>
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index c1cabda3..ada68ac3 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -1426,7 +1426,21 @@
       </Expression>
       <OverallResult success="false"/>
     </TestCase>
-    <TestCase name="When unchecked exceptions are thrown during a require the test should fail">
+    <TestCase name="When unchecked exceptions are thrown during a REQUIRE the test should abort fail">
+      <Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ExceptionTests.cpp" >
+        <Original>
+          thisThrows() == 0
+        </Original>
+        <Expanded>
+          thisThrows() == 0
+        </Expanded>
+        <Exception filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ExceptionTests.cpp" >
+          expected exception
+        </Exception>
+      </Expression>
+      <OverallResult success="false"/>
+    </TestCase>
+    <TestCase name="When unchecked exceptions are thrown during a CHECK the test should abort and fail">
       <Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ExceptionTests.cpp" >
         <Original>
           thisThrows() == 0
@@ -7228,7 +7242,7 @@ there&quot;
       </Section>
       <OverallResult success="true"/>
     </TestCase>
-    <OverallResults successes="567" failures="111"/>
+    <OverallResults successes="567" failures="112"/>
   </Group>
-  <OverallResults successes="567" failures="111"/>
+  <OverallResults successes="567" failures="112"/>
 </Catch>
diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp
index a193b226..9a325c55 100644
--- a/projects/SelfTest/ExceptionTests.cpp
+++ b/projects/SelfTest/ExceptionTests.cpp
@@ -66,12 +66,18 @@ TEST_CASE( "When unchecked exceptions are thrown from functions they are always
     CHECK( thisThrows() == 0 );
 }
 
-TEST_CASE( "When unchecked exceptions are thrown during a require the test should fail", "[.][failing]" )
+TEST_CASE( "When unchecked exceptions are thrown during a REQUIRE the test should abort fail", "[.][failing]" )
 {
     REQUIRE( thisThrows() == 0 );
     FAIL( "This should never happen" );
 }
 
+TEST_CASE( "When unchecked exceptions are thrown during a CHECK the test should abort and fail", "[.][failing]" )
+{
+    CHECK( thisThrows() == 0 );
+    FAIL( "This should never happen" );
+}
+
 TEST_CASE( "When unchecked exceptions are thrown, but caught, they do not affect the test", "" )
 {
     try