diff --git a/Test/MiscTests.cpp b/Test/MiscTests.cpp index afe42baf..ab380dc2 100644 --- a/Test/MiscTests.cpp +++ b/Test/MiscTests.cpp @@ -54,9 +54,6 @@ TEST_CASE( "./mixed/Misc/Sections/nested2", "nested SECTION tests" ) SECTION( "s1", "doesn't equal" ) { - REQUIRE( a != b ); - REQUIRE( b != a ); - SECTION( "s2", "equal" ) { REQUIRE( a == b ); @@ -68,7 +65,7 @@ TEST_CASE( "./mixed/Misc/Sections/nested2", "nested SECTION tests" ) } SECTION( "s4", "less than" ) { - REQUIRE( b < a ); + REQUIRE( a < b ); } } } diff --git a/Test/TestMain.cpp b/Test/TestMain.cpp index 7db62baa..04855fc8 100644 --- a/Test/TestMain.cpp +++ b/Test/TestMain.cpp @@ -20,7 +20,7 @@ TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results" runner.runMatching( "./succeeding/*" ); INFO( runner.getOutput() ); - CHECK( runner.getSuccessCount() == 197 ); + CHECK( runner.getSuccessCount() == 199 ); CHECK( runner.getFailureCount() == 0 ); runner.runMatching( "./failing/*" ); @@ -34,7 +34,7 @@ TEST_CASE( "meta/Misc/Sections", "looped tests" ) Catch::EmbeddedRunner runner; runner.runMatching( "./mixed/Misc/Sections/nested2" ); - CHECK( runner.getSuccessCount() == 9 ); - CHECK( runner.getFailureCount() == 2 ); + CHECK( runner.getSuccessCount() == 2 ); + CHECK( runner.getFailureCount() == 1 ); } diff --git a/catch_reporter_basic.hpp b/catch_reporter_basic.hpp index 655ab175..23374583 100644 --- a/catch_reporter_basic.hpp +++ b/catch_reporter_basic.hpp @@ -142,7 +142,7 @@ namespace Catch const std::string /*description*/ ) { - m_sectionSpan = sectionName; + m_sectionSpans.push_back( SpanInfo( sectionName ) ); } /////////////////////////////////////////////////////////////////////////// @@ -153,13 +153,14 @@ namespace Catch std::size_t failed ) { - if( m_sectionSpan.emitted && !m_sectionSpan.name.empty() ) + SpanInfo& sectionSpan = m_sectionSpans.back(); + if( sectionSpan.emitted && !sectionSpan.name.empty() ) { m_config.stream() << "[End of section: '" << sectionName << "'. "; ReportCounts( succeeded, failed ); m_config.stream() << "]\n" << std::endl; - m_sectionSpan = SpanInfo(); } + m_sectionSpans.pop_back(); } /////////////////////////////////////////////////////////////////////////// @@ -260,16 +261,29 @@ namespace Catch m_testSpan.emitted = true; } - if( !m_sectionSpan.emitted && !m_sectionSpan.name.empty() ) + if( !m_sectionSpans.empty() ) { - if( m_firstSectionInTestCase ) + SpanInfo& sectionSpan = m_sectionSpans.back(); + if( !sectionSpan.emitted && !sectionSpan.name.empty() ) { - m_config.stream() << "\n"; - m_firstSectionInTestCase = false; + if( m_firstSectionInTestCase ) + { + m_config.stream() << "\n"; + m_firstSectionInTestCase = false; + } + std::vector::iterator it = m_sectionSpans.begin(); + std::vector::iterator itEnd = m_sectionSpans.end(); + for(; it != itEnd; ++it ) + { + SpanInfo& prevSpan = *it; + if( !prevSpan.emitted && !prevSpan.name.empty() ) + { + m_config.stream() << "[Started section: '" << prevSpan.name << "']" << std::endl; + prevSpan.emitted = true; + } + } } - m_config.stream() << "[Started section: '" << m_sectionSpan.name << "']" << std::endl; - m_sectionSpan.emitted = true; - } + } } private: @@ -278,8 +292,8 @@ namespace Catch SpanInfo m_testingSpan; SpanInfo m_groupSpan; - SpanInfo m_sectionSpan; SpanInfo m_testSpan; + std::vector m_sectionSpans; }; INTERNAL_CATCH_REGISTER_REPORTER( "basic", BasicReporter )