mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Added facility to write self-registering test cases as methods
This commit is contained in:
		| @@ -134,6 +134,9 @@ struct AutoReg | ||||
|         TestRegistry::instance().registerTest( TestCaseInfo( new MethodTestCase<C>( method ), name, description ) ); | ||||
|     } | ||||
| }; | ||||
|  | ||||
| template<typename T, size_t> | ||||
| struct FixtureWrapper{}; | ||||
|      | ||||
| } // end namespace Catch | ||||
|  | ||||
| @@ -145,4 +148,12 @@ struct AutoReg | ||||
| #define CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \ | ||||
|     namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, Name, Desc ); } | ||||
|  | ||||
| #define TEST_CASE_METHOD( ClassName, TestName, Desc )\ | ||||
|     namespace Catch{ template<> struct FixtureWrapper<ClassName, __LINE__> : ClassName \ | ||||
|     { \ | ||||
|         void test(); \ | ||||
|     }; }\ | ||||
|     namespace { Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &Catch::FixtureWrapper<ClassName, __LINE__>::test, TestName, Desc ); } \ | ||||
|     void Catch::FixtureWrapper<ClassName, __LINE__>::test() | ||||
|  | ||||
| #endif // TWOBLUECUBES_CATCH_REGISTRY_HPP_INCLUDED | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash