#include <array>
#include <cassert>
#include "test_comparisons.h"
constexpr std::size_t N{1};
static_assert(std::three_way_comparable<std::array<int, N>>);
struct NonComparable {};
static_assert(!std::three_way_comparable<std::array<NonComparable, N>>);
template <typename Elem, typename Order>
constexpr void test_sequence_container_array_spaceship_with_type() {
{
std::array<Elem, 0> l1 = {};
std::array<Elem, 0> l2 = {};
assert(testOrder(l1, l2, Order::equivalent));
}
{
std::array l1{Elem{1}, Elem{1}};
std::array l2{Elem{1}, Elem{1}};
assert(testOrder(l1, l2, Order::equivalent));
}
{
std::array l1{Elem{1}, Elem{1}};
std::array l2{Elem{1}, Elem{2}};
assert(testOrder(l1, l2, Order::less));
}
{
std::array l1{Elem{1}, Elem{3}};
std::array l2{Elem{1}, Elem{2}};
assert(testOrder(l1, l2, Order::greater));
}
if constexpr (std::is_same_v<Elem, PartialOrder>) {
std::array l1{Elem{1}, Elem{std::numeric_limits<int>::min()}};
std::array l2{Elem{1}, Elem{2}};
assert(testOrder(l1, l2, Order::unordered));
}
}
constexpr bool test_sequence_container_array_spaceship() {
test_sequence_container_array_spaceship_with_type<int, std::strong_ordering>();
test_sequence_container_array_spaceship_with_type<StrongOrder, std::strong_ordering>();
test_sequence_container_array_spaceship_with_type<WeakOrder, std::weak_ordering>();
test_sequence_container_array_spaceship_with_type<PartialOrder, std::partial_ordering>();
test_sequence_container_array_spaceship_with_type<LessAndEqComp, std::weak_ordering>();
return true;
}
int main(int, char**) {
assert(test_sequence_container_array_spaceship());
static_assert(test_sequence_container_array_spaceship());
return 0;
}