forked from catchorg/Catch2
Add Concat generator for combining multiple generators
This commit is contained in:
@@ -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() );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user