-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using GENERATE macro in a for loop #1913
Comments
That's definitely unintended behaviour. At a glance, what happens is that the What this boils down to is a 5-bit binary counter, where each number leads to 5 assertions: 5 * 2**5 == 160. |
ah great, thanks for you reply, Martin - I was indeed wondering how the 160 came to be :-) |
I have a prototype fix for this issue. The problem is that it is kinda brittle, and also that it silently breaks code like this: TEST_CASE() {
int i = GENERATE(1, 2); int j = GENERATE(3, 4);
} because they are both on the same line. I can probably fix that too, but it will take a bit longer. |
* Successive executions of the same `GENERATE` macro (e.g. because of a for loop) no longer lead to multiple nested generators. * The same line can now contain multiple `GENERATE` macros without issues. Fixes #1913
I have this code:
I would like to understand why there is 32 assertions and actually quite a lot of e.g. pairs (1,3). I would expect 2*2*2 = 8 assertions. Basically twice the set of {(1,3), (1, 4), (2, 3), (2, 4) } (same when the loop is only till n < 1). |
When using a simple GENERATE expression inside a 'for' loop, the number of iterations increases dramatically
This results in 160 assertions (according to the catch console output). I would expect 10.
If I put the GENERATE() outside the for loop, I get 10 assertions.
Is this expected behaviour or a bug?
Using Catch v2.11.3 with clang-1103.0.32.29 on macos.
The text was updated successfully, but these errors were encountered: