You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all,
I've studied through parametric tests and got confused.
Let's say I have something like this
// some parametric machinery taked from docs (with using std::begin/std::end)
#defineDOCTEST_VALUE_PARAMETERIZED_DATA(data, data_container) \
staticsize_t _doctest_subcase_idx = 0; \
std::for_each(std::begin(data_container), std::end(data_container), [&](constauto& in) { \
DOCTEST_SUBCASE((std::string(#data_container "[") + \
std::to_string(_doctest_subcase_idx++) + "]").c_str()) { data = in; } \
}); \
_doctest_subcase_idx = 0TEST_CASE("something")
{
intconst data_container[] = {10, 8, 7, 4};
int data;
DOCTEST_VALUE_PARAMETERIZED_DATA(data, data_container);
SUBCASE("more1")
{
// ... quite many nested subcases here
}
SUBASE("more2")
{
// ... quite many nested subcases here
}
//Question: As we came into SUBCASE more1,more2 what values of data to expect?// Looks like it is uninitialized for those.
}
Initially I wanted to wrap all in a loop but it woked waaaaay too longer. I didn't wait it finished.
// my initial approachTEST_CASE("something")
{
intconst data_container[] = {10, 8, 7, 4};
for(int data: data_container)
{
SUBCASE("more1")
{
// ... quite many nested subcases here
}
SUBASE("more2")
{
// ... quite many nested subcases here
}
}
}
Can you clarify how do I manage this?
I guess It is impossible to put SUBCASES into function like in this "use case" example:
voiddo_tests(int data)
{
SUBCASE("more1")
{
// ... quite many nested subcases here
}
SUBASE("more2")
{
// ... quite many nested subcases here
}
}
TEST_CASE("something")
{
intconst data_container[] = {10, 8, 7, 4};
for(int data: data_container)
do_tests(data);
}
Is it impossible?
Wrapping this up.
Can you clarify how do I do parametric tests when I do have more subcases than in DOCTEST_VALUE_PARAMETERIZED_DATA?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all,
I've studied through parametric tests and got confused.
Let's say I have something like this
Initially I wanted to wrap all in a loop but it woked waaaaay too longer. I didn't wait it finished.
Can you clarify how do I manage this?
I guess It is impossible to put SUBCASES into function like in this "use case" example:
Is it impossible?
Wrapping this up.
Can you clarify how do I do parametric tests when I do have more subcases than in DOCTEST_VALUE_PARAMETERIZED_DATA?
BR, Daniel
Beta Was this translation helpful? Give feedback.
All reactions