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

Make FixtureWrapper class name unique using the preprocessor instead of a specialisations

Commit
06134ba1677be44d59e3566fbb318c0f0a9ee81d
Author
Phil Nash ·
Parents
b3db552cfab5

Files · Download .tar.gz

Changes

 Test/ClassTests.cpp              | 10 +++++++---
 internal/catch_test_registry.hpp | 11 ++++-------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/Test/ClassTests.cpp b/Test/ClassTests.cpp
index 3cadd645..ba1e5b6f 100644
--- a/Test/ClassTests.cpp
+++ b/Test/ClassTests.cpp
@@ -51,7 +51,11 @@ TEST_CASE_METHOD( Fixture, "./succeeding/Fixture/succeedingCase", "A method base
     REQUIRE( m_a == 1 );        
 }
 
-TEST_CASE_METHOD( Fixture, "./failing/Fixture/failingCase", "A method based test run that fails" )
-{   
-    REQUIRE( m_a == 2 );        
+// We should be able to write our tests within a different namespace
+namespace Inner
+{
+    TEST_CASE_METHOD( Fixture, "./failing/Fixture/failingCase", "A method based test run that fails" )
+    {   
+        REQUIRE( m_a == 2 );        
+    }
 }
diff --git a/internal/catch_test_registry.hpp b/internal/catch_test_registry.hpp
index e20bdc84..ab7e1670 100644
--- a/internal/catch_test_registry.hpp
+++ b/internal/catch_test_registry.hpp
@@ -112,9 +112,6 @@ private:
     void operator=
         ( const AutoReg& );
 };
-
-template<typename T, size_t>
-struct FixtureWrapper{};
     
 } // end namespace Catch
 
@@ -136,11 +133,11 @@ struct FixtureWrapper{};
 
 ///////////////////////////////////////////////////////////////////////////////
 #define TEST_CASE_METHOD( ClassName, TestName, Desc )\
-    namespace Catch{ template<> struct FixtureWrapper<ClassName, __LINE__> : ClassName \
+    struct INTERNAL_CATCH_UNIQUE_NAME( Catch_FixtureWrapper ) : ClassName \
     { \
         void test(); \
-    }; }\
-    namespace { Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &Catch::FixtureWrapper<ClassName, __LINE__>::test, TestName, Desc ); } \
-    void Catch::FixtureWrapper<ClassName, __LINE__>::test()
+    }; \
+    namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( Catch_FixtureWrapper )::test, TestName, Desc ); } \
+    void INTERNAL_CATCH_UNIQUE_NAME( Catch_FixtureWrapper )::test()
 
 #endif // TWOBLUECUBES_CATCH_REGISTRY_HPP_INCLUDED