Used Counts class in IResultCapture interface

This commit is contained in:
Phil Nash 2012-02-23 08:57:51 +00:00
parent 5ddf794fbc
commit 8d93949b19
3 changed files with 12 additions and 18 deletions

View File

@ -14,6 +14,7 @@
#include <string> #include <string>
#include "catch_result_type.h" #include "catch_result_type.h"
#include "catch_totals.hpp"
namespace Catch namespace Catch
{ {
@ -36,13 +37,11 @@ namespace Catch
const std::string& description, const std::string& description,
const std::string& filename, const std::string& filename,
std::size_t line, std::size_t line,
std::size_t& successes, Counts& assertions
std::size_t& failures
) = 0; ) = 0;
virtual void sectionEnded virtual void sectionEnded
( const std::string& name, ( const std::string& name,
std::size_t successes, const Counts& assertions
std::size_t failures
) = 0; ) = 0;
virtual void pushScopedInfo virtual void pushScopedInfo
( ScopedInfo* scopedInfo ( ScopedInfo* scopedInfo

View File

@ -480,8 +480,7 @@ namespace Catch
const std::string& description, const std::string& description,
const std::string& filename, const std::string& filename,
std::size_t line, std::size_t line,
std::size_t& successes, Counts& assertions
std::size_t& failures
) )
{ {
std::ostringstream oss; std::ostringstream oss;
@ -492,8 +491,7 @@ namespace Catch
m_currentResult.setFileAndLine( filename, line ); m_currentResult.setFileAndLine( filename, line );
m_reporter->StartSection( name, description ); m_reporter->StartSection( name, description );
successes = m_totals.assertions.passed; assertions = m_totals.assertions;
failures = m_totals.assertions.failed;
return true; return true;
} }
@ -502,12 +500,11 @@ namespace Catch
virtual void sectionEnded virtual void sectionEnded
( (
const std::string& name, const std::string& name,
std::size_t prevSuccesses, const Counts& prevAssertions
std::size_t prevFailures
) )
{ {
m_runningTest->endSection( name ); m_runningTest->endSection( name );
m_reporter->EndSection( name, m_totals.assertions.passed - prevSuccesses, m_totals.assertions.failed - prevFailures ); m_reporter->EndSection( name, m_totals.assertions.passed - prevAssertions.passed, m_totals.assertions.failed - prevAssertions.failed );
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View File

@ -14,6 +14,7 @@
#define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED #define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED
#include "catch_capture.hpp" #include "catch_capture.hpp"
#include "catch_totals.hpp"
#include <string> #include <string>
@ -31,9 +32,7 @@ namespace Catch
std::size_t line std::size_t line
) )
: m_name( name ), : m_name( name ),
m_successes(0), m_sectionIncluded( Hub::getResultCapture().sectionStarted( name, description, filename, line, m_assertions ) )
m_failures(0),
m_sectionIncluded( Hub::getResultCapture().sectionStarted( name, description, filename, line, m_successes, m_failures ) )
{ {
} }
@ -42,7 +41,7 @@ namespace Catch
() ()
{ {
if( m_sectionIncluded ) if( m_sectionIncluded )
Hub::getResultCapture().sectionEnded( m_name, m_successes, m_failures ); Hub::getResultCapture().sectionEnded( m_name, m_assertions );
} }
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
@ -56,8 +55,7 @@ namespace Catch
private: private:
std::string m_name; std::string m_name;
std::size_t m_successes; Counts m_assertions;
std::size_t m_failures;
bool m_sectionIncluded; bool m_sectionIncluded;
}; };