#include <cassert>
#include <concepts>
#include <functional>
#include "test_comparisons.h"
#include "test_macros.h"
#include "helper_concepts.h"
#include "helper_types.h"
static_assert(std::three_way_comparable<std::reference_wrapper<StrongOrder>>);
static_assert(std::three_way_comparable<std::reference_wrapper<WeakOrder>>);
static_assert(std::three_way_comparable<std::reference_wrapper<PartialOrder>>);
static_assert(!std::three_way_comparable<std::reference_wrapper<NonComparable>>);
template <typename T, typename Order>
constexpr void test() {
T t{47};
T bigger{94};
T smaller{82};
T unordered{std::numeric_limits<int>::min()};
{
std::reference_wrapper<T> rw1{t};
std::reference_wrapper<T> rw2{t};
assert(testOrder(rw1, rw2, Order::equivalent));
}
{
std::reference_wrapper<T> rw1{smaller};
std::reference_wrapper<T> rw2{bigger};
assert(testOrder(rw1, rw2, Order::less));
}
{
std::reference_wrapper<T> rw1{bigger};
std::reference_wrapper<T> rw2{smaller};
assert(testOrder(rw1, rw2, Order::greater));
}
if constexpr (std::same_as<T, PartialOrder>) {
std::reference_wrapper<T> rw1{bigger};
std::reference_wrapper<T> rw2{unordered};
assert(testOrder(rw1, rw2, Order::unordered));
}
}
constexpr bool test() {
test<int, std::strong_ordering>();
test<StrongOrder, std::strong_ordering>();
test<int, std::weak_ordering>();
test<WeakOrder, std::weak_ordering>();
test<int, std::partial_ordering>();
test<PartialOrder, std::partial_ordering>();
test<LessAndEqComp, std::weak_ordering>();
return true;
}
int main(int, char**) {
test();
static_assert(test());
return 0;
}