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:
Jozef Grajciar
2018-12-06 19:27:33 +01:00
parent 4902cd7215
commit 21a1cd5683
12 changed files with 630 additions and 8 deletions

View File

@@ -92,6 +92,50 @@ Class.tests.cpp:<line number>: FAILED:
with expansion:
"hello" == "world"
-------------------------------------------------------------------------------
A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 0
-------------------------------------------------------------------------------
Class.tests.cpp:<line number>
...............................................................................
Class.tests.cpp:<line number>: FAILED:
REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 )
with expansion:
0 == 1
-------------------------------------------------------------------------------
A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 1
-------------------------------------------------------------------------------
Class.tests.cpp:<line number>
...............................................................................
Class.tests.cpp:<line number>: FAILED:
REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 )
with expansion:
0 == 1
-------------------------------------------------------------------------------
A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 2
-------------------------------------------------------------------------------
Class.tests.cpp:<line number>
...............................................................................
Class.tests.cpp:<line number>: FAILED:
REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 )
with expansion:
0 == 1
-------------------------------------------------------------------------------
A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 3
-------------------------------------------------------------------------------
Class.tests.cpp:<line number>
...............................................................................
Class.tests.cpp:<line number>: FAILED:
REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 )
with expansion:
0 == 1
-------------------------------------------------------------------------------
A TEMPLATE_TEST_CASE_METHOD based test run that fails - double
-------------------------------------------------------------------------------
@@ -1126,6 +1170,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
test cases: 228 | 172 passed | 52 failed | 4 failed as expected
assertions: 1310 | 1178 passed | 111 failed | 21 failed as expected
test cases: 243 | 183 passed | 56 failed | 4 failed as expected
assertions: 1325 | 1189 passed | 115 failed | 21 failed as expected