mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	ResultCapture -> RunContext
This commit is contained in:
		| @@ -44,12 +44,12 @@ | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| #define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \ | ||||
|     INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ | ||||
|     if( Catch::getResultCapture().getLastResult()->succeeded() ) | ||||
|     if( Catch::getCurrentRunContext().getLastResult()->succeeded() ) | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| #define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \ | ||||
|     INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ | ||||
|     if( !Catch::getResultCapture().getLastResult()->succeeded() ) | ||||
|     if( !Catch::getCurrentRunContext().getLastResult()->succeeded() ) | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| #define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \ | ||||
|   | ||||
| @@ -18,7 +18,7 @@ namespace Catch { | ||||
|  | ||||
|     class TestCase; | ||||
|     class Stream; | ||||
|     struct IResultCapture; | ||||
|     struct IRunContext; | ||||
|     struct IRunner; | ||||
|     struct IConfig; | ||||
|  | ||||
| @@ -26,7 +26,7 @@ namespace Catch { | ||||
|     { | ||||
|         virtual ~IContext(); | ||||
|  | ||||
|         virtual IResultCapture* getResultCapture() = 0; | ||||
|         virtual IRunContext* getCurrentRunContext() = 0; | ||||
|         virtual IRunner* getRunner() = 0; | ||||
|         virtual IConfig const* getConfig() const = 0; | ||||
|     }; | ||||
| @@ -34,7 +34,7 @@ namespace Catch { | ||||
|     struct IMutableContext : IContext | ||||
|     { | ||||
|         virtual ~IMutableContext(); | ||||
|         virtual void setResultCapture( IResultCapture* resultCapture ) = 0; | ||||
|         virtual void setResultCapture( IRunContext* resultCapture ) = 0; | ||||
|         virtual void setRunner( IRunner* runner ) = 0; | ||||
|         virtual void setConfig( Ptr<IConfig const> const& config ) = 0; | ||||
|     }; | ||||
|   | ||||
| @@ -22,7 +22,7 @@ namespace Catch { | ||||
|         void operator=( Context const& ); | ||||
|  | ||||
|     public: // IContext | ||||
|         virtual IResultCapture* getResultCapture() { | ||||
|         virtual IRunContext* getCurrentRunContext() { | ||||
|             return m_resultCapture; | ||||
|         } | ||||
|         virtual IRunner* getRunner() { | ||||
| @@ -33,7 +33,7 @@ namespace Catch { | ||||
|         } | ||||
|  | ||||
|     public: // IMutableContext | ||||
|         virtual void setResultCapture( IResultCapture* resultCapture ) { | ||||
|         virtual void setResultCapture( IRunContext* resultCapture ) { | ||||
|             m_resultCapture = resultCapture; | ||||
|         } | ||||
|         virtual void setRunner( IRunner* runner ) { | ||||
| @@ -48,7 +48,7 @@ namespace Catch { | ||||
|     private: | ||||
|         Ptr<IConfig const> m_config; | ||||
|         IRunner* m_runner; | ||||
|         IResultCapture* m_resultCapture; | ||||
|         IRunContext* m_resultCapture; | ||||
|     }; | ||||
|  | ||||
|     namespace { | ||||
|   | ||||
| @@ -15,8 +15,8 @@ namespace Catch { | ||||
|     // Report the error condition then exit the process | ||||
|     inline void fatal( std::string const& message, int exitCode ) { | ||||
|         IContext& context = Catch::getCurrentContext(); | ||||
|         IResultCapture* resultCapture = context.getResultCapture(); | ||||
|         resultCapture->handleFatalErrorCondition( message ); | ||||
|         IRunContext* runContext = context.getCurrentRunContext(); | ||||
|         runContext->handleFatalErrorCondition( message ); | ||||
|  | ||||
| 		if( Catch::alwaysTrue() ) // avoids "no return" warnings | ||||
|             exit( exitCode ); | ||||
|   | ||||
| @@ -53,7 +53,7 @@ namespace Catch { | ||||
|     DebugOutStream::~DebugOutStream() CATCH_NOEXCEPT {} | ||||
|     StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {} | ||||
|     IContext::~IContext() {} | ||||
|     IResultCapture::~IResultCapture() {} | ||||
|     IRunContext::~IRunContext() {} | ||||
|     ITestCase::~ITestCase() {} | ||||
|     ITestCaseRegistry::~ITestCaseRegistry() {} | ||||
|     IRegistryHub::~IRegistryHub() {} | ||||
|   | ||||
| @@ -23,9 +23,9 @@ namespace Catch { | ||||
|     class ScopedMessageBuilder; | ||||
|     struct Counts; | ||||
|  | ||||
|     struct IResultCapture { | ||||
|     struct IRunContext { | ||||
|  | ||||
|         virtual ~IResultCapture(); | ||||
|         virtual ~IRunContext(); | ||||
|  | ||||
|         virtual void assertionEnded( AssertionResult const& result ) = 0; | ||||
|         virtual bool sectionStarted(    SectionInfo const& sectionInfo, | ||||
| @@ -41,7 +41,7 @@ namespace Catch { | ||||
|         virtual void handleFatalErrorCondition( std::string const& message ) = 0; | ||||
|     }; | ||||
|  | ||||
|     IResultCapture& getResultCapture(); | ||||
|     IRunContext& getCurrentRunContext(); | ||||
| } | ||||
|  | ||||
| #endif // TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED | ||||
|   | ||||
| @@ -31,14 +31,14 @@ namespace Catch { | ||||
|     : m_info( builder.m_info ) | ||||
|     { | ||||
|         m_info.message = builder.m_stream.str(); | ||||
|         getResultCapture().pushScopedMessage( m_info ); | ||||
|         getCurrentRunContext().pushScopedMessage( m_info ); | ||||
|     } | ||||
|     ScopedMessage::ScopedMessage( ScopedMessage const& other ) | ||||
|     : m_info( other.m_info ) | ||||
|     {} | ||||
|  | ||||
|     ScopedMessage::~ScopedMessage() { | ||||
|         getResultCapture().popScopedMessage( m_info ); | ||||
|         getCurrentRunContext().popScopedMessage( m_info ); | ||||
|     } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -98,7 +98,7 @@ namespace Catch { | ||||
|     } | ||||
|     void ResultBuilder::handleResult( AssertionResult const& result ) | ||||
|     { | ||||
|         getResultCapture().assertionEnded( result ); | ||||
|         getCurrentRunContext().assertionEnded( result ); | ||||
|  | ||||
|         if( !result.isOk() ) { | ||||
|             if( getCurrentConfig()->shouldDebugBreak() ) | ||||
|   | ||||
| @@ -52,7 +52,7 @@ namespace Catch { | ||||
|  | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
|     class RunContext : public IResultCapture, public IRunner { | ||||
|     class RunContext : public IRunContext, public IRunner { | ||||
|  | ||||
|         RunContext( RunContext const& ); | ||||
|         void operator =( RunContext const& ); | ||||
| @@ -119,7 +119,7 @@ namespace Catch { | ||||
|             return m_config; | ||||
|         } | ||||
|  | ||||
|     private: // IResultCapture | ||||
|     private: // IRunContext | ||||
|  | ||||
|  | ||||
|         virtual void assertionEnded( AssertionResult const& result ) { | ||||
| @@ -337,8 +337,8 @@ namespace Catch { | ||||
|         std::vector<MessageInfo> m_messages; | ||||
|     }; | ||||
|  | ||||
|     IResultCapture& getResultCapture() { | ||||
|         if( IResultCapture* capture = getCurrentContext().getResultCapture() ) | ||||
|     IRunContext& getCurrentRunContext() { | ||||
|         if( IRunContext* capture = getCurrentContext().getCurrentRunContext() ) | ||||
|             return *capture; | ||||
|         else | ||||
|             throw std::logic_error( "No result capture instance" ); | ||||
|   | ||||
| @@ -26,7 +26,7 @@ namespace Catch { | ||||
|  | ||||
|     Section::Section( SectionInfo const& info ) | ||||
|     :   m_info( info ), | ||||
|         m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) ) | ||||
|         m_sectionIncluded( getCurrentRunContext().sectionStarted( m_info, m_assertions ) ) | ||||
|     { | ||||
|         m_timer.start(); | ||||
|     } | ||||
| @@ -35,9 +35,9 @@ namespace Catch { | ||||
|         if( m_sectionIncluded ) { | ||||
|             SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() ); | ||||
|             if( std::uncaught_exception() ) | ||||
|                 getResultCapture().sectionEndedEarly( endInfo ); | ||||
|                 getCurrentRunContext().sectionEndedEarly( endInfo ); | ||||
|             else | ||||
|                 getResultCapture().sectionEnded( endInfo ); | ||||
|                 getCurrentRunContext().sectionEnded( endInfo ); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash