From 06134ba1677be44d59e3566fbb318c0f0a9ee81d Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 12 Apr 2011 18:44:58 +0100 Subject: [PATCH] Make FixtureWrapper class name unique using the preprocessor instead of a specialisations --- 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 -struct FixtureWrapper{}; } // end namespace Catch @@ -136,11 +133,11 @@ struct FixtureWrapper{}; /////////////////////////////////////////////////////////////////////////////// #define TEST_CASE_METHOD( ClassName, TestName, Desc )\ - namespace Catch{ template<> struct FixtureWrapper : ClassName \ + struct INTERNAL_CATCH_UNIQUE_NAME( Catch_FixtureWrapper ) : ClassName \ { \ void test(); \ - }; }\ - namespace { Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &Catch::FixtureWrapper::test, TestName, Desc ); } \ - void Catch::FixtureWrapper::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