Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for generic typelists in TEMPLATE_TEST_CASE #1627

Closed
BenjaminW3 opened this issue May 12, 2019 · 0 comments · Fixed by #1642
Closed

Support for generic typelists in TEMPLATE_TEST_CASE #1627

BenjaminW3 opened this issue May 12, 2019 · 0 comments · Fixed by #1642

Comments

@BenjaminW3
Copy link
Contributor

Description
Often I already have a typelist of some kind (std::tuple, boost::mpl::list (Boost.MPL), mp_list (Boost.mp11)) and I want to execute a test for each of the types contained in the typelist. I have not yet found a good way to do this with catch2. In my case the types in those lists depend on the current platform and other settings so it is hard if not impossible to write them into the test case header.

Currently I am working around this by iterating over the type list in the test body and calling a separate template test method for each type. However, with this approach the type is not part of the test name and it is not easily possible to see which type triggered the error.

To enable this use-case, a new macro called TEMPLATE_LIST_TEST_CASE or similar would have to be added which internally adds a test case for each of the contained types.
This is supported by Boost.Test as well as gtest.

Additional context
Example pseudo code usage:

using Types = std::tuple<int, double, float>;
TEMPLATE_LIST_TEST_CASE("test", "[test]", Types)
{
    // Do something with the TestType here which would be `int`, `double` or `float`
}
TEMPLATE_LIST_TEST_CASE("test2", "[test]", Types)
{
    // This allows to reuse the typelist for multiple tests
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant