Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Changed some names in test case registry

- in preparation for a bigger refactoring
Commit
79627cdcdb457d21c04b762ed5c128397dd3d807
Author
Phil Nash ·
Parents
10c36aa74c0d

Files · Download .tar.gz

Changes

 include/internal/catch_impl.hpp                    |  2 +-
 include/internal/catch_interfaces_testcase.h       |  6 +++---
 include/internal/catch_objc.hpp                    |  2 +-
 include/internal/catch_test_case_info.cpp          |  4 ++--
 include/internal/catch_test_case_info.h            |  8 ++++----
 include/internal/catch_test_case_registry_impl.hpp | 22 +++++++---------------
 include/internal/catch_test_registry.hpp           | 19 +++++++------------
 7 files changed, 25 insertions(+), 38 deletions(-)

diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp
index a62ce3c0..96b7a452 100644
--- a/include/internal/catch_impl.hpp
+++ b/include/internal/catch_impl.hpp
@@ -49,7 +49,7 @@ namespace Catch {
     StreamBufBase::~StreamBufBase() noexcept {}
     IContext::~IContext() {}
     IResultCapture::~IResultCapture() {}
-    ITestCase::~ITestCase() {}
+    ITestInvoker::~ITestInvoker() {}
     ITestCaseRegistry::~ITestCaseRegistry() {}
     IRegistryHub::~IRegistryHub() {}
     IMutableRegistryHub::~IMutableRegistryHub() {}
diff --git a/include/internal/catch_interfaces_testcase.h b/include/internal/catch_interfaces_testcase.h
index c9ab3238..9e02b14f 100644
--- a/include/internal/catch_interfaces_testcase.h
+++ b/include/internal/catch_interfaces_testcase.h
@@ -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;
diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp
index 30237ac4..300d796f 100644
--- a/include/internal/catch_objc.hpp
+++ b/include/internal/catch_objc.hpp
@@ -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 ) {}
diff --git a/include/internal/catch_test_case_info.cpp b/include/internal/catch_test_case_info.cpp
index 04bebecd..f75f5a3c 100644
--- a/include/internal/catch_test_case_info.cpp
+++ b/include/internal/catch_test_case_info.cpp
@@ -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 {
diff --git a/include/internal/catch_test_case_info.h b/include/internal/catch_test_case_info.h
index 1ff0c819..7f6d5a85 100644
--- a/include/internal/catch_test_case_info.h
+++ b/include/internal/catch_test_case_info.h
@@ -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,
diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp
index d50b3b28..cbe755e3 100644
--- a/include/internal/catch_test_case_registry_impl.hpp
+++ b/include/internal/catch_test_case_registry_impl.hpp
@@ -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 );
     }
 
     ///////////////////////////////////////////////////////////////////////////
diff --git a/include/internal/catch_test_registry.hpp b/include/internal/catch_test_registry.hpp
index 1f269ee9..374b9228 100644
--- a/include/internal/catch_test_registry.hpp
+++ b/include/internal/catch_test_registry.hpp
@@ -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 );