Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-07-04 17:45:30 +0200
committerMartin Hořeňovský2020-07-26 11:35:06 +0200
commit4565b826cff3f8c11325c23d1536ded6acd8fa78 (patch)
treeeb58e60deeaf005abd8de4191fe857795055a21f /tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp
parent250d9b9c72219cc196e971356705af6fd24b6ed2 (diff)
downloadcatch3-4565b826cff3f8c11325c23d1536ded6acd8fa78.tar.gz
Modify generator tracking to allow GENERATEs between SECTIONs
This means that code such as ```cpp TEST_CASE() { SECTION("first") { SUCCEED(); } auto _ = GENERATE(1, 2); SECTION("second") { SUCCEED(); } } ``` will run and report 3 assertions, 1 from section "first" and 2 from section "second". This also applies for greater and potentially more confusing nesting, but fundamentally it is up to the user to avoid overly complex and confusing nestings, just as with `SECTION`s. The old behaviour of `GENERATE` as first thing in a `TEST_CASE`, `GENERATE` not followed by a `SECTION`, etc etc should be unchanged. Closes #1938
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp')
-rw-r--r--tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp b/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp
index fd40abfa..c56adc5e 100644
--- a/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp
@@ -4,6 +4,7 @@
*/
#include <catch2/catch_test_macros.hpp>
+#include <catch2/generators/catch_generators.hpp>
#include <catch2/internal/catch_test_case_tracker.hpp>
@@ -201,3 +202,50 @@ TEST_CASE("#1670 regression check", "[.approvals][tracker]") {
SECTION("2") SUCCEED();
}
}
+
+// #1938 required a rework on how generator tracking works, so that `GENERATE`
+// supports being sandwiched between two `SECTION`s. The following tests check
+// various other scenarios through checking output in approval tests.
+TEST_CASE("#1938 - GENERATE after a section", "[.][regression][generators]") {
+ SECTION("A") {
+ SUCCEED("A");
+ }
+ auto m = GENERATE(1, 2, 3);
+ SECTION("B") {
+ REQUIRE(m);
+ }
+}
+
+TEST_CASE("#1938 - flat generate", "[.][regression][generators]") {
+ auto m = GENERATE(1, 2, 3);
+ REQUIRE(m);
+}
+
+TEST_CASE("#1938 - nested generate", "[.][regression][generators]") {
+ auto m = GENERATE(1, 2, 3);
+ auto n = GENERATE(1, 2, 3);
+ REQUIRE(m);
+ REQUIRE(n);
+}
+
+TEST_CASE("#1938 - mixed sections and generates", "[.][regression][generators]") {
+ auto i = GENERATE(1, 2);
+ SECTION("A") {
+ SUCCEED("A");
+ }
+ auto j = GENERATE(3, 4);
+ SECTION("B") {
+ SUCCEED("B");
+ }
+ auto k = GENERATE(5, 6);
+ CAPTURE(i, j, k);
+ SUCCEED();
+}
+
+TEST_CASE("#1938 - Section followed by flat generate", "[.][regression][generators]") {
+ SECTION("A") {
+ REQUIRE(1);
+ }
+ auto m = GENERATE(2, 3);
+ REQUIRE(m);
+}