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

Made SUCCESS variadic too (optional stream)

Commit
557b3bdbe331650ac936eaaba6cc7b173128f673
Author
Phil Nash ·
Parents
2851b4a55aed

Files · Download .tar.gz

Changes

 include/catch.hpp                                    |  6 ++++--
 projects/SelfTest/Baselines/console.std.approved.txt |  2 +-
 projects/SelfTest/Baselines/console.sw.approved.txt  | 11 ++++++++++-
 projects/SelfTest/Baselines/junit.sw.approved.txt    |  3 ++-
 projects/SelfTest/Baselines/xml.sw.approved.txt      |  7 +++++--
 projects/SelfTest/MessageTests.cpp                   | 10 ++++++----
 6 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/include/catch.hpp b/include/catch.hpp
index 39820ebc..df162dff 100644
--- a/include/catch.hpp
+++ b/include/catch.hpp
@@ -72,7 +72,6 @@
 
 #define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" )
 #define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN", msg )
-#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg )
 #define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" )
 #define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
 #define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
@@ -83,12 +82,14 @@
     #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
     #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
     #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ )
+    #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ )
 #else
     #define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
     #define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
     #define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
     #define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
     #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg )
+    #define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg )
 #endif
 #define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
 
@@ -134,7 +135,6 @@
 
 #define INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" )
 #define WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN", msg )
-#define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg )
 #define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" )
 #define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" )
 #define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" )
@@ -145,12 +145,14 @@
     #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
     #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
     #define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ )
+    #define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ )
 #else
     #define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
     #define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
     #define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
     #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
     #define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg )
+    #define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg )
 #endif
 #define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
 
diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt
index 7ff5146f..54d3ee6f 100644
--- a/projects/SelfTest/Baselines/console.std.approved.txt
+++ b/projects/SelfTest/Baselines/console.std.approved.txt
@@ -750,5 +750,5 @@ with expansion:
   "first" == "second"
 
 ===============================================================================
-121 test cases - 36 failed (674 assertions - 91 failed)
+122 test cases - 36 failed (675 assertions - 91 failed)
 
diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt
index 6d696ef3..e0c15c68 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -2580,6 +2580,15 @@ MessageTests.cpp:<line number>
 
 MessageTests.cpp:<line number>: FAILED:
 
+-------------------------------------------------------------------------------
+SUCCESS does not require an argument
+-------------------------------------------------------------------------------
+MessageTests.cpp:<line number>
+...............................................................................
+
+MessageTests.cpp:<line number>:
+PASSED:
+
 -------------------------------------------------------------------------------
 Output from all sections is reported
   one
@@ -7131,5 +7140,5 @@ with expansion:
   true
 
 ===============================================================================
-121 test cases - 51 failed (693 assertions - 110 failed)
+122 test cases - 51 failed (694 assertions - 110 failed)
 
diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt
index 675a7be1..b105e986 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="10" failures="100" tests="693" hostname="tbd" time="{duration}" timestamp="tbd">
+  <testsuite name="~_" errors="10" failures="100" tests="694" 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}"/>
@@ -267,6 +267,7 @@ MessageTests.cpp:<line number>
 MessageTests.cpp:<line number>
       </failure>
     </testcase>
+    <testcase classname="global" name="SUCCESS does not require an argument" time="{duration}"/>
     <testcase classname="Output from all sections is reported" name="one" time="{duration}">
       <failure type="FAIL">
 Message from section one
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index 65477307..dda010b1 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -2734,6 +2734,9 @@
       <Failure/>
       <OverallResult success="false"/>
     </TestCase>
+    <TestCase name="SUCCESS does not require an argument">
+      <OverallResult success="true"/>
+    </TestCase>
     <TestCase name="Output from all sections is reported">
       <Section name="one">
         <Failure>
@@ -7402,7 +7405,7 @@ there&quot;
       </Section>
       <OverallResult success="true"/>
     </TestCase>
-    <OverallResults successes="583" failures="110"/>
+    <OverallResults successes="584" failures="110"/>
   </Group>
-  <OverallResults successes="583" failures="110"/>
+  <OverallResults successes="584" failures="110"/>
 </Catch>
diff --git a/projects/SelfTest/MessageTests.cpp b/projects/SelfTest/MessageTests.cpp
index 55098b2c..0e4a3313 100644
--- a/projects/SelfTest/MessageTests.cpp
+++ b/projects/SelfTest/MessageTests.cpp
@@ -47,15 +47,17 @@ TEST_CASE( "INFO gets logged on failure, even if captured before successful asse
 
 TEST_CASE( "FAIL aborts the test", "[failing][messages][.]" )
 {
-	if( Catch::isTrue( true ) )
-        FAIL( "This is a " << "failure" );    // This should output the message and abort
+    FAIL( "This is a " << "failure" );    // This should output the message and abort
 }
 
 #ifdef CATCH_CONFIG_VARIADIC_MACROS
 TEST_CASE( "FAIL does not require an argument", "[failing][messages][.]" )
 {
-	if( Catch::isTrue( true ) )
-        FAIL();
+    FAIL();
+}
+TEST_CASE( "SUCCESS does not require an argument", "[messages][.]" )
+{
+   SUCCEED();
 }
 #endif