Since views are lazy evaluated, they allow us to create infinite series. For example, to generate a series of integers, we can use the view::ints function. Then, we need to limit the series so we can use view::take to keep the first five elements from the series:
TEST_CASE("Infinite series"){
vector<int> values = ranges::view::ints(1) | ranges::view::take(5);
vector<int> expected{1, 2, 3, 4, 5};
CHECK_EQ(expected, values);
}
Additional data generation can be done using view::iota for any type that allows increments, for example, for chars:
TEST_CASE("Infinite series"){...
vector<char> values = ranges::view::iota('a') |
ranges::view::take(5);
vector<char> expected{'a', 'b', 'c', 'd', 'e'};
CHECK_EQ(expected, values);
}