1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

LibWeb: Perform rounding when dividing CSSPixels

This should allow us to produce results that more closely match old
layouts when divisions were done in floating-point.
This commit is contained in:
Zaggy1024 2023-09-03 19:03:03 -05:00 committed by Alexander Kalenik
parent bd85e1b30b
commit 98926b487c
27 changed files with 250 additions and 233 deletions

View file

@ -36,6 +36,15 @@ TEST_CASE(division1)
b = CSSPixels(0.25);
EXPECT(!a.might_be_saturated());
EXPECT((a / b).might_be_saturated());
// Results should be rounded:
a = CSSPixels::smallest_positive_value() * 3;
b = 2;
EXPECT((a / b) == CSSPixels::smallest_positive_value() * 2);
a = CSSPixels::smallest_positive_value() * -5;
b = 3;
EXPECT((a / b) == CSSPixels::smallest_positive_value() * -2);
}
TEST_CASE(multiplication1)