mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-25 23:06:10 +01:00
renamed hub -> context
(also did some reformatting)
This commit is contained in:
parent
aec1e5ed86
commit
5ec53b2788
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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 <sstream>
|
||||
|
||||
@ -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<typename T>
|
||||
@ -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 ) )
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define TWOBLUECUBES_CATCH_RUNNERCONFIG_HPP_INCLUDED
|
||||
|
||||
#include "catch_interfaces_reporter.h"
|
||||
#include "catch_hub.h"
|
||||
#include "catch_context.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@ -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<IReporter> getReporter()
|
||||
{
|
||||
if( !m_reporter.get() )
|
||||
const_cast<Config*>( this )->setReporter( Hub::getReporterRegistry().create( "basic", *this ) );
|
||||
const_cast<Config*>( 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;
|
||||
|
63
include/internal/catch_context.h
Normal file
63
include/internal/catch_context.h
Normal file
@ -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 <memory>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
|
||||
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<IReporterRegistry> m_reporterRegistry;
|
||||
std::auto_ptr<ITestCaseRegistry> m_testCaseRegistry;
|
||||
std::auto_ptr<IExceptionTranslatorRegistry> m_exceptionTranslatorRegistry;
|
||||
IRunner* m_runner;
|
||||
IResultCapture* m_resultCapture;
|
||||
std::map<std::string, GeneratorsForTest*> m_generatorsByTestName;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
|
@ -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<OutputDebugWriter>;
|
||||
@ -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<std::string, GeneratorsForTest*>::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();
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 <iterator>
|
||||
#include <vector>
|
||||
@ -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 IGenerator<T>*>::const_iterator it = m_composed.begin();
|
||||
typename std::vector<const IGenerator<T>*>::const_iterator itEnd = m_composed.end();
|
||||
|
@ -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 <memory>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
|
||||
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<IReporterRegistry> m_reporterRegistry;
|
||||
std::auto_ptr<ITestCaseRegistry> m_testCaseRegistry;
|
||||
std::auto_ptr<IExceptionTranslatorRegistry> m_exceptionTranslatorRegistry;
|
||||
IRunner* m_runner;
|
||||
IResultCapture* m_resultCapture;
|
||||
std::map<std::string, GeneratorsForTest*> m_generatorsByTestName;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_HUB_H_INCLUDED
|
@ -77,7 +77,7 @@ namespace Catch
|
||||
std::string(*translateFunction)( T& )
|
||||
)
|
||||
{
|
||||
Catch::Hub::getExceptionTranslatorRegistry().registerTranslator
|
||||
Catch::Context::getExceptionTranslatorRegistry().registerTranslator
|
||||
( new ExceptionTranslator<T>( translateFunction ) );
|
||||
}
|
||||
};
|
||||
|
@ -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<TestCaseInfo>::const_iterator it = Hub::getTestCaseRegistry().getAllTests().begin();
|
||||
std::vector<TestCaseInfo>::const_iterator itEnd = Hub::getTestCaseRegistry().getAllTests().end();
|
||||
std::vector<TestCaseInfo>::const_iterator it = Context::getTestCaseRegistry().getAllTests().begin();
|
||||
std::vector<TestCaseInfo>::const_iterator itEnd = Context::getTestCaseRegistry().getAllTests().end();
|
||||
for(; it != itEnd; ++it )
|
||||
{
|
||||
// !TBD: consider listAs()
|
||||
|
@ -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++;
|
||||
|
||||
}
|
||||
|
@ -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() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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<TestCaseInfo> allTests = Hub::getTestCaseRegistry().getAllTests();
|
||||
std::vector<TestCaseInfo> 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<TestCaseInfo> allTests = Hub::getTestCaseRegistry().getAllTests();
|
||||
std::vector<TestCaseInfo> 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();
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include "catch_test_registry.hpp"
|
||||
#include "catch_test_case_info.hpp"
|
||||
#include "catch_hub.h"
|
||||
#include "catch_context.h"
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
@ -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
|
||||
|
@ -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
|
||||
|
@ -180,7 +180,7 @@ namespace Catch
|
||||
Expected::Result expectedResult
|
||||
)
|
||||
{
|
||||
forEach( Hub::getTestCaseRegistry().getMatchingTestCases( testSpec ),
|
||||
forEach( Context::getTestCaseRegistry().getMatchingTestCases( testSpec ),
|
||||
MetaTestRunner( expectedResult ) );
|
||||
}
|
||||
|
||||
|
@ -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 = "<group>"; };
|
||||
4A6D0C4F149B3E3D00DB3EAA /* catch_generators.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_generators.hpp; sourceTree = "<group>"; };
|
||||
4A6D0C50149B3E3D00DB3EAA /* catch_generators_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_generators_impl.hpp; sourceTree = "<group>"; };
|
||||
4A6D0C51149B3E3D00DB3EAA /* catch_hub.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_hub.h; sourceTree = "<group>"; };
|
||||
4A6D0C52149B3E3D00DB3EAA /* catch_hub_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_hub_impl.hpp; sourceTree = "<group>"; };
|
||||
4A6D0C51149B3E3D00DB3EAA /* catch_context.h */ = {isa = PBXFileReference; fileEncoding = 4; path = catch_context.h; sourceTree = "<group>"; };
|
||||
4A6D0C52149B3E3D00DB3EAA /* catch_context_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; path = catch_context_impl.hpp; sourceTree = "<group>"; };
|
||||
4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_capture.h; sourceTree = "<group>"; };
|
||||
4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_exception.h; sourceTree = "<group>"; };
|
||||
4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_reporter.h; sourceTree = "<group>"; };
|
||||
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user