diff options
| author | Martin Hořeňovský | 2025-10-14 22:14:47 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2025-10-16 09:16:56 +0200 |
| commit | 49d79e9e9c40e644304945dd5a8e4e78d0c61d10 (patch) | |
| tree | ab0ed18db89b464e8e36f4964cd91af2bd6b4135 /tests/SelfTest | |
| parent | 33e6fd217aee285eca97bef175df716264088b8a (diff) | |
| download | catch3-49d79e9e9c40e644304945dd5a8e4e78d0c61d10.tar.gz | |
Fix section filtering to make sense
Specifically, this commit makes the `-c`/`--section` parameter
strictly ordered and hierarchical, unlike how it behaved before,
which was a huge mess -- see #3038 for details.
Closes #3038
Diffstat (limited to 'tests/SelfTest')
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/Details.tests.cpp | 62 | ||||
| -rw-r--r-- | tests/SelfTest/UsageTests/Tricky.tests.cpp | 18 |
2 files changed, 62 insertions, 18 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp index 5566bb59..d968d942 100644 --- a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp @@ -7,6 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include <catch2/catch_test_macros.hpp> +#include <catch2/generators/catch_generators.hpp> #include <catch2/internal/catch_enforce.hpp> #include <catch2/internal/catch_case_insensitive_comparisons.hpp> #include <catch2/internal/catch_optional.hpp> @@ -170,3 +171,64 @@ TEST_CASE( "Decomposer checks that the argument is 0 when handling " CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION } + + +TEST_CASE( "foo", "[approvals]" ) { + SECTION( "A" ) { + SECTION( "B1" ) { REQUIRE( true ); } + SECTION( "B2" ) { REQUIRE( true ); } + SECTION( "B3" ) { REQUIRE( true ); } + } +} + +TEST_CASE( "bar", "[approvals]" ) { + REQUIRE( true ); + SECTION( "A" ) { + SECTION( "B1" ) { REQUIRE( true ); } + SECTION( "B2" ) { REQUIRE( true ); } + SECTION( "B3" ) { REQUIRE( true ); } + } + REQUIRE( true ); +} + +TEST_CASE( "baz", "[approvals]" ) { + SECTION( "A" ) { REQUIRE( true ); } + auto _ = GENERATE( 1, 2, 3 ); + (void)_; + SECTION( "B" ) { REQUIRE( true ); } +} + +TEST_CASE( "qux", "[approvals]" ) { + REQUIRE( true ); + SECTION( "A" ) { REQUIRE( true ); } + auto _ = GENERATE( 1, 2, 3 ); + (void)_; + SECTION( "B" ) { REQUIRE( true ); } + REQUIRE( true ); +} + +TEST_CASE( "corge", "[approvals]" ) { + REQUIRE( true ); + SECTION( "A" ) { + REQUIRE( true ); + } + auto i = GENERATE( 1, 2, 3 ); + DYNAMIC_SECTION( "i=" << i ) { + REQUIRE( true ); + } + REQUIRE( true ); +} + +TEST_CASE("grault", "[approvals]") { + REQUIRE( true ); + SECTION( "A" ) { + REQUIRE( true ); + } + SECTION("B") { + auto i = GENERATE( 1, 2, 3 ); + DYNAMIC_SECTION( "i=" << i ) { + REQUIRE( true ); + } + } + REQUIRE( true ); +} diff --git a/tests/SelfTest/UsageTests/Tricky.tests.cpp b/tests/SelfTest/UsageTests/Tricky.tests.cpp index 041d7867..fe93e8cf 100644 --- a/tests/SelfTest/UsageTests/Tricky.tests.cpp +++ b/tests/SelfTest/UsageTests/Tricky.tests.cpp @@ -354,27 +354,9 @@ TEST_CASE("#1514: stderr/stdout is not captured in tests aborted by an exception FAIL("1514"); } - -TEST_CASE( "#2025: -c shouldn't cause infinite loop", "[sections][generators][regression][.approvals]" ) { - SECTION( "Check cursor from buffer offset" ) { - auto bufPos = GENERATE_REF( range( 0, 44 ) ); - WHEN( "Buffer position is " << bufPos ) { REQUIRE( 1 == 1 ); } - } -} - TEST_CASE("#2025: original repro", "[sections][generators][regression][.approvals]") { auto fov = GENERATE(true, false); DYNAMIC_SECTION("fov_" << fov) { std::cout << "inside with fov: " << fov << '\n'; } } - -TEST_CASE("#2025: same-level sections", "[sections][generators][regression][.approvals]") { - SECTION("A") { - SUCCEED(); - } - auto i = GENERATE(1, 2, 3); - SECTION("B") { - REQUIRE(i < 4); - } -} |