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
Generators is a feature from Catch2. It is somewhat similar to a SECTION() that generates a different value each time it is entered. This has been requested on reddit.
This is currently not on the roadmap, mostly because:
I didn't know if people used them, and
they seem like they would be complex to implement.
Now I have some data that people do use them, so there's extra motivation to implement it. Still need to weigh the pros and cons. The API would likely be different from Catch2 however, likely using concepts rather than a virtual interface.
The text was updated successfully, but these errors were encountered:
I have used simple generators (FixedValuesGenerator?) to a limited degree in some of my code, like this:
int param1 = GENERATE(0, 1, 50, 99, 100);
int param2 = GENERATE(0x10, 0x100, 0x1000);
bool param3 = GENERATE(true, false);
auto x = func(param1, param2, param3);
CHECK( ... );
if (param1 > 0) {
CHECK( ... );
}
if (param3) {
CHECK( ... )
}
If I understand things correctly, the same thing can currently be implemented in Snitch like this:
for (int param1 : std::vector<int>{0, 1, 50, 99, 100}) {
CAPTURE(param1);
for (int param2 : std::vector<int>{0x10, 0x100, 0x1000}) {
CAPTURE(param2);
for (bool param3 : std::vector<bool>{true, false}) {
CAPTURE(param3);
... do the tests ...
}
}
}
(I have not tested this)
Surely the code with GENERATE looks much nicer, but that is syntactic sugar only. Question is: are the any more complicated usage scenarios of GENERATE, which can't be modeled like this?
If all generators can be fully replaced with similar code, then I would support adding them only if they can be added without any significant bloat. But, if generators can be implemented as a special case of SECTIONs with few extra parameters, then go for it.
Generators is a feature from Catch2. It is somewhat similar to a
SECTION()
that generates a different value each time it is entered. This has been requested on reddit.This is currently not on the roadmap, mostly because:
Now I have some data that people do use them, so there's extra motivation to implement it. Still need to weigh the pros and cons. The API would likely be different from Catch2 however, likely using concepts rather than a virtual interface.
The text was updated successfully, but these errors were encountered: