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

Just track whether last assertion passed directly, rather than deduce it from counts

Commit
dfa817ae73486bdff61336b60967407324e5e1f4
Author
Phil Nash ·
Parents
57c346a46d00

Files · Download .tar.gz

Changes

 include/internal/catch_run_context.cpp | 10 +++++++---
 include/internal/catch_run_context.h   |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp
index 0e9cf983..44e3fb37 100644
--- a/include/internal/catch_run_context.cpp
+++ b/include/internal/catch_run_context.cpp
@@ -111,15 +111,19 @@ namespace Catch {
     }
 
     void RunContext::assertionEnded(AssertionResult const & result) {
-        m_prevPassed = m_totals.assertions.passed;
         if (result.getResultType() == ResultWas::Ok) {
             m_totals.assertions.passed++;
+            m_lastAssertionPassed = true;
         } else if (!result.isOk()) {
+            m_lastAssertionPassed = false;
             if( m_activeTestCase->getTestCaseInfo().okToFail() )
                 m_totals.assertions.failedButOk++;
             else
                 m_totals.assertions.failed++;
         }
+        else {
+            m_lastAssertionPassed = true;
+        }
 
         // We have no use for the return value (whether messages should be cleared), because messages were made scoped
         // and should be let to clear themselves out.
@@ -251,11 +255,11 @@ namespace Catch {
     }
 
     bool RunContext::lastAssertionPassed() {
-         return m_totals.assertions.passed == (m_prevPassed + 1);
+         return m_lastAssertionPassed;
     }
 
     void RunContext::assertionPassed() {
-        m_prevPassed = m_totals.assertions.passed;
+        m_lastAssertionPassed = true;
         ++m_totals.assertions.passed;
         resetAssertionInfo();
     }
diff --git a/include/internal/catch_run_context.h b/include/internal/catch_run_context.h
index 617baba1..88767711 100644
--- a/include/internal/catch_run_context.h
+++ b/include/internal/catch_run_context.h
@@ -164,7 +164,7 @@ namespace Catch {
         std::vector<SectionEndInfo> m_unfinishedSections;
         std::vector<ITracker*> m_activeSections;
         TrackerContext m_trackerContext;
-        std::size_t m_prevPassed = 0;
+        bool m_lastAssertionPassed = false;
         bool m_shouldReportUnexpected = true;
         bool m_includeSuccessfulResults;
     };