libcruft-util/test/ranges/adjacent.cpp
Danny Robson 8eeb35cf36 ranges: add a naive implemenation of "adjacent"
This works around a diffiency in the clang-19 ranges library.
2024-11-11 11:19:33 +10:00

29 lines
625 B
C++

#include <cruft/util/ranges/adjacent.hpp>
#include <cruft/util/tap.hpp>
#include <algorithm>
int main()
{
static int constexpr INPUT[] = { 1, 1, 2, 3, 5, 8 };
static int constexpr EXPECTED[][2] = {
{ 1, 1 },
{ 1, 2 },
{ 2, 3 },
{ 3, 5 },
{ 5, 8 },
};
cruft::TAP::logger tap;
const bool same = std::ranges::equal (
std::views::all (INPUT) | cruft::ranges::pairwise,
EXPECTED,
[] (auto const &a, auto const &b) { return std::ranges::equal (a, b); }
);
tap.expect (same, "ranges::pairwise fibonacci");
return tap.status ();
}