Is it possible to modify/set a SECTION name during runtime?
I'd like to do this for adding type info in the detailed test output for type parametrized test cases.
Current implementation:
https://github.com/fecjanky/poly_vector/blob/master/test/include/catch_ext.hpp
Basically I'd like to wrap line 44 Func<T>::execute() in a SECTION() where the section name is set during runtime from a string parameter.
Any other ideas are welcome.
Thanks & BR,
Ferenc
--
You received this message because you are subscribed to the Google Groups "CATCH" group.
To unsubscribe from this group and stop receiving emails from it, send an email to catch-forum+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks for the suggestions. I made the modifications according to your suggestion but an assertion fails in TrackerBase::moveToParent() for m_parent being null.
Do you have any idea what could be the problem?
Thanks & Br
Ferenc
Ferenc
if( m_parent )
m_parent->markAsNeedingAnotherRun();
moveToParent();if( m_parent ) {
m_parent->markAsNeedingAnotherRun();
moveToParent();
}
The callstack is like
RunContext::sectionEnded() -> TrackerBase::close() -> TrackerBase::close() -> TrackerBase::moveToParent().
I can reproduce it deterministically so if you have any ideas I can try it out.
Phil, maybe a null check is missing here also like in fail() method?
BR,
Ferenc
Hey,The callstack is like
RunContext::sectionEnded() -> TrackerBase::close() -> TrackerBase::close() -> TrackerBase::moveToParent().
I can reproduce it deterministically so if you have any ideas I can try it out.
Phil, maybe a null check is missing here also like in fail() method?
Update:Wrapping the moveToParent call in null check resulted in infinite recursion.
BR,
Ferenc
#define CATCH_CONFIG_MAIN #include <catch.hpp> namespace detail { template<template<typename> class Func, typename... Ts> struct for_each_type; } #define INTERNAL_STRINGIFY_IMPL(X) #X #define INTERNAL_STRINGIFY(X) INTERNAL_STRINGIFY_IMPL(X) #define INTERNAL_TYPE_P_TEST_CASE(TESTSTRUCT, NAME, DESCR, TPARAM, ...) \ template<typename TPARAM> \ struct TESTSTRUCT \ { \ static void execute(); \ }; \ TEST_CASE(NAME, DESCR) \ { \ ::detail::for_each_type<TESTSTRUCT, __VA_ARGS__>::execute( \ INTERNAL_STRINGIFY(TPARAM)); \ } \ template<typename TPARAM> \ void TESTSTRUCT<TPARAM>::execute() #define TYPE_P_TEST_CASE(NAME, DESCR, TPARAM, ...) \ INTERNAL_TYPE_P_TEST_CASE( \ INTERNAL_CATCH_UNIQUE_NAME( \ ____C_A_T_C_H____T_E_S_T___E_X_T_E_N_S_I_O_N____), \ NAME, \ DESCR, \ TPARAM, \ __VA_ARGS__) namespace detail { template<template<typename> class Func> struct for_each_type<Func> { static void execute(const std::string&) {} }; template<template<typename> class Func, typename T, typename... Ts> struct for_each_type<Func, T, Ts...> { static void execute(const std::string& tParamName) { SECTION(tParamName, typeid(T).name()) { Func<T>::execute(); } for_each_type<Func, Ts...>::execute(tParamName); } }; } TYPE_P_TEST_CASE("repor", "[repro]", T, int, double) { std::vector<T> vec; SECTION("push back") { vec.push_back(T{}); REQUIRE(vec.size() == 1); } SECTION("empty") { REQUIRE(vec.empty()); } }