mirror of
https://github.com/catchorg/Catch2.git
synced 2025-10-16 15:15:40 +02:00
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:
@@ -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 );
|
||||
}
|
||||
|
Reference in New Issue
Block a user