diff options
| author | Martin Hořeňovský | 2026-01-12 14:10:25 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2026-01-12 14:27:49 +0100 |
| commit | 44c597f0742b491399994afa00070b99d3ef2885 (patch) | |
| tree | dbb0581d1bf101f4423f43b1e1d0ed150ed48ddb /tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp | |
| parent | 6aedc79870e7b9122b11810abe195f8cc70fbaa5 (diff) | |
| download | catch3-44c597f0742b491399994afa00070b99d3ef2885.tar.gz | |
Add Concat generator for combining multiple generators
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp')
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp index c044547d..0ba4ab43 100644 --- a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp @@ -85,7 +85,7 @@ TEST_CASE("Generators internals", "[generators][internals]") { filter([](int) { return false; }, values({ 1, 2, 3 })), Catch::GeneratorException); } - + // Non-trivial usage SECTION("Out-of-line predicates are copied into the generator") { auto evilNumber = Catch::Detail::make_unique<int>(2); @@ -586,3 +586,21 @@ TEST_CASE("from_range(container) supports ADL begin/end and arrays", "[generator } } + +TEST_CASE( "ConcatGenerator", "[generators][concat]" ) { + using namespace Catch::Generators; + SECTION( "Cat support single-generator construction" ) { + ConcatGenerator<int> c( value( 1 ) ); + REQUIRE( c.get() == 1 ); + REQUIRE_FALSE( c.next() ); + } + SECTION( "Iterating over multiple generators" ) { + ConcatGenerator<int> c( value( 1 ), values( { 2, 3, 4 } ), value( 5 ) ); + for ( int i = 0; i < 4; ++i ) { + REQUIRE( c.get() == i + 1 ); + REQUIRE( c.next() ); + } + REQUIRE( c.get() == 5 ); + REQUIRE_FALSE( c.next() ); + } +} |