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) {
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();
}

View File

@ -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;
};