#include #include #include int main () { cruft::TAP::logger tap; static constexpr int src[] = { 1, 2, 3, 4, 5, 6, 7, 8, }; static constexpr int expected[] = { 1, 2, 3, -1, 4, 5, 6, -2, 7, 8, -3, }; std::vector dst; dst.reserve (std::size (expected)); // Copy out the src array in groups of 3, inserting a decrementing 'line number' value. // It's a little easier that manually juggling iterators and such. int line = 0; for (auto const chunk: src | cruft::ranges::chunk (3)) { // This could be made more efficient by directly insert the chunk in one go, // but it's better to exercise the single iteration case for increased code coverage. for (auto const &i: chunk) dst.push_back (i); dst.push_back (--line); } tap.expect (cruft::equal (cruft::view (dst), cruft::view (expected)), "chunk(3)"); return tap.status (); }