mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Changed some names in test case registry
- in preparation for a bigger refactoring
This commit is contained in:
parent
10c36aa74c
commit
79627cdcdb
@ -49,7 +49,7 @@ namespace Catch {
|
||||
StreamBufBase::~StreamBufBase() noexcept {}
|
||||
IContext::~IContext() {}
|
||||
IResultCapture::~IResultCapture() {}
|
||||
ITestCase::~ITestCase() {}
|
||||
ITestInvoker::~ITestInvoker() {}
|
||||
ITestCaseRegistry::~ITestCaseRegistry() {}
|
||||
IRegistryHub::~IRegistryHub() {}
|
||||
IMutableRegistryHub::~IMutableRegistryHub() {}
|
||||
|
@ -15,12 +15,12 @@ namespace Catch {
|
||||
|
||||
class TestSpec;
|
||||
|
||||
struct ITestCase {
|
||||
struct ITestInvoker {
|
||||
virtual void invoke () const = 0;
|
||||
virtual ~ITestCase();
|
||||
virtual ~ITestInvoker();
|
||||
};
|
||||
|
||||
using ITestCasePtr = std::shared_ptr<ITestCase>;
|
||||
using ITestCasePtr = std::shared_ptr<ITestInvoker>;
|
||||
|
||||
class TestCase;
|
||||
struct IConfig;
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class OcMethod : public SharedImpl<ITestCase> {
|
||||
class OcMethod : public SharedImpl<ITestInvoker> {
|
||||
|
||||
public:
|
||||
OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {}
|
||||
|
@ -42,7 +42,7 @@ namespace Catch {
|
||||
<< _lineInfo );
|
||||
}
|
||||
|
||||
TestCase makeTestCase( ITestCase* _testCase,
|
||||
TestCase makeTestCase( ITestInvoker* _testCase,
|
||||
std::string const& _className,
|
||||
std::string const& _name,
|
||||
std::string const& _descOrTags,
|
||||
@ -130,7 +130,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
|
||||
TestCase::TestCase( ITestCase* testCase, TestCaseInfo const& info ) : TestCaseInfo( info ), test( testCase ) {}
|
||||
TestCase::TestCase( ITestInvoker* testCase, TestCaseInfo const& info ) : TestCaseInfo( info ), test( testCase ) {}
|
||||
|
||||
|
||||
TestCase TestCase::withName( std::string const& _newName ) const {
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct ITestCase;
|
||||
struct ITestInvoker;
|
||||
|
||||
struct TestCaseInfo {
|
||||
enum SpecialProperties{
|
||||
@ -59,7 +59,7 @@ namespace Catch {
|
||||
class TestCase : public TestCaseInfo {
|
||||
public:
|
||||
|
||||
TestCase( ITestCase* testCase, TestCaseInfo const& info );
|
||||
TestCase( ITestInvoker* testCase, TestCaseInfo const& info );
|
||||
|
||||
TestCase withName( std::string const& _newName ) const;
|
||||
|
||||
@ -71,10 +71,10 @@ namespace Catch {
|
||||
bool operator < ( TestCase const& other ) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ITestCase> test;
|
||||
std::shared_ptr<ITestInvoker> test;
|
||||
};
|
||||
|
||||
TestCase makeTestCase( ITestCase* testCase,
|
||||
TestCase makeTestCase( ITestInvoker* testCase,
|
||||
std::string const& className,
|
||||
std::string const& name,
|
||||
std::string const& description,
|
||||
|
@ -125,24 +125,16 @@ namespace Catch {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class FreeFunctionTestCase : public ITestCase {
|
||||
class TestInvokerAsFunction : public ITestInvoker {
|
||||
void(*m_testAsFunction)();
|
||||
public:
|
||||
TestInvokerAsFunction( void(*testAsFunction)() ) : m_testAsFunction( testAsFunction ) {}
|
||||
|
||||
FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {}
|
||||
|
||||
virtual void invoke() const {
|
||||
m_fun();
|
||||
void invoke() const override {
|
||||
m_testAsFunction();
|
||||
}
|
||||
|
||||
private:
|
||||
virtual ~FreeFunctionTestCase();
|
||||
|
||||
TestFunction m_fun;
|
||||
};
|
||||
|
||||
FreeFunctionTestCase::~FreeFunctionTestCase() {}
|
||||
|
||||
|
||||
inline std::string extractClassName( std::string const& classOrQualifiedMethodName ) {
|
||||
std::string className = classOrQualifiedMethodName;
|
||||
if( startsWith( className, '&' ) )
|
||||
@ -157,7 +149,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
void registerTestCase
|
||||
( ITestCase* testCase,
|
||||
( ITestInvoker* testCase,
|
||||
char const* classOrQualifiedMethodName,
|
||||
NameAndDesc const& nameAndDesc,
|
||||
SourceLineInfo const& lineInfo ) {
|
||||
@ -178,7 +170,7 @@ namespace Catch {
|
||||
( TestFunction function,
|
||||
SourceLineInfo const& lineInfo,
|
||||
NameAndDesc const& nameAndDesc ) {
|
||||
registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo );
|
||||
registerTestCase( new TestInvokerAsFunction( function ), "", nameAndDesc, lineInfo );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -15,20 +15,15 @@
|
||||
namespace Catch {
|
||||
|
||||
template<typename C>
|
||||
class MethodTestCase : public ITestCase {
|
||||
|
||||
class TestInvokerAsMethod : public ITestInvoker {
|
||||
void (C::*m_testAsMethod)();
|
||||
public:
|
||||
MethodTestCase( void (C::*method)() ) : m_method( method ) {}
|
||||
TestInvokerAsMethod( void (C::*testAsMethod)() ) : m_testAsMethod( testAsMethod ) {}
|
||||
|
||||
virtual void invoke() const {
|
||||
void invoke() const override {
|
||||
C obj;
|
||||
(obj.*m_method)();
|
||||
(obj.*m_testAsMethod)();
|
||||
}
|
||||
|
||||
private:
|
||||
virtual ~MethodTestCase() {}
|
||||
|
||||
void (C::*m_method)();
|
||||
};
|
||||
|
||||
typedef void(*TestFunction)();
|
||||
@ -43,7 +38,7 @@ struct NameAndDesc {
|
||||
};
|
||||
|
||||
void registerTestCase
|
||||
( ITestCase* testCase,
|
||||
( ITestInvoker* testCase,
|
||||
char const* className,
|
||||
NameAndDesc const& nameAndDesc,
|
||||
SourceLineInfo const& lineInfo );
|
||||
@ -63,7 +58,7 @@ struct AutoReg {
|
||||
SourceLineInfo const& lineInfo ) {
|
||||
|
||||
registerTestCase
|
||||
( new MethodTestCase<C>( method ),
|
||||
( new TestInvokerAsMethod<C>( method ),
|
||||
className,
|
||||
nameAndDesc,
|
||||
lineInfo );
|
||||
|
Loading…
Reference in New Issue
Block a user