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

This commit is contained in:
Phil Nash 2017-12-02 21:01:59 +03:00
parent 57c346a46d
commit dfa817ae73
2 changed files with 8 additions and 4 deletions

View File

@ -111,15 +111,19 @@ namespace Catch {
} }
void RunContext::assertionEnded(AssertionResult const & result) { void RunContext::assertionEnded(AssertionResult const & result) {
m_prevPassed = m_totals.assertions.passed;
if (result.getResultType() == ResultWas::Ok) { if (result.getResultType() == ResultWas::Ok) {
m_totals.assertions.passed++; m_totals.assertions.passed++;
m_lastAssertionPassed = true;
} else if (!result.isOk()) { } else if (!result.isOk()) {
m_lastAssertionPassed = false;
if( m_activeTestCase->getTestCaseInfo().okToFail() ) if( m_activeTestCase->getTestCaseInfo().okToFail() )
m_totals.assertions.failedButOk++; m_totals.assertions.failedButOk++;
else else
m_totals.assertions.failed++; 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 // 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. // and should be let to clear themselves out.
@ -251,11 +255,11 @@ namespace Catch {
} }
bool RunContext::lastAssertionPassed() { bool RunContext::lastAssertionPassed() {
return m_totals.assertions.passed == (m_prevPassed + 1); return m_lastAssertionPassed;
} }
void RunContext::assertionPassed() { void RunContext::assertionPassed() {
m_prevPassed = m_totals.assertions.passed; m_lastAssertionPassed = true;
++m_totals.assertions.passed; ++m_totals.assertions.passed;
resetAssertionInfo(); resetAssertionInfo();
} }

View File

@ -164,7 +164,7 @@ namespace Catch {
std::vector<SectionEndInfo> m_unfinishedSections; std::vector<SectionEndInfo> m_unfinishedSections;
std::vector<ITracker*> m_activeSections; std::vector<ITracker*> m_activeSections;
TrackerContext m_trackerContext; TrackerContext m_trackerContext;
std::size_t m_prevPassed = 0; bool m_lastAssertionPassed = false;
bool m_shouldReportUnexpected = true; bool m_shouldReportUnexpected = true;
bool m_includeSuccessfulResults; bool m_includeSuccessfulResults;
}; };