Files
clice/tests/unit/Support/Compare.cpp
2025-08-16 23:09:13 +08:00

68 lines
1.2 KiB
C++

#include "Test/Test.h"
#include "Support/Compare.h"
namespace clice::testing {
namespace {
struct Point {
int x;
int y;
};
struct Line {
Point begin;
Point end;
};
suite<"Compare"> compare = [] {
test("Equal") = [] {
constexpr Point p1{1, 2};
constexpr Point p2{1, 2};
constexpr Point p3{2, 3};
static_assert(refl::equal(p1, p2));
static_assert(!refl::equal(p1, p3));
constexpr Line l1{
{1, 2},
{3, 4}
};
constexpr Line l2{
{1, 2},
{3, 4}
};
constexpr Line l3{
{1, 2},
{4, 5}
};
static_assert(refl::equal(l1, l2));
static_assert(!refl::equal(l1, l3));
};
test("Less") = [] {
constexpr Point p1{1, 2};
constexpr Point p2{2, 3};
static_assert(refl::less(p1, p2));
static_assert(!refl::less(p2, p1));
constexpr Line l1{
{1, 2},
{3, 4}
};
constexpr Line l2{
{1, 2},
{4, 5}
};
static_assert(refl::less(l1, l2));
static_assert(!refl::less(l2, l1));
};
};
} // namespace
} // namespace clice::testing