Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2012-11-21 08:19:23 +0000
committerPhil Nash2012-11-21 08:19:23 +0000
commit5d248c98bfb5974cd624cc95e94a9c149fa3348a (patch)
tree8b9e1aa2b4a2529ce40938124301e06c49846e7c /include
parentdb48a6dfdafcc970eac39f085526a12c23a2fd9b (diff)
downloadcatch3-5d248c98bfb5974cd624cc95e94a9c149fa3348a.tar.gz
Moved code that detects absence of assertions closer to where end of test case is reported (ready for merging).
Also now considers info macros when warning (i.e. an empty test case with an INFO() will not warn).
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_runner_impl.hpp27
-rw-r--r--include/internal/catch_totals.hpp5
2 files changed, 20 insertions, 12 deletions
diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp
index 98381ccd..303f958c 100644
--- a/include/internal/catch_runner_impl.hpp
+++ b/include/internal/catch_runner_impl.hpp
@@ -115,12 +115,22 @@ namespace Catch {
}
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
+ Totals deltaTotals = m_totals.delta( prevTotals );
+ if( deltaTotals.assertions.total() == 0 &&
+ deltaTotals.assertions.info == 0 &&
+ ( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) ) {
+ m_totals.assertions.failed++;
+ deltaTotals = m_totals.delta( prevTotals );
+ m_reporter->NoAssertionsInTestCase( m_runningTest->getTestCaseInfo().getName() );
+ }
+ m_totals.testCases += deltaTotals.testCases;
+
+ m_reporter->EndTestCase( testInfo, deltaTotals, redirectedCout, redirectedCerr );
+
+
delete m_runningTest;
m_runningTest = NULL;
- Totals deltaTotals = m_totals.delta( prevTotals );
- m_totals.testCases += deltaTotals.testCases;
- m_reporter->EndTestCase( testInfo, deltaTotals, redirectedCout, redirectedCerr );
return deltaTotals;
}
@@ -158,7 +168,10 @@ namespace Catch {
}
if( result.getResultType() == ResultWas::Info )
+ {
m_assertionResults.push_back( result );
+ m_totals.assertions.info++;
+ }
else
m_reporter->Result( result );
@@ -252,7 +265,6 @@ namespace Catch {
try {
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCaseInfo().getLineInfo(), "", ResultDisposition::Normal );
m_runningTest->reset();
- Counts prevAssertions = m_totals.assertions;
if( m_reporter->shouldRedirectStdout() ) {
StreamRedirect coutRedir( std::cout, redirectedCout );
StreamRedirect cerrRedir( std::cerr, redirectedCerr );
@@ -261,13 +273,6 @@ namespace Catch {
else {
m_runningTest->getTestCaseInfo().invoke();
}
- Counts assertions = m_totals.assertions - prevAssertions;
- if( assertions.total() == 0 &&
- ( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) &&
- !m_runningTest->hasSections() ) {
- m_totals.assertions.failed++;
- m_reporter->NoAssertionsInTestCase( m_runningTest->getTestCaseInfo().getName() );
- }
m_runningTest->ranToCompletion();
}
catch( TestFailureException& ) {
diff --git a/include/internal/catch_totals.hpp b/include/internal/catch_totals.hpp
index 03832a2e..9f854580 100644
--- a/include/internal/catch_totals.hpp
+++ b/include/internal/catch_totals.hpp
@@ -13,17 +13,19 @@
namespace Catch {
struct Counts {
- Counts() : passed( 0 ), failed( 0 ) {}
+ Counts() : passed( 0 ), failed( 0 ), info( 0 ) {}
Counts operator - ( const Counts& other ) const {
Counts diff;
diff.passed = passed - other.passed;
diff.failed = failed - other.failed;
+ diff.info = info - other.info;
return diff;
}
Counts& operator += ( const Counts& other ) {
passed += other.passed;
failed += other.failed;
+ info += other.info;
return *this;
}
@@ -33,6 +35,7 @@ namespace Catch {
std::size_t passed;
std::size_t failed;
+ std::size_t info;
};
struct Totals {