mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Renamed static registries -> registry hub
This commit is contained in:
@@ -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 ) )
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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 ) );
|
||||
}
|
||||
};
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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";
|
||||
|
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user