8#ifndef TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
9#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
22class TestInvokerAsMethod :
public ITestInvoker {
23 void (C::*m_testAsMethod)();
29 (obj.*m_testAsMethod)();
33auto makeTestInvoker(
void(*testAsFunction)() ) noexcept -> ITestInvoker*;
53#if defined(CATCH_CONFIG_DISABLE)
54 #define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \
55 static void TestName()
56 #define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \
58 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \
63 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION( TestName, ... ) \
64 template<typename TestType> \
65 static void TestName()
66 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \
68 template<typename TestType> \
69 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \
73 template<typename TestType> \
78 #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
79 static void TestName(); \
80 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
81 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } \
82 CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \
83 static void TestName()
84 #define INTERNAL_CATCH_TESTCASE( ... ) \
85 INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
88 #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
89 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
90 namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } \
91 CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS
94 #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
95 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
97 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \
100 Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); \
102 CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \
103 void TestName::test()
104 #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
105 INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
108 #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
109 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
110 Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); \
111 CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS
114 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(TestName, TestFunc, Name, Tags, ... )\
115 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
116 template<typename TestType> \
117 static void TestFunc();\
119 template<typename...Types> \
121 template<typename...Ts> \
122 TestName(Ts...names){\
123 CATCH_INTERNAL_CHECK_UNIQUE_TYPES(CATCH_REC_LIST(INTERNAL_CATCH_REMOVE_PARENS, __VA_ARGS__)) \
124 using expander = int[];\
125 (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ names, Tags } ), 0)... }; \
128 INTERNAL_CATCH_TEMPLATE_REGISTRY_INITIATE(TestName, Name, __VA_ARGS__) \
130 CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \
131 template<typename TestType> \
132 static void TestFunc()
134#if defined(CATCH_CPP17_OR_GREATER)
135#define CATCH_INTERNAL_CHECK_UNIQUE_TYPES(...) static_assert(Catch::is_unique<__VA_ARGS__>,"Duplicate type detected in declaration of template test case");
137#define CATCH_INTERNAL_CHECK_UNIQUE_TYPES(...) static_assert(Catch::is_unique<__VA_ARGS__>::value,"Duplicate type detected in declaration of template test case");
140#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
141 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \
142 INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, __VA_ARGS__ )
144 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \
145 INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, __VA_ARGS__ ) )
148 #define INTERNAL_CATCH_TEMPLATE_REGISTRY_INITIATE(TestName, Name, ...)\
149 static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
150 TestName<CATCH_REC_LIST(INTERNAL_CATCH_REMOVE_PARENS, __VA_ARGS__)>(CATCH_REC_LIST_UD(INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME,Name, __VA_ARGS__));\
154 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(TestName, TestFuncName, Name, Tags, TmplTypes, TypesList) \
155 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
156 template<typename TestType> static void TestFuncName(); \
158 template<typename... Types> \
161 CATCH_INTERNAL_CHECK_UNIQUE_TYPES(Types...) \
163 using expander = int[]; \
164 constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\
165 constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\
166 constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\
167 (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++, 0)... };\
170 static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
171 using TestInit = Catch::combine<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)> \
172 ::with_types<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(TypesList)>::into<TestName>::type; \
177 CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \
178 template<typename TestType> \
179 static void TestFuncName()
181#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
182 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\
183 INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ),Name,Tags,__VA_ARGS__)
185 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\
186 INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, __VA_ARGS__ ) )
189 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, ... ) \
190 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
192 template<typename TestType> \
193 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \
196 template<typename...Types> \
197 struct TestNameClass{\
198 template<typename...Ts> \
199 TestNameClass(Ts...names){\
200 CATCH_INTERNAL_CHECK_UNIQUE_TYPES(CATCH_REC_LIST(INTERNAL_CATCH_REMOVE_PARENS, __VA_ARGS__)) \
201 using expander = int[];\
202 (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ names, Tags } ), 0)... }; \
205 INTERNAL_CATCH_TEMPLATE_REGISTRY_INITIATE(TestNameClass, Name, __VA_ARGS__)\
207 CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS\
208 template<typename TestType> \
209 void TestName<TestType>::test()
211#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
212 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \
213 INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, __VA_ARGS__ )
215 #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \
216 INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, __VA_ARGS__ ) )
219 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(TestNameClass, TestName, ClassName, Name, Tags, TmplTypes, TypesList)\
220 CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
221 template<typename TestType> \
222 struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \
226 template<typename...Types>\
227 struct TestNameClass{\
229 CATCH_INTERNAL_CHECK_UNIQUE_TYPES(Types...)\
231 using expander = int[];\
232 constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\
233 constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\
234 constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\
235 (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++, 0)... }; \
238 static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
239 using TestInit = Catch::combine<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>\
240 ::with_types<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(TypesList)>::into<TestNameClass>::type;\
245 CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \
246 template<typename TestType> \
247 void TestName<TestType>::test()
249#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
250 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\
251 INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, __VA_ARGS__ )
253 #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\
254 INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, __VA_ARGS__ ) )
TestInvokerAsMethod(void(C::*testAsMethod)()) noexcept
void invoke() const override
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
auto makeTestInvoker(void(*testAsFunction)()) noexcept -> ITestInvoker *
yubihsm_pkcs11_object_template template