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
This commit is contained in:
parent
4902cd7215
commit
21a1cd5683
12 changed files with 630 additions and 8 deletions
|
@ -46,6 +46,18 @@ struct Template_Fixture {
|
|||
T m_a;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct Template_Fixture_2 {
|
||||
Template_Fixture_2() {}
|
||||
|
||||
T m_a;
|
||||
};
|
||||
|
||||
template< typename T>
|
||||
struct Template_Foo {
|
||||
size_t size() { return 0; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -62,6 +74,11 @@ TEMPLATE_TEST_CASE_METHOD(Template_Fixture, "A TEMPLATE_TEST_CASE_METHOD based t
|
|||
REQUIRE( Template_Fixture<TestType>::m_a == 1 );
|
||||
}
|
||||
|
||||
TEMPLATE_PRODUCT_TEST_CASE_METHOD(Template_Fixture_2, "A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds","[class][template][product]",(std::vector,Template_Foo),(int,float))
|
||||
{
|
||||
REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 0 );
|
||||
}
|
||||
|
||||
// We should be able to write our tests within a different namespace
|
||||
namespace Inner
|
||||
{
|
||||
|
@ -74,6 +91,11 @@ namespace Inner
|
|||
{
|
||||
REQUIRE( Template_Fixture<TestType>::m_a == 2 );
|
||||
}
|
||||
|
||||
TEMPLATE_PRODUCT_TEST_CASE_METHOD(Template_Fixture_2, "A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails","[.][class][template][product][failing]",(std::vector,Template_Foo),(int,float))
|
||||
{
|
||||
REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue