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
|
|
|
/*
|
|
|
|
* Created by Jozef on 02/12/2018.
|
|
|
|
* Copyright 2018 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)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TWOBLUECUBES_CATCH_META_HPP_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_META_HPP_INCLUDED
|
|
|
|
|
2018-12-30 23:44:20 +01:00
|
|
|
#include <type_traits>
|
|
|
|
|
2019-02-23 21:06:16 +01:00
|
|
|
namespace Catch {
|
2019-04-23 23:41:13 +02:00
|
|
|
template<typename T>
|
|
|
|
struct always_false : std::false_type {};
|
|
|
|
|
|
|
|
template <typename> struct true_given : std::true_type {};
|
|
|
|
struct is_callable_tester {
|
|
|
|
template <typename Fun, typename... Args>
|
|
|
|
true_given<decltype(std::declval<Fun>()(std::declval<Args>()...))> static test(int);
|
|
|
|
template <typename...>
|
|
|
|
std::false_type static test(...);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_callable;
|
|
|
|
|
|
|
|
template <typename Fun, typename... Args>
|
|
|
|
struct is_callable<Fun(Args...)> : decltype(is_callable_tester::test<Fun, Args...>(0)) {};
|
|
|
|
|
2019-02-23 21:06:16 +01:00
|
|
|
} // namespace Catch
|
|
|
|
|
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 // TWOBLUECUBES_CATCH_META_HPP_INCLUDED
|