From ca9b92f8fa9ae8a004040364f8baf35cefcc55cb Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 28 May 2013 18:51:53 +0100 Subject: [PATCH] Most of system now uses Ptr --- include/catch_runner.hpp | 2 +- include/internal/catch_config.hpp | 2 +- include/internal/catch_context.h | 4 ++-- include/internal/catch_context_impl.hpp | 6 +++--- include/internal/catch_interfaces_config.h | 2 ++ include/internal/catch_runner_impl.hpp | 19 +++++++++---------- projects/SelfTest/catch_self_test.cpp | 2 +- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp index 2998c866..dd820fe2 100644 --- a/include/catch_runner.hpp +++ b/include/catch_runner.hpp @@ -39,7 +39,7 @@ namespace Catch { filterGroups.push_back( filterGroup ); } - Runner context( m_config, m_reporter ); // This Runner will be renamed Context + Runner context( m_config.get(), m_reporter ); // This Runner will be renamed Context Totals totals; for( std::size_t i=0; i < filterGroups.size() && !context.aborting(); ++i ) { diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index 41415e4e..11e1e86d 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -141,7 +141,7 @@ namespace Catch { m_data.filters.push_back( filters ); } - int getCutoff() const { + int abortAfter() const { return m_data.cutoff; } diff --git a/include/internal/catch_context.h b/include/internal/catch_context.h index c419544b..a1468dfb 100644 --- a/include/internal/catch_context.h +++ b/include/internal/catch_context.h @@ -32,7 +32,7 @@ namespace Catch { virtual IRunner& getRunner() = 0; virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0; virtual bool advanceGeneratorsForCurrentTest() = 0; - virtual Ptr getConfig() const = 0; + virtual Ptr getConfig() const = 0; }; struct IMutableContext : IContext @@ -40,7 +40,7 @@ namespace Catch { virtual ~IMutableContext(); virtual void setResultCapture( IResultCapture* resultCapture ) = 0; virtual void setRunner( IRunner* runner ) = 0; - virtual void setConfig( Ptr const& config ) = 0; + virtual void setConfig( Ptr const& config ) = 0; }; IContext& getCurrentContext(); diff --git a/include/internal/catch_context_impl.hpp b/include/internal/catch_context_impl.hpp index 3adcb9ce..e870324f 100644 --- a/include/internal/catch_context_impl.hpp +++ b/include/internal/catch_context_impl.hpp @@ -38,7 +38,7 @@ namespace Catch { return generators && generators->moveNext(); } - virtual Ptr getConfig() const { + virtual Ptr getConfig() const { return m_config; } @@ -49,7 +49,7 @@ namespace Catch { virtual void setRunner( IRunner* runner ) { m_runner = runner; } - virtual void setConfig( Ptr const& config ) { + virtual void setConfig( Ptr const& config ) { m_config = config; } @@ -79,7 +79,7 @@ namespace Catch { private: IRunner* m_runner; IResultCapture* m_resultCapture; - Ptr m_config; + Ptr m_config; std::map m_generatorsByTestName; }; diff --git a/include/internal/catch_interfaces_config.h b/include/internal/catch_interfaces_config.h index 3db8bf2d..87ee35b4 100644 --- a/include/internal/catch_interfaces_config.h +++ b/include/internal/catch_interfaces_config.h @@ -23,7 +23,9 @@ namespace Catch { virtual std::ostream& stream() const = 0; virtual std::string name() const = 0; virtual bool includeSuccessfulResults() const = 0; + virtual bool shouldDebugBreak() const = 0; virtual bool warnAboutMissingAssertions() const = 0; + virtual int abortAfter() const = 0; }; } diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index 0451072e..66a57923 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -56,7 +56,7 @@ namespace Catch { public: - explicit Runner( Ptr const& config, Ptr const& reporter ) + explicit Runner( Ptr const& config, Ptr const& reporter ) : m_runInfo( config->name() ), m_context( getCurrentMutableContext() ), m_runningTest( NULL ), @@ -67,7 +67,7 @@ namespace Catch { m_prevConfig( m_context.getConfig() ) { m_context.setRunner( this ); - m_context.setConfig( m_config.get() ); + m_context.setConfig( m_config ); m_context.setResultCapture( this ); m_reporter->testRunStarting( m_runInfo ); } @@ -126,8 +126,7 @@ namespace Catch { Totals deltaTotals = m_totals.delta( prevTotals ); bool missingAssertions = false; - if( deltaTotals.assertions.total() == 0 && - ( m_config->data().warnings & ConfigData::WarnAbout::NoAssertions ) ) { + if( deltaTotals.assertions.total() == 0 && m_config->warnAboutMissingAssertions() ) { m_totals.assertions.failed++; deltaTotals = m_totals.delta( prevTotals ); missingAssertions = true; @@ -149,7 +148,7 @@ namespace Catch { return deltaTotals; } - Ptr config() const { + Ptr config() const { return m_config; } @@ -209,8 +208,8 @@ namespace Catch { Counts assertions = m_totals.assertions - prevAssertions; bool missingAssertions = false; if( assertions.total() == 0 && - ( m_config->data().warnings & ConfigData::WarnAbout::NoAssertions ) && - !m_runningTest->isBranchSection() ) { + m_config->warnAboutMissingAssertions() && + !m_runningTest->isBranchSection() ) { m_totals.assertions.failed++; assertions.failed++; missingAssertions = true; @@ -247,7 +246,7 @@ namespace Catch { public: // !TBD We need to do this another way! bool aborting() const { - return m_totals.assertions.failed == static_cast( m_config->getCutoff() ); + return m_totals.assertions.failed == static_cast( m_config->abortAfter() ); } private: @@ -315,13 +314,13 @@ namespace Catch { RunningTest* m_runningTest; AssertionResult m_lastResult; - Ptr m_config; + Ptr m_config; Totals m_totals; Ptr m_reporter; std::vector m_messages; IRunner* m_prevRunner; IResultCapture* m_prevResultCapture; - Ptr m_prevConfig; + Ptr m_prevConfig; AssertionInfo m_lastAssertionInfo; std::vector m_unfinishedSections; }; diff --git a/projects/SelfTest/catch_self_test.cpp b/projects/SelfTest/catch_self_test.cpp index af26510f..089f8e1d 100644 --- a/projects/SelfTest/catch_self_test.cpp +++ b/projects/SelfTest/catch_self_test.cpp @@ -22,7 +22,7 @@ namespace Catch{ // Scoped because Runner doesn't report EndTesting until its destructor { - Runner runner( config, m_reporter.get() ); + Runner runner( config.get(), m_reporter.get() ); totals = runner.runMatching( rawTestSpec, groupIndex, groupsCount ); } return totals;