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