Improve naming for TEMPLATE_LIST_TEST_CASE_METHOD

It's not often very useful to name tests simply by incrementing numbers.
This change adds a mechanism by which a name can be generated using both
the index of the type in the type list, and also some from the type
itself somehow.
This commit is contained in:
Chris Sarbora
2023-11-29 22:21:00 -08:00
parent c18b88f7e3
commit df90ea39e1
19 changed files with 227 additions and 20 deletions

View File

@@ -67,3 +67,20 @@ TEMPLATE_LIST_TEST_CASE_METHOD(Template_Fixture, "Template test case method with
{
REQUIRE( Template_Fixture<TestType>::m_a == 1 );
}
// Creating an IndextTestTypeName specialization should alter how template list tests are named.
template<char C> struct NamedType {};
namespace Catch {
template <char C>
struct IndexedTestTypeName<NamedType<C>> {
std::string operator()(size_t) const {
return {C};
}
};
}
using NamedTypes = std::tuple<NamedType<'A'>, NamedType<'B'>, NamedType<'C'>>;
TEMPLATE_LIST_TEST_CASE_METHOD(Template_Foo, "Template list test case with specialized IndexedTestTypeName", "[class][template][list][indexedtesttypename]", NamedTypes)
{
REQUIRE( Template_Foo<TestType>{}.size() == 0 );
}