From 2632dca81d84b30f014a5a7efca785fe345f322a Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Sat, 1 Dec 2012 23:49:57 +0000 Subject: [PATCH] Completed IStreamingInterface abstraction with TestRunInfo and GroupInfo --- include/internal/catch_interfaces_reporter.h | 33 +++++++++++++------- include/internal/catch_runner_impl.hpp | 8 ++--- projects/SelfTest/catch_self_test.hpp | 4 +-- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 7c30d96c..fc272755 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -43,6 +43,15 @@ namespace Catch bool shouldRedirectStdOut; }; + struct TestRunInfo { + TestRunInfo( std::string const& _name ) : name( _name ) {} + std::string name; + }; + struct GroupInfo { + GroupInfo( std::string const& _name ) : name( _name ) {} + std::string name; + }; + struct SectionInfo { SectionInfo( std::string const& _name, std::string const& _description, @@ -109,31 +118,31 @@ namespace Catch }; struct TestGroupStats : SharedImpl<> { - TestGroupStats( std::string const& _groupName, + TestGroupStats( GroupInfo const& _groupInfo, Totals const& _totals, bool _aborting ) - : groupName( _groupName ), + : groupInfo( _groupInfo ), totals( _totals ), aborting( _aborting ) {} virtual ~TestGroupStats(); - std::string groupName; + GroupInfo groupInfo; Totals totals; bool aborting; }; struct TestRunStats : SharedImpl<> { - TestRunStats( std::string const& _runName, + TestRunStats( TestRunInfo const& _runInfo, Totals const& _totals, bool _aborting ) - : runName( _runName ), + : runInfo( _runInfo ), totals( _totals ), aborting( _aborting ) {} virtual ~TestRunStats(); - std::string runName; + TestRunInfo runInfo; Totals totals; bool aborting; }; @@ -143,8 +152,8 @@ namespace Catch virtual ~IStreamingReporter(); virtual ReporterPreferences getPreferences() const = 0; - virtual void testRunStarting( std::string const& runName ) = 0; - virtual void testGroupStarting( std::string const& groupName ) = 0; + virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; + virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; @@ -199,11 +208,11 @@ namespace Catch return prefs; } - virtual void testRunStarting( std::string const& ) { + virtual void testRunStarting( TestRunInfo const& ) { m_legacyReporter->StartTesting(); } - virtual void testGroupStarting( std::string const& groupName ) { - m_legacyReporter->StartGroup( groupName ); + virtual void testGroupStarting( GroupInfo const& groupInfo ) { + m_legacyReporter->StartGroup( groupInfo.name ); } virtual void testCaseStarting( TestCaseInfo const& testInfo ) { m_legacyReporter->StartTestCase( testInfo ); @@ -235,7 +244,7 @@ namespace Catch virtual void testGroupEnded( Ptr const& testGroupStats ) { if( testGroupStats->aborting ) m_legacyReporter->Aborted(); - m_legacyReporter->EndGroup( testGroupStats->groupName, testGroupStats->totals ); + m_legacyReporter->EndGroup( testGroupStats->groupInfo.name, testGroupStats->totals ); } virtual void testRunEnded( Ptr const& testRunStats ) { m_legacyReporter->EndTesting( testRunStats->totals ); diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index 850fa56f..8deb4f7d 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -68,11 +68,11 @@ namespace Catch { m_context.setRunner( this ); m_context.setConfig( &m_config ); m_context.setResultCapture( this ); - m_reporter->testRunStarting( "" ); // !TBD - name + m_reporter->testRunStarting( TestRunInfo( "" ) ); // !TBD - name } virtual ~Runner() { - m_reporter->testRunEnded( new TestRunStats( "", m_totals, aborting() ) ); // !TBD - name + m_reporter->testRunEnded( new TestRunStats( TestRunInfo( "" ), m_totals, aborting() ) ); // !TBD - name m_context.setRunner( m_prevRunner ); m_context.setConfig( NULL ); m_context.setResultCapture( m_prevResultCapture ); @@ -80,10 +80,10 @@ namespace Catch { } void testGroupStarting( std::string const& testSpec ) { - m_reporter->testGroupStarting( testSpec ); + m_reporter->testGroupStarting( GroupInfo( testSpec ) ); } void testGroupEnded( std::string const& testSpec, Totals const& totals ) { - m_reporter->testGroupEnded( new TestGroupStats( testSpec, totals, aborting() ) ); + m_reporter->testGroupEnded( new TestGroupStats( GroupInfo( testSpec ), totals, aborting() ) ); } Totals runMatching( const std::string& testSpec ) { diff --git a/projects/SelfTest/catch_self_test.hpp b/projects/SelfTest/catch_self_test.hpp index f31d7eca..eeaff6e4 100644 --- a/projects/SelfTest/catch_self_test.hpp +++ b/projects/SelfTest/catch_self_test.hpp @@ -35,8 +35,8 @@ namespace Catch { return ReporterPreferences(); } - virtual void testRunStarting( std::string const& ) {} - virtual void testGroupStarting( std::string const& ) {} + virtual void testRunStarting( TestRunInfo const& ) {} + virtual void testGroupStarting( GroupInfo const& ) {} virtual void testCaseStarting( TestCaseInfo const& ) {} virtual void sectionStarting( SectionInfo const& ) {} virtual void assertionStarting( AssertionInfo const& ) {}