mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
AK: Add Time::is_negative() to detect negative time values
This commit is contained in:
parent
3cbc2364a8
commit
a2a5cb0f24
2 changed files with 14 additions and 0 deletions
|
@ -261,3 +261,16 @@ TEST_CASE(truncation)
|
|||
EXPECT_EQ(TIME(9223372036854, 775'807'000).to_truncated_microseconds(), 0x7fff'ffff'ffff'ffff);
|
||||
EXPECT_EQ(TIME(9223372036854, 775'808'000).to_truncated_microseconds(), 0x7fff'ffff'ffff'ffff);
|
||||
}
|
||||
|
||||
TEST_CASE(is_negative)
|
||||
{
|
||||
auto small = Time::from_nanoseconds(10);
|
||||
auto large = Time::from_nanoseconds(15);
|
||||
auto result = small - large;
|
||||
EXPECT_EQ(result.to_nanoseconds(), -5);
|
||||
EXPECT(result.is_negative());
|
||||
|
||||
result = large - small;
|
||||
EXPECT_EQ(result.to_nanoseconds(), 5);
|
||||
EXPECT(!result.is_negative());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue