mirror of
https://github.com/catchorg/Catch2.git
synced 2025-11-21 12:39:33 +01:00
Add support for templated tests
This adds support for templated tests and test methods via `TEMPLATE_TEST_CASE` and `TEMPLATE_TEST_CASE_METHOD` macros. These work mostly just like their regular counterparts*, but take an unlimited** number of types as their last arguments. * Unlike the plain `TEST_CASE*` macros, the `TEMPLATE*` variants require a tag string. ** In practice there is limit of about 300 types.
This commit is contained in:
committed by
Martin Hořeňovský
parent
489a41012e
commit
2d906a92cb
@@ -92,6 +92,39 @@ Class.tests.cpp:<line number>: FAILED:
|
||||
with expansion:
|
||||
"hello" == "world"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
A TEMPLATE_TEST_CASE_METHOD based test run that fails - double
|
||||
-------------------------------------------------------------------------------
|
||||
Class.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Class.tests.cpp:<line number>: FAILED:
|
||||
REQUIRE( Template_Fixture<TestType>::m_a == 2 )
|
||||
with expansion:
|
||||
1.0 == 2
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
A TEMPLATE_TEST_CASE_METHOD based test run that fails - float
|
||||
-------------------------------------------------------------------------------
|
||||
Class.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Class.tests.cpp:<line number>: FAILED:
|
||||
REQUIRE( Template_Fixture<TestType>::m_a == 2 )
|
||||
with expansion:
|
||||
1.0f == 2
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
A TEMPLATE_TEST_CASE_METHOD based test run that fails - int
|
||||
-------------------------------------------------------------------------------
|
||||
Class.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Class.tests.cpp:<line number>: FAILED:
|
||||
REQUIRE( Template_Fixture<TestType>::m_a == 2 )
|
||||
with expansion:
|
||||
1 == 2
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
A TEST_CASE_METHOD based test run that fails
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -1093,6 +1126,6 @@ due to unexpected exception with message:
|
||||
Why would you throw a std::string?
|
||||
|
||||
===============================================================================
|
||||
test cases: 216 | 163 passed | 49 failed | 4 failed as expected
|
||||
assertions: 1234 | 1105 passed | 108 failed | 21 failed as expected
|
||||
test cases: 226 | 170 passed | 52 failed | 4 failed as expected
|
||||
assertions: 1308 | 1176 passed | 111 failed | 21 failed as expected
|
||||
|
||||
|
||||
Reference in New Issue
Block a user