31 lines
775 B
C++
31 lines
775 B
C++
#include <cruft/util/ranges/adjacent.hpp>
|
|
|
|
#include <cruft/util/tap.hpp>
|
|
|
|
#include <algorithm>
|
|
|
|
int main()
|
|
{
|
|
static int const constexpr INPUT[] = { 1, 1, 2, 3, 5, 8 };
|
|
static int const constexpr EXPECTED[][2] = {
|
|
{ 1, 1 },
|
|
{ 1, 2 },
|
|
{ 2, 3 },
|
|
{ 3, 5 },
|
|
{ 5, 8 },
|
|
};
|
|
|
|
cruft::TAP::logger tap;
|
|
|
|
// Use a temporary in an attempt to trigger cvref related type errors when calling the range closure.
|
|
std::span<int const> input_span (INPUT);
|
|
const bool same = std::ranges::equal (
|
|
input_span | 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 ();
|
|
} |