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

Fixed NoAssertions warning

Commit
ca2455e6e6436d18b4d62dddd0595444cceeb3ad
Author
Phil Nash ·
Parents
42213d4c31ac

Files · Download .tar.gz

Changes

 include/internal/catch_run_context.cpp             |  5 +-
 .../SelfTest/Baselines/compact.sw.approved.txt     |  2 +-
 .../SelfTest/Baselines/console.sw.approved.txt     | 82 +++++++++++++++++++++-
 projects/SelfTest/Baselines/junit.sw.approved.txt  |  2 +-
 projects/SelfTest/Baselines/xml.sw.approved.txt    | 28 ++++----
 5 files changed, 99 insertions(+), 20 deletions(-)

diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp
index 2f07a6a0..ca78bfb4 100644
--- a/include/internal/catch_run_context.cpp
+++ b/include/internal/catch_run_context.cpp
@@ -321,12 +321,13 @@ namespace Catch {
                 handleUnexpectedInflightException( m_lastAssertionInfo, translateActiveException(), dummyReaction );
             }
         }
+        Counts assertions = m_totals.assertions - prevAssertions;
+        bool missingAssertions = testForMissingAssertions(assertions);
+
         m_testCaseTracker->close();
         handleUnfinishedSections();
         m_messages.clear();
 
-        Counts assertions = m_totals.assertions - prevAssertions;
-        bool missingAssertions = testForMissingAssertions(assertions);
         SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions);
         m_reporter->sectionEnded(testCaseSectionStats);
     }
diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt
index 68c9e5cf..25e183bb 100644
--- a/projects/SelfTest/Baselines/compact.sw.approved.txt
+++ b/projects/SelfTest/Baselines/compact.sw.approved.txt
@@ -1058,5 +1058,5 @@ Misc.tests.cpp:<line number>: passed: v.size() == 5 for: 5 == 5
 Misc.tests.cpp:<line number>: passed: v.capacity() >= 5 for: 5 >= 5
 Misc.tests.cpp:<line number>: passed:
 Misc.tests.cpp:<line number>: passed:
-Failed 49 test cases, failed 108 assertions.
+Failed 61 test cases, failed 120 assertions.
 
diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt
index 11b89a33..eaf2cb41 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -574,6 +574,15 @@ PASSED:
 with expansion:
   100.3 == Approx( 100.0 )
 
+-------------------------------------------------------------------------------
+An empty test with no assertions
+-------------------------------------------------------------------------------
+Misc.tests.cpp:<line number>
+...............................................................................
+
+
+No assertions in test case 'An empty test with no assertions'
+
 -------------------------------------------------------------------------------
 An expression with side-effects should only be evaluated once
 -------------------------------------------------------------------------------
@@ -2118,6 +2127,9 @@ warning:
   this is a message
   this is a warning
 
+
+No assertions in test case 'INFO and WARN do not abort tests'
+
 -------------------------------------------------------------------------------
 INFO gets logged on failure
 -------------------------------------------------------------------------------
@@ -2530,6 +2542,9 @@ Misc.tests.cpp:<line number>:
 warning:
   This one ran
 
+
+No assertions in test case 'Nice descriptive name'
+
 -------------------------------------------------------------------------------
 Non-std exceptions can be translated
 -------------------------------------------------------------------------------
@@ -4662,6 +4677,15 @@ with expansion:
 A string sent directly to stdout
 A string sent directly to stderr
 A string sent to stderr via clog
+-------------------------------------------------------------------------------
+Sends stuff to stdout and stderr
+-------------------------------------------------------------------------------
+Misc.tests.cpp:<line number>
+...............................................................................
+
+
+No assertions in test case 'Sends stuff to stdout and stderr'
+
 -------------------------------------------------------------------------------
 Some simple comparisons between doubles
 -------------------------------------------------------------------------------
@@ -5390,6 +5414,9 @@ Message.tests.cpp:<line number>:
 FAILED - but was ok:
   CHECK_NOFAIL( 1 == 2 )
 
+
+No assertions in test case 'The NO_FAIL macro reports a failure but does not fail the test'
+
 -------------------------------------------------------------------------------
 This test 'should' fail but doesn't
 -------------------------------------------------------------------------------
@@ -6755,6 +6782,15 @@ Exception.tests.cpp:<line number>: FAILED:
 due to unexpected exception with message:
   unexpected exception
 
+-------------------------------------------------------------------------------
+When unchecked exceptions are thrown, but caught, they do not affect the test
+-------------------------------------------------------------------------------
+Exception.tests.cpp:<line number>
+...............................................................................
+
+
+No assertions in test case 'When unchecked exceptions are thrown, but caught, they do not affect the test'
+
 -------------------------------------------------------------------------------
 Where the LHS is not a simple value
 -------------------------------------------------------------------------------
@@ -6766,6 +6802,9 @@ warning:
   Uncomment the code in this test to check that it gives a sensible compiler
   error
 
+
+No assertions in test case 'Where the LHS is not a simple value'
+
 -------------------------------------------------------------------------------
 Where there is more to the expression after the RHS
 -------------------------------------------------------------------------------
@@ -6777,6 +6816,9 @@ warning:
   Uncomment the code in this test to check that it gives a sensible compiler
   error
 
+
+No assertions in test case 'Where there is more to the expression after the RHS'
+
 -------------------------------------------------------------------------------
 X/level/0/a
 -------------------------------------------------------------------------------
@@ -7143,7 +7185,25 @@ Misc.tests.cpp:<line number>
 Misc.tests.cpp:<line number>:
 PASSED:
 
+-------------------------------------------------------------------------------
+first tag
+-------------------------------------------------------------------------------
+Misc.tests.cpp:<line number>
+...............................................................................
+
+
+No assertions in test case 'first tag'
+
 loose text artifact
+-------------------------------------------------------------------------------
+has printf
+-------------------------------------------------------------------------------
+Tricky.tests.cpp:<line number>
+...............................................................................
+
+
+No assertions in test case 'has printf'
+
 -------------------------------------------------------------------------------
 just failure
 -------------------------------------------------------------------------------
@@ -7154,6 +7214,15 @@ Message.tests.cpp:<line number>: FAILED:
 explicitly with message:
   Previous info should not be seen
 
+-------------------------------------------------------------------------------
+just info
+-------------------------------------------------------------------------------
+Message.tests.cpp:<line number>
+...............................................................................
+
+
+No assertions in test case 'just info'
+
 -------------------------------------------------------------------------------
 long long
 -------------------------------------------------------------------------------
@@ -7572,6 +7641,15 @@ PASSED:
 with expansion:
   "didn|'t" == "didn|'t"
 
+-------------------------------------------------------------------------------
+second tag
+-------------------------------------------------------------------------------
+Misc.tests.cpp:<line number>
+...............................................................................
+
+
+No assertions in test case 'second tag'
+
 -------------------------------------------------------------------------------
 send a single char to INFO
 -------------------------------------------------------------------------------
@@ -8329,6 +8407,6 @@ Misc.tests.cpp:<line number>:
 PASSED:
 
 ===============================================================================
-test cases: 197 | 144 passed |  49 failed |  4 failed as expected
-assertions: 991 | 862 passed | 108 failed | 21 failed as expected
+test cases:  197 | 132 passed |  61 failed |  4 failed as expected
+assertions: 1003 | 862 passed | 120 failed | 21 failed as expected
 
diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt
index 79d8e6d9..4bd6458c 100644
--- a/projects/SelfTest/Baselines/junit.sw.approved.txt
+++ b/projects/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <testsuitesloose text artifact
 >
-  <testsuite name="<exe-name>" errors="15" failures="94" tests="992" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+  <testsuite name="<exe-name>" errors="15" failures="106" tests="1004" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
     <testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index 86557362..a95f74f1 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -600,7 +600,7 @@
       <OverallResult success="true"/>
     </TestCase>
     <TestCase name="An empty test with no assertions" tags="[empty]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
-      <OverallResult success="true"/>
+      <OverallResult success="false"/>
     </TestCase>
     <TestCase name="An expression with side-effects should only be evaluated once" tags="[Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
@@ -2447,7 +2447,7 @@
       <Warning>
         this is a warning
       </Warning>
-      <OverallResult success="true"/>
+      <OverallResult success="false"/>
     </TestCase>
     <TestCase name="INFO gets logged on failure" tags="[.][failing][messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
       <Info>
@@ -2957,7 +2957,7 @@
       <Warning>
         This one ran
       </Warning>
-      <OverallResult success="true"/>
+      <OverallResult success="false"/>
     </TestCase>
     <TestCase name="Non-std exceptions can be translated" tags="[!throws][.][failing]" filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" >
       <Exception filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" >
@@ -5375,7 +5375,7 @@
       <OverallResult success="true"/>
     </TestCase>
     <TestCase name="Sends stuff to stdout and stderr" tags="[.]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
-      <OverallResult success="true">
+      <OverallResult success="false">
         <StdOut>
 A string sent directly to stdout
         </StdOut>
@@ -6183,7 +6183,7 @@ Message from section two
           1 == 2
         </Expanded>
       </Expression>
-      <OverallResult success="true"/>
+      <OverallResult success="false"/>
     </TestCase>
     <TestCase name="This test 'should' fail but doesn't" tags="[!shouldfail][.][failing]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
       <OverallResult success="false"/>
@@ -7699,19 +7699,19 @@ Message from section two
       <OverallResult success="false"/>
     </TestCase>
     <TestCase name="When unchecked exceptions are thrown, but caught, they do not affect the test" tags="[!throws]" filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" >
-      <OverallResult success="true"/>
+      <OverallResult success="false"/>
     </TestCase>
     <TestCase name="Where the LHS is not a simple value" tags="[.][Tricky][failing]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
       <Warning>
         Uncomment the code in this test to check that it gives a sensible compiler error
       </Warning>
-      <OverallResult success="true"/>
+      <OverallResult success="false"/>
     </TestCase>
     <TestCase name="Where there is more to the expression after the RHS" tags="[.][Tricky][failing]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
       <Warning>
         Uncomment the code in this test to check that it gives a sensible compiler error
       </Warning>
-      <OverallResult success="true"/>
+      <OverallResult success="false"/>
     </TestCase>
     <TestCase name="X/level/0/a" tags="[Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
       <OverallResult success="true"/>
@@ -8052,11 +8052,11 @@ Message from section two
       <OverallResult success="true"/>
     </TestCase>
     <TestCase name="first tag" tags="[tag1]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
-      <OverallResult success="true"/>
+      <OverallResult success="false"/>
     </TestCase>
     <TestCase name="has printf" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
 loose text artifact
-      <OverallResult success="true"/>
+      <OverallResult success="false"/>
     </TestCase>
     <TestCase name="just failure" tags="[.][fail][isolated info][messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
       <Failure filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
@@ -8065,7 +8065,7 @@ loose text artifact
       <OverallResult success="false"/>
     </TestCase>
     <TestCase name="just info" tags="[info][isolated info][messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
-      <OverallResult success="true"/>
+      <OverallResult success="false"/>
     </TestCase>
     <TestCase name="long long" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
@@ -8512,7 +8512,7 @@ loose text artifact
       <OverallResult success="true"/>
     </TestCase>
     <TestCase name="second tag" tags="[tag2]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
-      <OverallResult success="true"/>
+      <OverallResult success="false"/>
     </TestCase>
     <TestCase name="send a single char to INFO" tags="[.][failing]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Info>
@@ -9257,7 +9257,7 @@ loose text artifact
       </Section>
       <OverallResult success="true"/>
     </TestCase>
-    <OverallResults successes="862" failures="109" expectedFailures="21"/>
+    <OverallResults successes="862" failures="121" expectedFailures="21"/>
   </Group>
-  <OverallResults successes="862" failures="108" expectedFailures="21"/>
+  <OverallResults successes="862" failures="120" expectedFailures="21"/>
 </Catch>