Closed getsoubl closed 1 month ago
It is called 3 times, because it has 3 elements. Why do you need to the details?
Hello , Just for educational reasons, I am wondering how does it work
Right so the basic answer is that first time the GENERATE
macro is executed, it creates an object that lives outside of the TEST_CASE
, using the arguments provided by the user to the GENERATE
macro. Every subsequent case, it uses some internal metadata generated by the macro to find the previously created object.
After the test case is finished executing*, the generator object is queried on whether it has more elements, if yes, the generator is moved forward and test case is executed again. If not, then it is done.
I am reading about catch2 framework. I am trying to understand how internally the GENERATE macro works For example having the following section TEST_CASE("Foo") { auto i = GENERATE(1,2,3); std::cout << i << std::endl; } How is it called 3 times? Checking the internal implementation of makeGenerators is not clear to me . My understanding that this GENERATE returns a IteratorGenerator . But how the next is called ?