Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

docs for TEMPLATE_LIST_TEST_CASE

Commit
e90d5a86e42b696309e6c5357d36c999f9235f3e
Author
Jozef Grajciar ·
Committer
Martin Hořeňovský
Parents
dbc1295354ee

Files · Download .tar.gz

Changes

 docs/test-cases-and-sections.md | 21 +++++++++++++++++++--
 docs/test-fixtures.md           | 13 +++++++++++++
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/docs/test-cases-and-sections.md b/docs/test-cases-and-sections.md
index 8a494b5c..b7f79ef1 100644
--- a/docs/test-cases-and-sections.md
+++ b/docs/test-cases-and-sections.md
@@ -96,8 +96,8 @@ Other than the additional prefixes and the formatting in the console reporter th
 ## Type parametrised test cases
 
 In addition to `TEST_CASE`s, Catch2 also supports test cases parametrised
-by types, in the form of `TEMPLATE_TEST_CASE` and
-`TEMPLATE_PRODUCT_TEST_CASE`.
+by types, in the form of `TEMPLATE_TEST_CASE`,
+`TEMPLATE_PRODUCT_TEST_CASE` and `TEMPLATE_LIST_TEST_CASE`.
 
 * **TEMPLATE_TEST_CASE(** _test name_ , _tags_,  _type1_, _type2_, ..., _typen_ **)**
 
@@ -192,6 +192,23 @@ _While there is an upper limit on the number of types you can specify
 in single `TEMPLATE_TEST_CASE` or `TEMPLATE_PRODUCT_TEST_CASE`, the limit
 is very high and should not be encountered in practice._
 
+* **TEMPLATE_LIST_TEST_CASE(** _test name_, _tags_, _type list_ **)**
+
+_type list_ is a generic list of types on which test case should be instantiated.
+List can be `std::tuple`, `boost::mpl::list`, `boost::mp11::mp_list` or anything with
+`template <typename...>` signature.
+
+This allows you to reuse the _type list_ in multiple test cases.
+
+Example:
+```cpp
+using MyTypes = std::tuple<int, char, float>;
+TEMPLATE_LIST_TEST_CASE("Template test case with test types specified inside std::tuple", "[template][list]", MyTypes)
+{
+    REQUIRE(sizeof(TestType) > 0);
+}
+```
+
 
 ## Signature based parametrised test cases
 
diff --git a/docs/test-fixtures.md b/docs/test-fixtures.md
index 5a2d4df5..5a3f877b 100644
--- a/docs/test-fixtures.md
+++ b/docs/test-fixtures.md
@@ -111,6 +111,19 @@ TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(Template_Fixture_2, "A TEMPLATE_PRODUCT_TE
 }
 ```
 
+Catch2 also provides `TEMPLATE_LIST_TEST_CASE_METHOD` to support template fixtures with types specified in
+template type lists like `std::tuple`, `boost::mpl::list` or `boost::mp11::mp_list`. This test case works the same as `TEMPLATE_TEST_CASE_METHOD`,
+only difference is the source of types. This allows you to reuse the template type list in multiple test cases.
+
+Example:
+```cpp
+using MyTypes = std::tuple<int, char, double>;
+TEMPLATE_LIST_TEST_CASE_METHOD(Template_Fixture, "Template test case method with test types specified inside std::tuple", "[class][template][list]", MyTypes)
+{
+    REQUIRE( Template_Fixture<TestType>::m_a == 1 );
+}
+```
+
 ---
 
 [Home](Readme.md#top)