Add Concat generator for combining multiple generators

This commit is contained in:
Martin Hořeňovský
2026-01-12 14:27:49 +01:00
parent 6aedc79870
commit 44c597f074
21 changed files with 1020 additions and 20 deletions
@@ -321,3 +321,16 @@ TEST_CASE( "GENERATE can combine literals and generators", "[generators]" ) {
random( -100, 100 ) ) ) );
REQUIRE( i % 2 == 0 );
}
TEST_CASE( "cat generator", "[generators][concat]" ) {
SECTION("Simple usage") {
const int input = GENERATE( cat( value( 0 ) ), cat( value( 1 ), value( 2 ) ) );
REQUIRE( input < 3 );
}
SECTION( "Used in map" ) {
const int input = GENERATE(
map( []( int i ) { return i * 2; },
cat( value( 1 ), take( 4, random( 10, 10'000'000 ) ) ) ) );
REQUIRE( input % 2 == 0 );
}
}