forked from catchorg/Catch2
MapGenerator only calls mapping function if the result is used
Previously the mapping was eager on construction and calls to `next()`. This was fine when generators were always exhausted fully, but with the new generator filtering, we might not want to call the map function eagerly; rather we want to call it only once, after the generator is moved to the target element.
This commit is contained in:
@@ -709,6 +709,7 @@ TEST_CASE("MapGenerator can be skipped forward efficiently",
|
||||
};
|
||||
|
||||
MapGenerator<int, int, decltype(map_func)> map_generator( map_func, values( { 0, 1, 2, 3, 4, 5, 6 } ) );
|
||||
REQUIRE( map_calls == 0 );
|
||||
const int map_calls_1 = map_calls;
|
||||
|
||||
map_generator.skipToNthElement( 4 );
|
||||
|
||||
Reference in New Issue
Block a user