diff options
| author | Martin Hořeňovský | 2020-06-01 19:04:23 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-07-22 20:44:22 +0200 |
| commit | 480f3f418b07cba56421041564211f24d8376e37 (patch) | |
| tree | e9166abd289766819aa2c254b0de97acc45dd63e /tests/SelfTest/UsageTests/Generators.tests.cpp | |
| parent | 3ceaad7d6603d637f0d80f2bd3470ef3ac2b41fd (diff) | |
| download | catch3-480f3f418b07cba56421041564211f24d8376e37.tar.gz | |
Improved generator tracking
* 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
Diffstat (limited to 'tests/SelfTest/UsageTests/Generators.tests.cpp')
| -rw-r--r-- | tests/SelfTest/UsageTests/Generators.tests.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/SelfTest/UsageTests/Generators.tests.cpp b/tests/SelfTest/UsageTests/Generators.tests.cpp index 45088111..acfef8a9 100644 --- a/tests/SelfTest/UsageTests/Generators.tests.cpp +++ b/tests/SelfTest/UsageTests/Generators.tests.cpp @@ -255,6 +255,22 @@ TEST_CASE("Copy and then generate a range", "[generators]") { } } +TEST_CASE("#1913 - GENERATE inside a for loop should not keep recreating the generator", "[regression][generators]") { + static int counter = 0; + for (int i = 0; i < 3; ++i) { + int _ = GENERATE(1, 2); + (void)_; + ++counter; + } + // There should be at most 6 (3 * 2) counter increments + REQUIRE(counter < 7); +} + +TEST_CASE("#1913 - GENERATEs can share a line", "[regression][generators]") { + int i = GENERATE(1, 2); int j = GENERATE(3, 4); + REQUIRE(i != j); +} + #if defined(__clang__) #pragma clang diagnostic pop #endif |