2010-11-10 00:24:00 +01:00
|
|
|
/*
|
|
|
|
* Created by Phil on 18/10/2010.
|
|
|
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
|
|
|
*
|
|
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
*/
|
2012-09-17 07:42:29 +02:00
|
|
|
#ifndef TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
|
2010-11-10 00:24:00 +01:00
|
|
|
|
|
|
|
#include "catch_common.h"
|
2011-01-07 20:57:32 +01:00
|
|
|
#include "catch_interfaces_testcase.h"
|
2015-03-04 08:08:53 +01:00
|
|
|
#include "catch_compiler_capabilities.h"
|
2017-07-12 23:39:31 +02:00
|
|
|
#include "catch_stringref.h"
|
2018-11-08 07:26:39 +01:00
|
|
|
#include "catch_preprocessor.hpp"
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
#include "catch_meta.hpp"
|
2010-11-10 00:24:00 +01:00
|
|
|
|
2019-11-04 21:35:57 +01:00
|
|
|
#include <memory>
|
|
|
|
|
2012-05-16 09:02:20 +02:00
|
|
|
namespace Catch {
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2010-11-10 00:24:00 +01:00
|
|
|
template<typename C>
|
2017-07-12 19:01:54 +02:00
|
|
|
class TestInvokerAsMethod : public ITestInvoker {
|
|
|
|
void (C::*m_testAsMethod)();
|
2012-05-10 22:46:46 +02:00
|
|
|
public:
|
2017-07-13 09:25:47 +02:00
|
|
|
TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {}
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2017-07-12 19:01:54 +02:00
|
|
|
void invoke() const override {
|
2010-11-10 00:24:00 +01:00
|
|
|
C obj;
|
2017-07-12 19:01:54 +02:00
|
|
|
(obj.*m_testAsMethod)();
|
2010-11-10 00:24:00 +01:00
|
|
|
}
|
|
|
|
};
|
2011-01-07 20:57:32 +01:00
|
|
|
|
2019-11-04 21:35:57 +01:00
|
|
|
std::unique_ptr<ITestInvoker> makeTestInvoker( void(*testAsFunction)() );
|
2013-03-16 21:18:52 +01:00
|
|
|
|
2017-07-12 23:39:31 +02:00
|
|
|
template<typename C>
|
2019-11-04 21:35:57 +01:00
|
|
|
std::unique_ptr<ITestInvoker> makeTestInvoker( void (C::*testAsMethod)() ) {
|
|
|
|
return std::make_unique<TestInvokerAsMethod<C>>( testAsMethod );
|
2017-07-12 23:39:31 +02:00
|
|
|
}
|
2013-03-16 21:18:52 +01:00
|
|
|
|
2017-07-12 23:39:31 +02:00
|
|
|
struct NameAndTags {
|
2019-11-07 12:45:16 +01:00
|
|
|
NameAndTags(StringRef const& name_ = StringRef(),
|
|
|
|
StringRef const& tags_ = StringRef()) noexcept:
|
|
|
|
name(name_), tags(tags_) {}
|
2017-07-12 23:39:31 +02:00
|
|
|
StringRef name;
|
|
|
|
StringRef tags;
|
2010-11-10 00:24:00 +01:00
|
|
|
};
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2017-07-12 23:39:31 +02:00
|
|
|
struct AutoReg : NonCopyable {
|
2019-11-04 21:35:57 +01:00
|
|
|
AutoReg( std::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept;
|
2017-07-12 23:39:31 +02:00
|
|
|
};
|
2015-11-20 17:54:07 +01:00
|
|
|
|
2010-11-10 00:24:00 +01:00
|
|
|
} // end namespace Catch
|
|
|
|
|
2017-08-27 17:03:32 +02:00
|
|
|
#if defined(CATCH_CONFIG_DISABLE)
|
|
|
|
#define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \
|
|
|
|
static void TestName()
|
|
|
|
#define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \
|
|
|
|
namespace{ \
|
2018-11-08 07:26:39 +01:00
|
|
|
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \
|
2017-08-27 17:03:32 +02:00
|
|
|
void test(); \
|
|
|
|
}; \
|
|
|
|
} \
|
|
|
|
void TestName::test()
|
2019-04-17 20:23:24 +02:00
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( TestName, TestFunc, Name, Tags, Signature, ... ) \
|
|
|
|
INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature))
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( TestNameClass, TestName, ClassName, Name, Tags, Signature, ... ) \
|
2018-11-08 07:26:39 +01:00
|
|
|
namespace{ \
|
2019-04-17 20:23:24 +02:00
|
|
|
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \
|
|
|
|
INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
|
2018-11-08 07:26:39 +01:00
|
|
|
} \
|
2019-04-17 20:23:24 +02:00
|
|
|
} \
|
|
|
|
INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))
|
|
|
|
|
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \
|
|
|
|
INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_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, typename TestType, __VA_ARGS__ )
|
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \
|
|
|
|
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_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, typename TestType, __VA_ARGS__ ) )
|
2019-10-27 21:07:21 +01:00
|
|
|
#endif
|
2019-04-17 20:23:24 +02:00
|
|
|
|
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \
|
|
|
|
INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_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, Signature, __VA_ARGS__ )
|
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \
|
|
|
|
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_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, Signature, __VA_ARGS__ ) )
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \
|
|
|
|
INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_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, typename T, __VA_ARGS__ )
|
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \
|
|
|
|
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_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, typename T, __VA_ARGS__ ) )
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \
|
|
|
|
INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_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, Signature, __VA_ARGS__ )
|
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \
|
|
|
|
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_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, Signature, __VA_ARGS__ ) )
|
|
|
|
#endif
|
2017-08-27 17:03:32 +02:00
|
|
|
#endif
|
|
|
|
|
2013-03-16 21:18:52 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2015-12-15 08:50:51 +01:00
|
|
|
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
|
|
|
|
static void TestName(); \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
2017-09-07 16:51:33 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
2018-07-22 14:06:21 +02:00
|
|
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
|
2015-12-15 08:50:51 +01:00
|
|
|
static void TestName()
|
2013-03-16 21:18:52 +01:00
|
|
|
#define INTERNAL_CATCH_TESTCASE( ... ) \
|
2015-12-15 08:50:51 +01:00
|
|
|
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
|
2013-03-16 21:18:52 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
2017-09-07 16:51:33 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
2017-08-10 11:34:26 +02:00
|
|
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
|
2013-03-16 21:18:52 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2015-12-15 08:50:51 +01:00
|
|
|
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
2017-09-07 16:51:33 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
2013-03-16 21:18:52 +01:00
|
|
|
namespace{ \
|
2018-11-08 07:26:39 +01:00
|
|
|
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \
|
2013-03-16 21:18:52 +01:00
|
|
|
void test(); \
|
|
|
|
}; \
|
2017-08-10 11:34:26 +02:00
|
|
|
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \
|
2013-03-16 21:18:52 +01:00
|
|
|
} \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
|
2015-12-15 08:50:51 +01:00
|
|
|
void TestName::test()
|
|
|
|
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
|
|
|
|
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
|
2013-03-16 21:18:52 +01:00
|
|
|
|
2015-11-20 17:54:07 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
2017-09-07 16:51:33 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
2018-07-22 14:06:21 +02:00
|
|
|
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
|
2015-11-20 17:54:07 +01:00
|
|
|
|
2018-11-08 07:26:39 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2019-04-17 20:23:24 +02:00
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(TestName, TestFunc, Name, Tags, Signature, ... )\
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
2018-11-08 07:26:39 +01:00
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
2019-04-17 20:23:24 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
|
2019-10-18 12:30:17 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
|
2019-04-17 20:23:24 +02:00
|
|
|
INTERNAL_CATCH_DECLARE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
|
2019-04-18 11:35:33 +02:00
|
|
|
namespace {\
|
2019-04-17 20:23:24 +02:00
|
|
|
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\
|
|
|
|
INTERNAL_CATCH_TYPE_GEN\
|
|
|
|
INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
|
|
|
|
INTERNAL_CATCH_NTTP_REG_GEN(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature))\
|
2018-11-08 07:26:39 +01:00
|
|
|
template<typename...Types> \
|
|
|
|
struct TestName{\
|
2019-04-17 20:23:24 +02:00
|
|
|
TestName(){\
|
|
|
|
int index = 0; \
|
|
|
|
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\
|
2018-11-08 07:26:39 +01:00
|
|
|
using expander = int[];\
|
2019-04-17 20:23:24 +02:00
|
|
|
(void)expander{(reg_test(Types{}, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++, 0)... };/* NOLINT */ \
|
2018-11-08 07:26:39 +01:00
|
|
|
}\
|
|
|
|
};\
|
2019-04-17 20:23:24 +02:00
|
|
|
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
|
|
|
|
TestName<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\
|
|
|
|
return 0;\
|
|
|
|
}();\
|
|
|
|
}\
|
2018-11-08 07:26:39 +01:00
|
|
|
}\
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
|
2019-04-17 20:23:24 +02:00
|
|
|
INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature))
|
2018-11-08 07:26:39 +01:00
|
|
|
|
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \
|
2019-04-17 20:23:24 +02:00
|
|
|
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, typename TestType, __VA_ARGS__ )
|
2018-11-08 07:26:39 +01:00
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \
|
2019-04-17 20:23:24 +02:00
|
|
|
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, typename TestType, __VA_ARGS__ ) )
|
2019-10-27 21:07:21 +01:00
|
|
|
#endif
|
2018-11-08 07:26:39 +01:00
|
|
|
|
2019-04-17 20:23:24 +02:00
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \
|
|
|
|
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, Signature, __VA_ARGS__ )
|
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \
|
|
|
|
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, Signature, __VA_ARGS__ ) )
|
|
|
|
#endif
|
2019-04-18 11:35:33 +02:00
|
|
|
|
2019-04-17 20:23:24 +02:00
|
|
|
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(TestName, TestFuncName, Name, Tags, Signature, TmplTypes, TypesList) \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
2019-04-17 20:23:24 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
template<typename TestType> static void TestFuncName(); \
|
2019-04-17 20:23:24 +02:00
|
|
|
namespace {\
|
|
|
|
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \
|
|
|
|
INTERNAL_CATCH_TYPE_GEN \
|
|
|
|
INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
template<typename... Types> \
|
|
|
|
struct TestName { \
|
2019-04-17 20:23:24 +02:00
|
|
|
void reg_tests() { \
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
int index = 0; \
|
|
|
|
using expander = int[]; \
|
2019-02-17 21:52:22 +01:00
|
|
|
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\
|
|
|
|
constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\
|
|
|
|
constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\
|
|
|
|
(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)... };/* NOLINT */\
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
} \
|
|
|
|
}; \
|
|
|
|
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
|
2019-10-18 11:38:00 +02:00
|
|
|
using TestInit = typename create<TestName, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>()), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type; \
|
2019-04-17 20:23:24 +02:00
|
|
|
TestInit t; \
|
|
|
|
t.reg_tests(); \
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
return 0; \
|
|
|
|
}(); \
|
|
|
|
} \
|
2019-04-17 20:23:24 +02:00
|
|
|
} \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
template<typename TestType> \
|
|
|
|
static void TestFuncName()
|
|
|
|
|
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\
|
2019-04-17 20:23:24 +02:00
|
|
|
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, typename T,__VA_ARGS__)
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\
|
2019-04-17 20:23:24 +02:00
|
|
|
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, typename T, __VA_ARGS__ ) )
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\
|
|
|
|
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, Signature, __VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\
|
|
|
|
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, Signature, __VA_ARGS__ ) )
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
#endif
|
|
|
|
|
2019-05-27 17:24:16 +02:00
|
|
|
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2(TestName, TestFunc, Name, Tags, TmplList)\
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
2019-05-27 17:24:16 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
2019-10-18 12:30:17 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
|
2019-05-27 17:24:16 +02:00
|
|
|
template<typename TestType> static void TestFunc(); \
|
|
|
|
namespace {\
|
|
|
|
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\
|
|
|
|
INTERNAL_CATCH_TYPE_GEN\
|
|
|
|
template<typename... Types> \
|
|
|
|
struct TestName { \
|
|
|
|
void reg_tests() { \
|
|
|
|
int index = 0; \
|
|
|
|
using expander = int[]; \
|
|
|
|
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++, 0)... };/* NOLINT */\
|
|
|
|
} \
|
|
|
|
};\
|
|
|
|
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
|
2019-10-18 11:38:00 +02:00
|
|
|
using TestInit = typename convert<TestName, TmplList>::type; \
|
2019-05-27 17:24:16 +02:00
|
|
|
TestInit t; \
|
|
|
|
t.reg_tests(); \
|
|
|
|
return 0; \
|
2019-10-27 21:07:21 +01:00
|
|
|
}(); \
|
2019-05-27 17:24:16 +02:00
|
|
|
}}\
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
|
2019-05-27 17:24:16 +02:00
|
|
|
template<typename TestType> \
|
|
|
|
static void TestFunc()
|
|
|
|
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(Name, Tags, TmplList) \
|
|
|
|
INTERNAL_CATCH_TEMPLATE_LIST_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, TmplList )
|
|
|
|
|
|
|
|
|
2019-04-17 20:23:24 +02:00
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, Signature, ... ) \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
2018-11-08 07:26:39 +01:00
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
2019-04-17 20:23:24 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
|
2019-10-18 12:30:17 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
|
2019-04-17 20:23:24 +02:00
|
|
|
namespace {\
|
|
|
|
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){ \
|
|
|
|
INTERNAL_CATCH_TYPE_GEN\
|
|
|
|
INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
|
|
|
|
INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
|
|
|
|
INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))\
|
2018-11-08 07:26:39 +01:00
|
|
|
template<typename...Types> \
|
|
|
|
struct TestNameClass{\
|
2019-04-17 20:23:24 +02:00
|
|
|
TestNameClass(){\
|
|
|
|
int index = 0; \
|
|
|
|
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\
|
2018-11-08 07:26:39 +01:00
|
|
|
using expander = int[];\
|
2019-04-17 20:23:24 +02:00
|
|
|
(void)expander{(reg_test(Types{}, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++, 0)... };/* NOLINT */ \
|
2018-11-08 07:26:39 +01:00
|
|
|
}\
|
|
|
|
};\
|
2019-04-17 20:23:24 +02:00
|
|
|
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
|
|
|
|
TestNameClass<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\
|
|
|
|
return 0;\
|
|
|
|
}();\
|
|
|
|
}\
|
2018-11-08 07:26:39 +01:00
|
|
|
}\
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
|
2019-04-17 20:23:24 +02:00
|
|
|
INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))
|
2018-11-08 07:26:39 +01:00
|
|
|
|
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \
|
2019-04-17 20:23:24 +02:00
|
|
|
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, typename T, __VA_ARGS__ )
|
2018-11-08 07:26:39 +01:00
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \
|
2019-04-17 20:23:24 +02:00
|
|
|
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, typename T, __VA_ARGS__ ) )
|
2018-11-08 07:26:39 +01:00
|
|
|
#endif
|
2010-12-27 21:51:06 +01:00
|
|
|
|
2019-04-17 20:23:24 +02:00
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \
|
|
|
|
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, Signature, __VA_ARGS__ )
|
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \
|
|
|
|
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, Signature, __VA_ARGS__ ) )
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(TestNameClass, TestName, ClassName, Name, Tags, Signature, TmplTypes, TypesList)\
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
2019-04-17 20:23:24 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
|
2019-10-18 12:30:17 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
template<typename TestType> \
|
|
|
|
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \
|
|
|
|
void test();\
|
|
|
|
};\
|
2019-04-18 11:35:33 +02:00
|
|
|
namespace {\
|
2019-04-17 20:23:24 +02:00
|
|
|
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestNameClass) {\
|
|
|
|
INTERNAL_CATCH_TYPE_GEN \
|
|
|
|
INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
template<typename...Types>\
|
|
|
|
struct TestNameClass{\
|
2019-04-17 20:23:24 +02:00
|
|
|
void reg_tests(){\
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
int index = 0;\
|
|
|
|
using expander = int[];\
|
2019-02-17 21:52:22 +01:00
|
|
|
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\
|
|
|
|
constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\
|
|
|
|
constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\
|
|
|
|
(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)... };/* NOLINT */ \
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
}\
|
|
|
|
};\
|
|
|
|
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
|
2019-10-18 11:38:00 +02:00
|
|
|
using TestInit = typename create<TestNameClass, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>()), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type;\
|
2019-04-17 20:23:24 +02:00
|
|
|
TestInit t;\
|
|
|
|
t.reg_tests();\
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
return 0;\
|
|
|
|
}(); \
|
|
|
|
}\
|
2019-04-17 20:23:24 +02:00
|
|
|
}\
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
template<typename TestType> \
|
|
|
|
void TestName<TestType>::test()
|
|
|
|
|
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\
|
2019-04-17 20:23:24 +02:00
|
|
|
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, typename T, __VA_ARGS__ )
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\
|
2019-04-17 20:23:24 +02:00
|
|
|
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, typename T,__VA_ARGS__ ) )
|
Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified
e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
(std::tuple, std::pair, std::map),
((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>
Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions
Closes #1454
2018-12-06 19:27:33 +01:00
|
|
|
#endif
|
|
|
|
|
2019-04-17 20:23:24 +02:00
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\
|
|
|
|
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, Signature, __VA_ARGS__ )
|
|
|
|
#else
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\
|
|
|
|
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, Signature,__VA_ARGS__ ) )
|
|
|
|
#endif
|
|
|
|
|
2019-05-27 17:24:16 +02:00
|
|
|
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, TmplList) \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
2019-05-27 17:24:16 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
2019-10-18 12:30:17 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
|
2019-05-27 17:24:16 +02:00
|
|
|
template<typename TestType> \
|
|
|
|
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \
|
|
|
|
void test();\
|
|
|
|
};\
|
|
|
|
namespace {\
|
|
|
|
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){ \
|
|
|
|
INTERNAL_CATCH_TYPE_GEN\
|
|
|
|
template<typename...Types>\
|
|
|
|
struct TestNameClass{\
|
|
|
|
void reg_tests(){\
|
|
|
|
int index = 0;\
|
|
|
|
using expander = int[];\
|
|
|
|
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++, 0)... };/* NOLINT */ \
|
|
|
|
}\
|
|
|
|
};\
|
|
|
|
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
|
2019-10-18 11:38:00 +02:00
|
|
|
using TestInit = typename convert<TestNameClass, TmplList>::type;\
|
2019-05-27 17:24:16 +02:00
|
|
|
TestInit t;\
|
|
|
|
t.reg_tests();\
|
|
|
|
return 0;\
|
|
|
|
}(); \
|
|
|
|
}}\
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
|
2019-05-27 17:24:16 +02:00
|
|
|
template<typename TestType> \
|
|
|
|
void TestName<TestType>::test()
|
|
|
|
|
|
|
|
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(ClassName, Name, Tags, TmplList) \
|
|
|
|
INTERNAL_CATCH_TEMPLATE_LIST_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, TmplList )
|
|
|
|
|
2019-04-17 20:23:24 +02:00
|
|
|
|
2012-09-17 07:42:29 +02:00
|
|
|
#endif // TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
|