diff --git a/include/catch.hpp b/include/catch.hpp index d5ba8c3f..8f45bfbc 100644 --- a/include/catch.hpp +++ b/include/catch.hpp @@ -12,7 +12,7 @@ #ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED #define TWOBLUECUBES_CATCH_HPP_INCLUDED -#include "internal/catch_hub.h" +#include "internal/catch_context.h" #include "internal/catch_test_registry.hpp" #include "internal/catch_capture.hpp" #include "internal/catch_section.hpp" diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp index 0821582f..361cae1e 100644 --- a/include/catch_runner.hpp +++ b/include/catch_runner.hpp @@ -13,7 +13,7 @@ #ifndef TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED #define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED -#include "internal/catch_hub_impl.hpp" +#include "internal/catch_context_impl.hpp" #include "internal/catch_commandline.hpp" #include "internal/catch_list.hpp" diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 120883ba..91bfa6bd 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -15,7 +15,7 @@ #include "catch_interfaces_capture.h" #include "catch_debugger.hpp" #include "catch_evaluate.hpp" -#include "catch_hub.h" +#include "catch_context.h" #include "catch_common.h" #include @@ -365,11 +365,11 @@ class ScopedInfo { public: ScopedInfo() : m_oss() { - Hub::getResultCapture().pushScopedInfo( this ); + Context::getResultCapture().pushScopedInfo( this ); } ~ScopedInfo() { - Hub::getResultCapture().popScopedInfo( this ); + Context::getResultCapture().popScopedInfo( this ); } template @@ -393,7 +393,7 @@ inline bool isTrue( bool value ){ return value; } /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_ACCEPT_EXPR( expr, stopOnFailure, originalExpr ) \ - if( Catch::ResultAction::Value internal_catch_action = Catch::Hub::getResultCapture().acceptExpression( expr ) ) \ + if( Catch::ResultAction::Value internal_catch_action = Catch::Context::getResultCapture().acceptExpression( expr ) ) \ { \ if( internal_catch_action == Catch::ResultAction::DebugFailed ) BreakIntoDebugger(); \ if( Catch::isTrue( stopOnFailure ) ) throw Catch::TestFailureException(); \ @@ -407,19 +407,19 @@ inline bool isTrue( bool value ){ return value; } }catch( Catch::TestFailureException& ){ \ throw; \ } catch( ... ){ \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, expr ); \ + INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, expr ); \ throw; \ }}while( Catch::isTrue( false ) ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_IF( expr, isNot, stopOnFailure, macroName ) \ INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ); \ - if( Catch::Hub::getResultCapture().getLastResult()->ok() ) + if( Catch::Context::getResultCapture().getLastResult()->ok() ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_ELSE( expr, isNot, stopOnFailure, macroName ) \ INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ); \ - if( !Catch::Hub::getResultCapture().getLastResult()->ok() ) + if( !Catch::Context::getResultCapture().getLastResult()->ok() ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_NO_THROW( expr, stopOnFailure, macroName ) \ @@ -430,7 +430,7 @@ inline bool isTrue( bool value ){ return value; } } \ catch( ... ) \ { \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \ + INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \ } /////////////////////////////////////////////////////////////////////////////// @@ -454,12 +454,12 @@ inline bool isTrue( bool value ){ return value; } INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \ catch( ... ) \ { \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \ + INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \ } /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \ - Catch::Hub::getResultCapture().acceptExpression( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName ) << reason ).setResultType( resultType ) ); + Catch::Context::getResultCapture().acceptExpression( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName ) << reason ).setResultType( resultType ) ); /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_SCOPED_INFO( log ) \ @@ -473,7 +473,7 @@ inline bool isTrue( bool value ){ return value; } }catch( Catch::TestFailureException& ){ \ throw; \ } catch( ... ){ \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, false ); \ + INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, false ); \ throw; \ }}while( Catch::isTrue( false ) ) diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index 85961890..c9595862 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -14,7 +14,7 @@ #define TWOBLUECUBES_CATCH_RUNNERCONFIG_HPP_INCLUDED #include "catch_interfaces_reporter.h" -#include "catch_hub.h" +#include "catch_context.h" #include #include @@ -76,7 +76,7 @@ namespace Catch { if( m_reporter.get() ) return setError( "Only one reporter may be specified" ); - setReporter( Hub::getReporterRegistry().create( reporterName, *this ) ); + setReporter( Context::getReporterRegistry().create( reporterName, *this ) ); } /////////////////////////////////////////////////////////////////////////// @@ -143,7 +143,7 @@ namespace Catch Ptr getReporter() { if( !m_reporter.get() ) - const_cast( this )->setReporter( Hub::getReporterRegistry().create( "basic", *this ) ); + const_cast( this )->setReporter( Context::getReporterRegistry().create( "basic", *this ) ); return m_reporter; } @@ -216,7 +216,7 @@ namespace Catch /////////////////////////////////////////////////////////////////////////// void useStream( const std::string& streamName ) { - std::streambuf* newBuf = Hub::createStreamBuf( streamName ); + std::streambuf* newBuf = Context::createStreamBuf( streamName ); setStreamBuf( newBuf ); delete m_streambuf; m_streambuf = newBuf; diff --git a/include/internal/catch_context.h b/include/internal/catch_context.h new file mode 100644 index 00000000..ada177c5 --- /dev/null +++ b/include/internal/catch_context.h @@ -0,0 +1,63 @@ +/* + * Created by Phil on 31/12/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED +#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED + +#include "catch_interfaces_reporter.h" + +#include +#include +#include + +namespace Catch +{ + class TestCaseInfo; + struct IResultCapture; + struct ITestCaseRegistry; + struct IRunner; + struct IExceptionTranslatorRegistry; + class GeneratorsForTest; + + class StreamBufBase : public std::streambuf{}; + + class Context + { + Context(); + Context( const Context& ); + void operator=( const Context& ); + static Context& me(); + + public: + static void setRunner( IRunner* runner ); + static void setResultCapture( IResultCapture* resultCapture ); + static IResultCapture& getResultCapture(); + static IReporterRegistry& getReporterRegistry(); + static ITestCaseRegistry& getTestCaseRegistry(); + static IExceptionTranslatorRegistry& getExceptionTranslatorRegistry(); + static std::streambuf* createStreamBuf( const std::string& streamName ); + static IRunner& getRunner(); + static size_t getGeneratorIndex( const std::string& fileInfo, size_t totalSize ); + static bool advanceGeneratorsForCurrentTest(); + static void cleanUp(); + + private: + static Context*& singleInstance(); + GeneratorsForTest* findGeneratorsForCurrentTest(); + GeneratorsForTest& getGeneratorsForCurrentTest(); + + private: + std::auto_ptr m_reporterRegistry; + std::auto_ptr m_testCaseRegistry; + std::auto_ptr m_exceptionTranslatorRegistry; + IRunner* m_runner; + IResultCapture* m_resultCapture; + std::map m_generatorsByTestName; + }; +} + +#endif // TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED diff --git a/include/internal/catch_hub_impl.hpp b/include/internal/catch_context_impl.hpp similarity index 50% rename from include/internal/catch_hub_impl.hpp rename to include/internal/catch_context_impl.hpp index 22ac8f9a..e2db244f 100644 --- a/include/internal/catch_hub_impl.hpp +++ b/include/internal/catch_context_impl.hpp @@ -1,15 +1,11 @@ /* - * catch_hub_impl.hpp - * Catch - * * Created by Phil on 31/12/2010. * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. * * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * */ -#include "catch_hub.h" +#include "catch_context.h" #include "catch_reporter_registry.hpp" #include "catch_test_case_registry_impl.hpp" #include "catch_exception_translator_registry.hpp" @@ -20,94 +16,59 @@ namespace Catch { - /////////////////////////////////////////////////////////////////////////// - Hub::Hub - () + Context::Context() : m_reporterRegistry( new ReporterRegistry ), m_testCaseRegistry( new TestRegistry ), m_exceptionTranslatorRegistry( new ExceptionTranslatorRegistry ) - { - } + {} - /////////////////////////////////////////////////////////////////////////// - Hub& Hub::me - () - { - Hub*& hub = singleInstance(); + Context& Context::me() { + Context*& hub = singleInstance(); if( !hub ) - hub = new Hub(); + hub = new Context(); return *hub; } - /////////////////////////////////////////////////////////////////////////// - void Hub::cleanUp - () - { - Hub*& hub = singleInstance(); + void Context::cleanUp() { + Context*& hub = singleInstance(); delete hub; hub = NULL; } - /////////////////////////////////////////////////////////////////////////// - Hub*& Hub::singleInstance() - { - static Hub* hub = NULL; + Context*& Context::singleInstance() { + static Context* hub = NULL; return hub; - } - /////////////////////////////////////////////////////////////////////////// - void Hub::setRunner( IRunner* runner ) - { + void Context::setRunner( IRunner* runner ) { me().m_runner = runner; } - /////////////////////////////////////////////////////////////////////////// - void Hub::setResultCapture( IResultCapture* resultCapture ) - { + + void Context::setResultCapture( IResultCapture* resultCapture ) { me().m_resultCapture = resultCapture; } - /////////////////////////////////////////////////////////////////////////// - IResultCapture& Hub::getResultCapture - () - { + IResultCapture& Context::getResultCapture() { return *me().m_resultCapture; } - /////////////////////////////////////////////////////////////////////////// - IRunner& Hub::getRunner - () - { + IRunner& Context::getRunner() { return *me().m_runner; } - /////////////////////////////////////////////////////////////////////////// - IReporterRegistry& Hub::getReporterRegistry - () - { + IReporterRegistry& Context::getReporterRegistry() { return *me().m_reporterRegistry.get(); } - /////////////////////////////////////////////////////////////////////////// - ITestCaseRegistry& Hub::getTestCaseRegistry - () - { + ITestCaseRegistry& Context::getTestCaseRegistry() { return *me().m_testCaseRegistry.get(); } - /////////////////////////////////////////////////////////////////////////// - IExceptionTranslatorRegistry& Hub::getExceptionTranslatorRegistry - () - { + IExceptionTranslatorRegistry& Context::getExceptionTranslatorRegistry() { return *me().m_exceptionTranslatorRegistry.get(); } - /////////////////////////////////////////////////////////////////////////// - std::streambuf* Hub::createStreamBuf - ( - const std::string& streamName - ) - { + std::streambuf* Context::createStreamBuf( const std::string& streamName ) { if( streamName == "stdout" ) return std::cout.rdbuf(); if( streamName == "stderr" ) return std::cerr.rdbuf(); if( streamName == "debug" ) return new StreamBufImpl; @@ -115,10 +76,7 @@ namespace Catch throw std::domain_error( "Unknown stream: " + streamName ); } - /////////////////////////////////////////////////////////////////////////// - GeneratorsForTest* Hub::findGeneratorsForCurrentTest - () - { + GeneratorsForTest* Context::findGeneratorsForCurrentTest() { std::string testName = getResultCapture().getCurrentTestName(); std::map::const_iterator it = @@ -127,10 +85,8 @@ namespace Catch ? it->second : NULL; } - /////////////////////////////////////////////////////////////////////////// - GeneratorsForTest& Hub::getGeneratorsForCurrentTest - () - { + + GeneratorsForTest& Context::getGeneratorsForCurrentTest() { GeneratorsForTest* generators = findGeneratorsForCurrentTest(); if( !generators ) { @@ -141,22 +97,14 @@ namespace Catch return *generators; } - /////////////////////////////////////////////////////////////////////////// - size_t Hub::getGeneratorIndex - ( - const std::string& fileInfo, - size_t totalSize - ) + size_t Context::getGeneratorIndex( const std::string& fileInfo, size_t totalSize ) { return me().getGeneratorsForCurrentTest() .getGeneratorInfo( fileInfo, totalSize ) .getCurrentIndex(); } - /////////////////////////////////////////////////////////////////////////// - bool Hub::advanceGeneratorsForCurrentTest - () - { + bool Context::advanceGeneratorsForCurrentTest() { GeneratorsForTest* generators = me().findGeneratorsForCurrentTest(); return generators && generators->moveNext(); } diff --git a/include/internal/catch_default_main.hpp b/include/internal/catch_default_main.hpp index 86e66391..ac3cf3c8 100644 --- a/include/internal/catch_default_main.hpp +++ b/include/internal/catch_default_main.hpp @@ -34,7 +34,7 @@ int main (int argc, char * const argv[]) int result =Catch::Main( argc, argv ); #endif - Catch::Hub::cleanUp(); + Catch::Context::cleanUp(); return result; } diff --git a/include/internal/catch_generators.hpp b/include/internal/catch_generators.hpp index 2d0cdbe0..08bfa4bb 100644 --- a/include/internal/catch_generators.hpp +++ b/include/internal/catch_generators.hpp @@ -13,7 +13,7 @@ #ifndef TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED #define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED -#include "catch_hub.h" +#include "catch_context.h" #include #include @@ -160,7 +160,7 @@ public: () const { - size_t overallIndex = Hub::getGeneratorIndex( m_fileInfo, m_totalSize ); + size_t overallIndex = Context::getGeneratorIndex( m_fileInfo, m_totalSize ); typename std::vector*>::const_iterator it = m_composed.begin(); typename std::vector*>::const_iterator itEnd = m_composed.end(); diff --git a/include/internal/catch_hub.h b/include/internal/catch_hub.h deleted file mode 100644 index f84056fe..00000000 --- a/include/internal/catch_hub.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * catch_hub.h - * Catch - * - * Created by Phil on 31/12/2010. - * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ -#ifndef TWOBLUECUBES_CATCH_HUB_H_INCLUDED -#define TWOBLUECUBES_CATCH_HUB_H_INCLUDED - -#include "catch_interfaces_reporter.h" - -#include -#include -#include - -namespace Catch -{ - class TestCaseInfo; - struct IResultCapture; - struct ITestCaseRegistry; - struct IRunner; - struct IExceptionTranslatorRegistry; - class GeneratorsForTest; - - class StreamBufBase : public std::streambuf - { - }; - - class Hub - { - Hub(); - - static Hub& me(); - - Hub( const Hub& ); - void operator=( const Hub& ); - - public: - - static void setRunner - ( IRunner* runner - ); - - static void setResultCapture - ( IResultCapture* resultCapture - ); - - static IResultCapture& getResultCapture - (); - - static IReporterRegistry& getReporterRegistry - (); - - static ITestCaseRegistry& getTestCaseRegistry - (); - - static IExceptionTranslatorRegistry& getExceptionTranslatorRegistry - (); - - static std::streambuf* createStreamBuf - ( const std::string& streamName - ); - - static IRunner& getRunner - (); - - static size_t getGeneratorIndex - ( const std::string& fileInfo, - size_t totalSize - ); - - static bool advanceGeneratorsForCurrentTest - (); - - static void cleanUp - (); - - private: - - static Hub*& singleInstance(); - - GeneratorsForTest* findGeneratorsForCurrentTest - (); - - GeneratorsForTest& getGeneratorsForCurrentTest - (); - - std::auto_ptr m_reporterRegistry; - std::auto_ptr m_testCaseRegistry; - std::auto_ptr m_exceptionTranslatorRegistry; - IRunner* m_runner; - IResultCapture* m_resultCapture; - std::map m_generatorsByTestName; - }; -} - -#endif // TWOBLUECUBES_CATCH_HUB_H_INCLUDED diff --git a/include/internal/catch_interfaces_exception.h b/include/internal/catch_interfaces_exception.h index 0e17fa36..fff7b653 100644 --- a/include/internal/catch_interfaces_exception.h +++ b/include/internal/catch_interfaces_exception.h @@ -77,7 +77,7 @@ namespace Catch std::string(*translateFunction)( T& ) ) { - Catch::Hub::getExceptionTranslatorRegistry().registerTranslator + Catch::Context::getExceptionTranslatorRegistry().registerTranslator ( new ExceptionTranslator( translateFunction ) ); } }; diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp index e0246057..5b7026b9 100644 --- a/include/internal/catch_list.hpp +++ b/include/internal/catch_list.hpp @@ -27,8 +27,8 @@ namespace Catch if( config.listWhat() & Config::List::Reports ) { std::cout << "Available reports:\n"; - IReporterRegistry::FactoryMap::const_iterator it = Hub::getReporterRegistry().getFactories().begin(); - IReporterRegistry::FactoryMap::const_iterator itEnd = Hub::getReporterRegistry().getFactories().end(); + IReporterRegistry::FactoryMap::const_iterator it = Context::getReporterRegistry().getFactories().begin(); + IReporterRegistry::FactoryMap::const_iterator itEnd = Context::getReporterRegistry().getFactories().end(); for(; it != itEnd; ++it ) { // !TBD: consider listAs() @@ -39,8 +39,8 @@ namespace Catch if( config.listWhat() & Config::List::Tests ) { std::cout << "Available tests:\n"; - std::vector::const_iterator it = Hub::getTestCaseRegistry().getAllTests().begin(); - std::vector::const_iterator itEnd = Hub::getTestCaseRegistry().getAllTests().end(); + std::vector::const_iterator it = Context::getTestCaseRegistry().getAllTests().begin(); + std::vector::const_iterator itEnd = Context::getTestCaseRegistry().getAllTests().end(); for(; it != itEnd; ++it ) { // !TBD: consider listAs() diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp index cc827781..330b948e 100644 --- a/include/internal/catch_objc.hpp +++ b/include/internal/catch_objc.hpp @@ -192,7 +192,7 @@ namespace Catch std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); - Hub::getTestCaseRegistry().registerTest( TestCaseInfo( new OcMethod( cls, selector ), name.c_str(), desc.c_str(), "", 0 ) ); + Context::getTestCaseRegistry().registerTest( TestCaseInfo( new OcMethod( cls, selector ), name.c_str(), desc.c_str(), "", 0 ) ); noTestMethods++; } diff --git a/include/internal/catch_reporter_registrars.hpp b/include/internal/catch_reporter_registrars.hpp index f18e2aae..5d6b09d0 100644 --- a/include/internal/catch_reporter_registrars.hpp +++ b/include/internal/catch_reporter_registrars.hpp @@ -12,7 +12,7 @@ #ifndef TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED -#include "catch_hub.h" +#include "catch_context.h" namespace Catch { @@ -47,7 +47,7 @@ namespace Catch const std::string& name ) { - Hub::getReporterRegistry().registerReporter( name, new ReporterFactory() ); + Context::getReporterRegistry().registerReporter( name, new ReporterFactory() ); } }; } diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index 3b183d4f..7c138953 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -75,11 +75,11 @@ namespace Catch : m_runningTest( NULL ), m_config( config ), m_reporter( config.getReporter() ), - m_prevRunner( &Hub::getRunner() ), - m_prevResultCapture( &Hub::getResultCapture() ) + m_prevRunner( &Context::getRunner() ), + m_prevResultCapture( &Context::getResultCapture() ) { - Hub::setRunner( this ); - Hub::setResultCapture( this ); + Context::setRunner( this ); + Context::setResultCapture( this ); m_reporter->StartTesting(); } @@ -88,8 +88,8 @@ namespace Catch () { m_reporter->EndTesting( m_totals ); - Hub::setRunner( m_prevRunner ); - Hub::setResultCapture( m_prevResultCapture ); + Context::setRunner( m_prevRunner ); + Context::setResultCapture( m_prevResultCapture ); } /////////////////////////////////////////////////////////////////////////// @@ -98,7 +98,7 @@ namespace Catch bool runHiddenTests = false ) { - std::vector allTests = Hub::getTestCaseRegistry().getAllTests(); + std::vector allTests = Context::getTestCaseRegistry().getAllTests(); for( std::size_t i=0; i < allTests.size(); ++i ) { if( runHiddenTests || !allTests[i].isHidden() ) @@ -114,7 +114,7 @@ namespace Catch { TestSpec testSpec( rawTestSpec ); - std::vector allTests = Hub::getTestCaseRegistry().getAllTests(); + std::vector allTests = Context::getTestCaseRegistry().getAllTests(); std::size_t testsRun = 0; for( std::size_t i=0; i < allTests.size(); ++i ) { @@ -153,7 +153,7 @@ namespace Catch } while( m_runningTest->hasUntestedSections() ); } - while( Hub::advanceGeneratorsForCurrentTest() ); + while( Context::advanceGeneratorsForCurrentTest() ); delete m_runningTest; m_runningTest = NULL; @@ -365,7 +365,7 @@ namespace Catch } catch(...) { - acceptMessage( Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ); + acceptMessage( Catch::Context::getExceptionTranslatorRegistry().translateActiveException() ); acceptResult( ResultWas::ThrewException ); } m_info.clear(); diff --git a/include/internal/catch_section.hpp b/include/internal/catch_section.hpp index 84403fc8..a0335435 100644 --- a/include/internal/catch_section.hpp +++ b/include/internal/catch_section.hpp @@ -31,7 +31,7 @@ namespace Catch const SourceLineInfo& lineInfo ) : m_name( name ), - m_sectionIncluded( Hub::getResultCapture().sectionStarted( name, description, lineInfo, m_assertions ) ) + m_sectionIncluded( Context::getResultCapture().sectionStarted( name, description, lineInfo, m_assertions ) ) { } @@ -40,7 +40,7 @@ namespace Catch () { if( m_sectionIncluded ) - Hub::getResultCapture().sectionEnded( m_name, m_assertions ); + Context::getResultCapture().sectionEnded( m_name, m_assertions ); } /////////////////////////////////////////////////////////////////////// diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp index d67ac4ae..4036f905 100644 --- a/include/internal/catch_test_case_registry_impl.hpp +++ b/include/internal/catch_test_case_registry_impl.hpp @@ -12,7 +12,7 @@ #include "catch_test_registry.hpp" #include "catch_test_case_info.hpp" -#include "catch_hub.h" +#include "catch_context.h" #include #include @@ -179,7 +179,7 @@ namespace Catch const SourceLineInfo& lineInfo ) { - Hub::getTestCaseRegistry().registerTest( TestCaseInfo( testCase, name, description, lineInfo ) ); + Context::getTestCaseRegistry().registerTest( TestCaseInfo( testCase, name, description, lineInfo ) ); } } // end namespace Catch diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp index f6ee6c36..bad0196c 100644 --- a/include/internal/catch_tostring.hpp +++ b/include/internal/catch_tostring.hpp @@ -116,6 +116,12 @@ inline std::string toString( bool value ) { return value ? "true" : "false"; } +#ifdef CATCH_CONFIG_CPP11_NULLPTR +inline std::string toString( std::nullptr_t null ) { + return "nullptr"; +} +#endif + } // end namespace Catch #endif // TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED diff --git a/projects/SelfTest/catch_self_test.hpp b/projects/SelfTest/catch_self_test.hpp index efde990b..41b9aed6 100644 --- a/projects/SelfTest/catch_self_test.hpp +++ b/projects/SelfTest/catch_self_test.hpp @@ -180,7 +180,7 @@ namespace Catch Expected::Result expectedResult ) { - forEach( Hub::getTestCaseRegistry().getMatchingTestCases( testSpec ), + forEach( Context::getTestCaseRegistry().getMatchingTestCases( testSpec ), MetaTestRunner( expectedResult ) ); } diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj index 79f9ccd0..b92fdafe 100644 --- a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj +++ b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj @@ -61,8 +61,8 @@ 4A6D0C4E149B3E3D00DB3EAA /* catch_exception_translator_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_exception_translator_registry.hpp; sourceTree = ""; }; 4A6D0C4F149B3E3D00DB3EAA /* catch_generators.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_generators.hpp; sourceTree = ""; }; 4A6D0C50149B3E3D00DB3EAA /* catch_generators_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_generators_impl.hpp; sourceTree = ""; }; - 4A6D0C51149B3E3D00DB3EAA /* catch_hub.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_hub.h; sourceTree = ""; }; - 4A6D0C52149B3E3D00DB3EAA /* catch_hub_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_hub_impl.hpp; sourceTree = ""; }; + 4A6D0C51149B3E3D00DB3EAA /* catch_context.h */ = {isa = PBXFileReference; fileEncoding = 4; path = catch_context.h; sourceTree = ""; }; + 4A6D0C52149B3E3D00DB3EAA /* catch_context_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; path = catch_context_impl.hpp; sourceTree = ""; }; 4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_capture.h; sourceTree = ""; }; 4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_exception.h; sourceTree = ""; }; 4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_reporter.h; sourceTree = ""; }; @@ -176,8 +176,8 @@ 4A6D0C4E149B3E3D00DB3EAA /* catch_exception_translator_registry.hpp */, 4A6D0C4F149B3E3D00DB3EAA /* catch_generators.hpp */, 4A6D0C50149B3E3D00DB3EAA /* catch_generators_impl.hpp */, - 4A6D0C51149B3E3D00DB3EAA /* catch_hub.h */, - 4A6D0C52149B3E3D00DB3EAA /* catch_hub_impl.hpp */, + 4A6D0C51149B3E3D00DB3EAA /* catch_context.h */, + 4A6D0C52149B3E3D00DB3EAA /* catch_context_impl.hpp */, 4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */, 4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */, 4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */, @@ -292,6 +292,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CXX0X_EXTENSIONS = NO; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -319,6 +322,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CXX0X_EXTENSIONS = NO; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";