Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2012-08-07 07:58:34 +0100
committerPhil Nash2012-08-07 07:58:34 +0100
commitda0ae952fcb05fa80635e001b3c276c2d1f65dc0 (patch)
treeebb4777ca3c04c493711844577462e03e021e012 /include
parent6b3ee4a61e056cf9d1486da1490595493b88d168 (diff)
downloadcatch3-da0ae952fcb05fa80635e001b3c276c2d1f65dc0.tar.gz
Renamed static registries -> registry hub
Diffstat (limited to 'include')
-rw-r--r--include/catch_runner.hpp2
-rw-r--r--include/internal/catch_capture.hpp8
-rw-r--r--include/internal/catch_impl.hpp2
-rw-r--r--include/internal/catch_interfaces_exception.h4
-rw-r--r--include/internal/catch_interfaces_registry_hub.h (renamed from include/internal/catch_interfaces_static_registries.h)12
-rw-r--r--include/internal/catch_list.hpp8
-rw-r--r--include/internal/catch_objc.hpp2
-rw-r--r--include/internal/catch_registry_hub.hpp (renamed from include/internal/catch_static_registries_impl.hpp)37
-rw-r--r--include/internal/catch_reporter_registrars.hpp4
-rw-r--r--include/internal/catch_runner_impl.hpp6
-rw-r--r--include/internal/catch_test_case_registry_impl.hpp2
11 files changed, 44 insertions, 43 deletions
diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp
index cda98164..3c75ecad 100644
--- a/include/catch_runner.hpp
+++ b/include/catch_runner.hpp
@@ -34,7 +34,7 @@ namespace Catch {
ReporterConfig reporterConfig( config.getName(), config.stream(), config.includeSuccessfulResults() );
- Ptr<IReporter> reporter = getStatics().getReporterRegistry().create( reporterName, reporterConfig );
+ Ptr<IReporter> reporter = getRegistryHub().getReporterRegistry().create( reporterName, reporterConfig );
if( !reporter )
{
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index 62018929..c4f28757 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -64,7 +64,7 @@ inline bool isTrue( bool value ){ return value; }
} catch( Catch::TestFailureException& ) { \
throw; \
} catch( ... ) { \
- INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getStatics().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, expr ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getRegistryHub().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, expr ); \
throw; \
} } while( Catch::isTrue( false ) )
@@ -85,7 +85,7 @@ inline bool isTrue( bool value ){ return value; }
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure, false ); \
} \
catch( ... ) { \
- INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getStatics().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getRegistryHub().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
}
///////////////////////////////////////////////////////////////////////////////
@@ -107,7 +107,7 @@ inline bool isTrue( bool value ){ return value; }
#define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, stopOnFailure, macroName ) \
INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \
catch( ... ) { \
- INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getStatics().getExceptionTranslatorRegistry() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::getRegistryHub().getExceptionTranslatorRegistry() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
}
///////////////////////////////////////////////////////////////////////////////
@@ -126,7 +126,7 @@ inline bool isTrue( bool value ){ return value; }
} catch( Catch::TestFailureException& ) { \
throw; \
} catch( ... ) { \
- INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::getStatics().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, false ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::getRegistryHub().getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, false ); \
throw; \
}}while( Catch::isTrue( false ) )
diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp
index 256846ce..d0a1b252 100644
--- a/include/internal/catch_impl.hpp
+++ b/include/internal/catch_impl.hpp
@@ -6,6 +6,6 @@
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
-#include "catch_static_registries_impl.hpp"
+#include "catch_registry_hub.hpp"
#include "catch_notimplemented_exception.hpp"
// !TBD... migrate all impl headers here
diff --git a/include/internal/catch_interfaces_exception.h b/include/internal/catch_interfaces_exception.h
index 15023ca5..9054dfe4 100644
--- a/include/internal/catch_interfaces_exception.h
+++ b/include/internal/catch_interfaces_exception.h
@@ -9,7 +9,7 @@
#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTIONS_H_INCLUDED
#include <string>
-#include "catch_interfaces_static_registries.h"
+#include "catch_interfaces_registry_hub.h"
namespace Catch {
@@ -51,7 +51,7 @@ namespace Catch {
public:
template<typename T>
ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {
- getStaticRegistries().registerTranslator
+ getMutableRegistryHub().registerTranslator
( new ExceptionTranslator<T>( translateFunction ) );
}
};
diff --git a/include/internal/catch_interfaces_static_registries.h b/include/internal/catch_interfaces_registry_hub.h
index c7212073..c4cbe940 100644
--- a/include/internal/catch_interfaces_static_registries.h
+++ b/include/internal/catch_interfaces_registry_hub.h
@@ -23,23 +23,23 @@ namespace Catch {
struct IExceptionTranslatorRegistry;
struct IExceptionTranslator;
- struct IStatics {
- virtual ~IStatics(){}
+ struct IRegistryHub {
+ virtual ~IRegistryHub(){}
virtual const IReporterRegistry& getReporterRegistry() const = 0;
virtual const ITestCaseRegistry& getTestCaseRegistry() const = 0;
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
};
- struct IStaticRegistries {
- virtual ~IStaticRegistries(){}
+ struct IMutableRegistryHub {
+ virtual ~IMutableRegistryHub(){}
virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0;
virtual void registerTest( const TestCaseInfo& testInfo ) = 0;
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
};
- IStatics& getStatics();
- IStaticRegistries& getStaticRegistries();
+ IRegistryHub& getRegistryHub();
+ IMutableRegistryHub& getMutableRegistryHub();
void cleanUp();
}
diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp
index a18914c1..614ab1f7 100644
--- a/include/internal/catch_list.hpp
+++ b/include/internal/catch_list.hpp
@@ -16,8 +16,8 @@ namespace Catch {
if( config.listWhat() & List::Reports ) {
std::cout << "Available reports:\n";
- IReporterRegistry::FactoryMap::const_iterator it = getStatics().getReporterRegistry().getFactories().begin();
- IReporterRegistry::FactoryMap::const_iterator itEnd = getStatics().getReporterRegistry().getFactories().end();
+ IReporterRegistry::FactoryMap::const_iterator it = getRegistryHub().getReporterRegistry().getFactories().begin();
+ IReporterRegistry::FactoryMap::const_iterator itEnd = getRegistryHub().getReporterRegistry().getFactories().end();
for(; it != itEnd; ++it ) {
// !TBD: consider listAs()
std::cout << "\t" << it->first << "\n\t\t'" << it->second->getDescription() << "'\n";
@@ -27,8 +27,8 @@ namespace Catch {
if( config.listWhat() & List::Tests ) {
std::cout << "Available tests:\n";
- std::vector<TestCaseInfo>::const_iterator it = getStatics().getTestCaseRegistry().getAllTests().begin();
- std::vector<TestCaseInfo>::const_iterator itEnd = getStatics().getTestCaseRegistry().getAllTests().end();
+ std::vector<TestCaseInfo>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
+ std::vector<TestCaseInfo>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
for(; it != itEnd; ++it ) {
// !TBD: consider listAs()
std::cout << "\t" << it->getName() << "\n\t\t '" << it->getDescription() << "'\n";
diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp
index 843c891b..a461e08b 100644
--- a/include/internal/catch_objc.hpp
+++ b/include/internal/catch_objc.hpp
@@ -106,7 +106,7 @@ namespace Catch {
std::string name = Detail::getAnnotation( cls, "Name", testCaseName );
std::string desc = Detail::getAnnotation( cls, "Description", testCaseName );
- getStaticRegisteries().registerTest( TestCaseInfo( new OcMethod( cls, selector ), name.c_str(), desc.c_str(), SourceLineInfo() ) );
+ getMutableRegistryHub().registerTest( TestCaseInfo( new OcMethod( cls, selector ), name.c_str(), desc.c_str(), SourceLineInfo() ) );
noTestMethods++;
}
}
diff --git a/include/internal/catch_static_registries_impl.hpp b/include/internal/catch_registry_hub.hpp
index fb8ec552..28b00efc 100644
--- a/include/internal/catch_static_registries_impl.hpp
+++ b/include/internal/catch_registry_hub.hpp
@@ -5,7 +5,7 @@
* 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_interfaces_static_registries.h"
+#include "catch_interfaces_registry_hub.h"
#include "catch_test_case_registry_impl.hpp"
#include "catch_reporter_registry.hpp"
@@ -15,13 +15,13 @@ namespace Catch {
namespace {
- class StaticRegistries : public IStatics, public IStaticRegistries {
+ class RegistryHub : public IRegistryHub, public IMutableRegistryHub {
- StaticRegistries( const StaticRegistries& );
- void operator=( const StaticRegistries& );
+ RegistryHub( const RegistryHub& );
+ void operator=( const RegistryHub& );
- public: // IStatics
- StaticRegistries() {
+ public: // IRegistryHub
+ RegistryHub() {
}
virtual const IReporterRegistry& getReporterRegistry() const {
return m_reporterRegistry;
@@ -33,7 +33,7 @@ namespace Catch {
return m_exceptionTranslatorRegistry;
}
- public: // IStaticRegistries
+ public: // IMutableRegistryHub
virtual void registerReporter( const std::string& name, IReporterFactory* factory ) {
m_reporterRegistry.registerReporter( name, factory );
}
@@ -50,23 +50,24 @@ namespace Catch {
ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;
};
- inline StaticRegistries*& getTheStaticRegistries() {
- static StaticRegistries* registries = NULL;
- if( !registries )
- registries = new StaticRegistries();
- return registries;
+ // Single, global, instance
+ inline RegistryHub*& getTheRegistryHub() {
+ static RegistryHub* theRegistryHub = NULL;
+ if( !theRegistryHub )
+ theRegistryHub = new RegistryHub();
+ return theRegistryHub;
}
}
- IStatics& getStatics() {
- return *getTheStaticRegistries();
+ IRegistryHub& getRegistryHub() {
+ return *getTheRegistryHub();
}
- IStaticRegistries& getStaticRegistries() {
- return *getTheStaticRegistries();
+ IMutableRegistryHub& getMutableRegistryHub() {
+ return *getTheRegistryHub();
}
void cleanUp() {
- delete getTheStaticRegistries();
- getTheStaticRegistries() = NULL;
+ delete getTheRegistryHub();
+ getTheRegistryHub() = NULL;
Context::cleanUp();
}
diff --git a/include/internal/catch_reporter_registrars.hpp b/include/internal/catch_reporter_registrars.hpp
index 8d36827f..33af47da 100644
--- a/include/internal/catch_reporter_registrars.hpp
+++ b/include/internal/catch_reporter_registrars.hpp
@@ -8,7 +8,7 @@
#ifndef TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
-#include "catch_interfaces_static_registries.h"
+#include "catch_interfaces_registry_hub.h"
namespace Catch {
@@ -29,7 +29,7 @@ namespace Catch {
public:
ReporterRegistrar( const std::string& name ) {
- getStaticRegistries().registerReporter( name, new ReporterFactory() );
+ getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
}
};
}
diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp
index d4fc1fa6..6e4b0c0a 100644
--- a/include/internal/catch_runner_impl.hpp
+++ b/include/internal/catch_runner_impl.hpp
@@ -80,7 +80,7 @@ namespace Catch {
virtual void runAll( bool runHiddenTests = false ) {
m_reporter->StartGroup( "" );
- const std::vector<TestCaseInfo>& allTests = getStatics().getTestCaseRegistry().getAllTests();
+ const std::vector<TestCaseInfo>& allTests = getRegistryHub().getTestCaseRegistry().getAllTests();
for( std::size_t i=0; i < allTests.size(); ++i ) {
if( runHiddenTests || !allTests[i].isHidden() ) {
if( aborting() ) {
@@ -100,7 +100,7 @@ namespace Catch {
TestSpec testSpec( rawTestSpec );
- const std::vector<TestCaseInfo>& allTests = getStatics().getTestCaseRegistry().getAllTests();
+ const std::vector<TestCaseInfo>& allTests = getRegistryHub().getTestCaseRegistry().getAllTests();
std::size_t testsRun = 0;
for( std::size_t i=0; i < allTests.size(); ++i ) {
if( testSpec.matches( allTests[i].getName() ) ) {
@@ -282,7 +282,7 @@ namespace Catch {
// This just means the test was aborted due to failure
}
catch(...) {
- acceptMessage( getStatics().getExceptionTranslatorRegistry().translateActiveException() );
+ acceptMessage( getRegistryHub().getExceptionTranslatorRegistry().translateActiveException() );
acceptResult( ResultWas::ThrewException );
}
m_info.clear();
diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp
index 2c22d237..46d2805e 100644
--- a/include/internal/catch_test_case_registry_impl.hpp
+++ b/include/internal/catch_test_case_registry_impl.hpp
@@ -109,7 +109,7 @@ namespace Catch {
const char* name,
const char* description,
const SourceLineInfo& lineInfo ) {
- getStaticRegistries().registerTest( TestCaseInfo( testCase, name, description, lineInfo ) );
+ getMutableRegistryHub().registerTest( TestCaseInfo( testCase, name, description, lineInfo ) );
}
} // end namespace Catch