mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-30 01:03:30 +01:00
Refactored missing assertions handling
This commit is contained in:
parent
b80280f428
commit
e8cf726a23
@ -194,6 +194,15 @@ namespace Catch {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool testForMissingAssertions( Counts& assertions ) {
|
||||||
|
if( assertions.total() != 0 ||
|
||||||
|
!m_config->warnAboutMissingAssertions() ||
|
||||||
|
m_testCaseTracker->currentSectionHasChildren() )
|
||||||
|
return false;
|
||||||
|
m_totals.assertions.failed++;
|
||||||
|
assertions.failed++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void sectionEnded( SectionInfo const& info, Counts const& prevAssertions ) {
|
virtual void sectionEnded( SectionInfo const& info, Counts const& prevAssertions ) {
|
||||||
if( std::uncaught_exception() ) {
|
if( std::uncaught_exception() ) {
|
||||||
@ -202,15 +211,8 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Counts assertions = m_totals.assertions - prevAssertions;
|
Counts assertions = m_totals.assertions - prevAssertions;
|
||||||
bool missingAssertions = false;
|
bool missingAssertions = testForMissingAssertions( assertions );
|
||||||
if( assertions.total() == 0 &&
|
|
||||||
m_config->warnAboutMissingAssertions() &&
|
|
||||||
!m_testCaseTracker->currentSectionHasChildren() ) {
|
|
||||||
m_totals.assertions.failed++;
|
|
||||||
assertions.failed++;
|
|
||||||
missingAssertions = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
m_testCaseTracker->leaveSection();
|
m_testCaseTracker->leaveSection();
|
||||||
|
|
||||||
m_reporter->sectionEnded( SectionStats( info, assertions, missingAssertions ) );
|
m_reporter->sectionEnded( SectionStats( info, assertions, missingAssertions ) );
|
||||||
@ -300,16 +302,7 @@ namespace Catch {
|
|||||||
m_messages.clear();
|
m_messages.clear();
|
||||||
|
|
||||||
Counts assertions = m_totals.assertions - prevAssertions;
|
Counts assertions = m_totals.assertions - prevAssertions;
|
||||||
// !TBD?
|
bool missingAssertions = testForMissingAssertions( assertions );
|
||||||
bool missingAssertions = false;
|
|
||||||
if( assertions.total() == 0 &&
|
|
||||||
m_config->warnAboutMissingAssertions() &&
|
|
||||||
!m_testCaseTracker->currentSectionHasChildren() ) {
|
|
||||||
m_totals.assertions.failed++;
|
|
||||||
assertions.failed++;
|
|
||||||
missingAssertions = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SectionStats testCaseSectionStats( testCaseSection, assertions, missingAssertions );
|
SectionStats testCaseSectionStats( testCaseSection, assertions, missingAssertions );
|
||||||
m_reporter->sectionEnded( testCaseSectionStats );
|
m_reporter->sectionEnded( testCaseSectionStats );
|
||||||
|
Loading…
Reference in New Issue
Block a user