mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
LibWeb: Implement subtraction using saturated_addition in CSSPixels
Fixes overflow bug found by UBSAN.
This commit is contained in:
parent
26c20e3da1
commit
c431167736
2 changed files with 12 additions and 1 deletions
|
@ -76,4 +76,15 @@ TEST_CASE(comparison2)
|
|||
EXPECT_EQ(CSSPixels(123) == CSSPixels(123), true);
|
||||
}
|
||||
|
||||
TEST_CASE(saturated_addition)
|
||||
{
|
||||
EXPECT_EQ(CSSPixels(INFINITY), CSSPixels(INFINITY) + 1);
|
||||
}
|
||||
|
||||
TEST_CASE(saturated_subtraction)
|
||||
{
|
||||
auto value = CSSPixels(INFINITY);
|
||||
EXPECT_EQ(value - -1, CSSPixels(INFINITY));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue