mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:47:34 +00:00
AK: Reimplement comparisons on AK::Time using operator<=>
This allows us to make all comparision operators on the class constexpr without pulling in a bunch of boilerplate. We don't use the `<compare>` header because it doesn't compile in the main serenity cross-build due to the include paths to LibC being incompatible with how libc++ expects them to be for clang builds.
This commit is contained in:
parent
83ad5bfba0
commit
a8fcd39b88
3 changed files with 29 additions and 25 deletions
|
@ -475,3 +475,18 @@ TEST_CASE(years_to_days_since_epoch_span)
|
|||
EXPECT_EQ(actual_days, expected_days);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(user_defined_literals)
|
||||
{
|
||||
using namespace AK::TimeLiterals;
|
||||
static_assert(Time::from_nanoseconds(123) == 123_ns, "Factory is same as UDL");
|
||||
|
||||
static_assert(100_ms > 10_ms, "LT UDL");
|
||||
static_assert(1000_ns == 1_us, "EQ UDL");
|
||||
static_assert(1_sec > 1_ms, "GT UDL");
|
||||
static_assert(100_ms >= 100'000_us, "GE UDL (eq)");
|
||||
static_assert(100_ms >= 99'999_us, "GE UDL (gt)");
|
||||
static_assert(100_ms <= 100'000_us, "LE UDL (eq)");
|
||||
static_assert(100_ms <= 100'001_us, "LE UDL (lt)");
|
||||
static_assert(1_sec != 2_sec, "NE UDL");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue