WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
266950
Add more `LayoutUnit::fromFloat*` API tests from Blink / Chromium
https://bugs.webkit.org/show_bug.cgi?id=266950
Summary
Add more `LayoutUnit::fromFloat*` API tests from Blink / Chromium
Ahmad Saleem
Reported
2023-12-31 07:27:07 PST
Hi Team, Just came across following commit, which has more API test, which we should import to get better coverage: Blink Commit:
https://chromium-review.googlesource.com/c/chromium/src/+/4652129
___ API Tests: TEST(WebCoreLayoutUnit, LayoutUnitFloat) ASSERT_EQ(LayoutUnit(1.25f), LayoutUnit(1.25f + tolerance / 2)); ASSERT_EQ(LayoutUnit(-2.0f), LayoutUnit(-2.0f - tolerance / 2)); TEST(WebCoreLayoutUnit, FromFloatCeil) { const float tolerance = 1.0f / kFixedPointDenominator; ASSERT_EQ(LayoutUnit(1.25f), LayoutUnit::fromFloatCeil(1.25f)); ASSERT_EQ(LayoutUnit(1.25f + tolerance), LayoutUnit::fromFloatCeil(1.25f + tolerance / 2)); ASSERT_EQ(LayoutUnit(), LayoutUnit::fromFloatCeil(-tolerance / 2)); using Limits = std::numeric_limits<float>; // Larger than max() ASSERT_EQ(LayoutUnit::max(), LayoutUnit::FromFloatCeil(Limits::max())); ASSERT_EQ(LayoutUnit::max(), LayoutUnit::FromFloatCeil(Limits::infinity())); // Smaller than Min() ASSERT_EQ(LayoutUnit::min(), LayoutUnit::FromFloatCeil(Limits::lowest())); ASSERT_EQ(LayoutUnit::min(), LayoutUnit::FromFloatCeil(-Limits::infinity())); ASSERT_EQ(LayoutUnit(), LayoutUnit::FromFloatCeil(Limits::quiet_NaN())); } TEST(WebCoreLayoutUnit, FromFloatFloor) { const float tolerance = 1.0f / kFixedPointDenominator; ASSERT_EQ(LayoutUnit(1.25f), LayoutUnit::fromFloatFloor(1.25f)); ASSERT_EQ(LayoutUnit(1.25f), LayoutUnit::fromFloatFloor(1.25f + tolerance / 2)); ASSERT_EQ(LayoutUnit(-tolerance), LayoutUnit::fromFloatFloor(-tolerance / 2)); using Limits = std::numeric_limits<float>; // Larger than max() ASSERT_EQ(LayoutUnit::max(), LayoutUnit::fromFloatFloor(Limits::max())); ASSERT_EQ(LayoutUnit::max(), LayoutUnit::fromFloatFloor(Limits::infinity())); // Smaller than min() ASSERT_EQ(LayoutUnit::min(), LayoutUnit::fromFloatFloor(Limits::lowest())); ASSERT_EQ(LayoutUnit::min(), LayoutUnit::fromFloatFloor(-Limits::infinity())); ASSERT_EQ(LayoutUnit(), LayoutUnit::fromFloatFloor(Limits::quiet_NaN())); } TEST(WebCoreLayoutUnit, FromFloatRound) { const float tolerance = 1.0f / kFixedPointDenominator; ASSERT_EQ(LayoutUnit(1.25f), LayoutUnit::fromFloatRound(1.25f)); ASSERT_EQ(LayoutUnit(1.25f), LayoutUnit::fromFloatRound(1.25f + tolerance / 4)); ASSERT_EQ(LayoutUnit(1.25f + tolerance), LayoutUnit::fromFloatRound(1.25f + tolerance * 3 / 4)); ASSERT_EQ(LayoutUnit(-tolerance), LayoutUnit::fromFloatRound(-tolerance * 3 / 4)); using Limits = std::numeric_limits<float>; // Larger than max() ASSERT_EQ(LayoutUnit::max(), LayoutUnit::fromFloatRound(Limits::max())); ASSERT_EQ(LayoutUnit::max(), LayoutUnit::fromFloatRound(Limits::infinity())); // Smaller than Min() ASSERT_EQ(LayoutUnit::min(), LayoutUnit::fromFloatRound(Limits::lowest())); ASSERT_EQ(LayoutUnit::min(), LayoutUnit::fromFloatRound(-Limits::infinity())); ASSERT_EQ(LayoutUnit(), LayoutUnit::fromFloatRound(Limits::quiet_NaN())); } ___ Just wanted to raise so we can import these as well. Will run locally to confirm that we don't fail them etc. Thanks!
Attachments
Add attachment
proposed patch, testcase, etc.
Ahmad Saleem
Comment 1
2023-12-31 08:43:47 PST
It fails: Ran 4 tests of 4 with 1 successful ------------------------------ Test suite failed Failed TestWebKitAPI.WebCoreLayoutUnit.FromFloatCeil /Users/ahmadsaleem/Documents/GitHub-Webkit-Ahmad-Fork/Untitled/Tools/TestWebKitAPI/Tests/WebCore/LayoutUnitTests.cpp:287Expected equality of these values: LayoutUnit() Which is: 4-byte object <00-00 00-00> LayoutUnit::fromFloatCeil(Limits::quiet_NaN()) Which is: 4-byte object <00-00 00-80> TestWebKitAPI.WebCoreLayoutUnit.FromFloatFloor /Users/ahmadsaleem/Documents/GitHub-Webkit-Ahmad-Fork/Untitled/Tools/TestWebKitAPI/Tests/WebCore/LayoutUnitTests.cpp:305Expected equality of these values: LayoutUnit() Which is: 4-byte object <00-00 00-00> LayoutUnit::fromFloatFloor(Limits::quiet_NaN()) Which is: 4-byte object <00-00 00-80> TestWebKitAPI.WebCoreLayoutUnit.FromFloatRound /Users/ahmadsaleem/Documents/GitHub-Webkit-Ahmad-Fork/Untitled/Tools/TestWebKitAPI/Tests/WebCore/LayoutUnitTests.cpp:324Expected equality of these values: LayoutUnit() Which is: 4-byte object <00-00 00-00> LayoutUnit::fromFloatRound(Limits::quiet_NaN()) Which is: 4-byte object <00-00 00-80>
Ahmad Saleem
Comment 2
2024-01-04 19:56:30 PST
One which compiles (previous had some errors): TEST(WebCoreLayoutUnit, FromFloatCeil) { const float tolerance = 1.0f / kFixedPointDenominator; ASSERT_EQ(LayoutUnit(1.25f), LayoutUnit::fromFloatCeil(1.25f)); ASSERT_EQ(LayoutUnit(1.25f + tolerance), LayoutUnit::fromFloatCeil(1.25f + tolerance / 2)); ASSERT_EQ(LayoutUnit(), LayoutUnit::fromFloatCeil(-tolerance / 2)); using Limits = std::numeric_limits<float>; // Larger than max() ASSERT_EQ(LayoutUnit::max(), LayoutUnit::fromFloatCeil(Limits::max())); ASSERT_EQ(LayoutUnit::max(), LayoutUnit::fromFloatCeil(Limits::infinity())); // Smaller than Min() ASSERT_EQ(LayoutUnit::min(), LayoutUnit::fromFloatCeil(Limits::lowest())); ASSERT_EQ(LayoutUnit::min(), LayoutUnit::fromFloatCeil(-Limits::infinity())); ASSERT_EQ(LayoutUnit(), LayoutUnit::fromFloatCeil(Limits::quiet_NaN())); } TEST(WebCoreLayoutUnit, FromFloatFloor) { const float tolerance = 1.0f / kFixedPointDenominator; ASSERT_EQ(LayoutUnit(1.25f), LayoutUnit::fromFloatFloor(1.25f)); ASSERT_EQ(LayoutUnit(1.25f), LayoutUnit::fromFloatFloor(1.25f + tolerance / 2)); ASSERT_EQ(LayoutUnit(-tolerance), LayoutUnit::fromFloatFloor(-tolerance / 2)); using Limits = std::numeric_limits<float>; // Larger than max() ASSERT_EQ(LayoutUnit::max(), LayoutUnit::fromFloatFloor(Limits::max())); ASSERT_EQ(LayoutUnit::max(), LayoutUnit::fromFloatFloor(Limits::infinity())); // Smaller than min() ASSERT_EQ(LayoutUnit::min(), LayoutUnit::fromFloatFloor(Limits::lowest())); ASSERT_EQ(LayoutUnit::min(), LayoutUnit::fromFloatFloor(-Limits::infinity())); ASSERT_EQ(LayoutUnit(), LayoutUnit::fromFloatFloor(Limits::quiet_NaN())); } TEST(WebCoreLayoutUnit, FromFloatRound) { const float tolerance = 1.0f / kFixedPointDenominator; ASSERT_EQ(LayoutUnit(1.25f), LayoutUnit::fromFloatRound(1.25f)); ASSERT_EQ(LayoutUnit(1.25f), LayoutUnit::fromFloatRound(1.25f + tolerance / 4)); ASSERT_EQ(LayoutUnit(1.25f + tolerance), LayoutUnit::fromFloatRound(1.25f + tolerance * 3 / 4)); ASSERT_EQ(LayoutUnit(-tolerance), LayoutUnit::fromFloatRound(-tolerance * 3 / 4)); using Limits = std::numeric_limits<float>; // Larger than max() ASSERT_EQ(LayoutUnit::max(), LayoutUnit::fromFloatRound(Limits::max())); ASSERT_EQ(LayoutUnit::max(), LayoutUnit::fromFloatRound(Limits::infinity())); // Smaller than Min() ASSERT_EQ(LayoutUnit::min(), LayoutUnit::fromFloatRound(Limits::lowest())); ASSERT_EQ(LayoutUnit::min(), LayoutUnit::fromFloatRound(-Limits::infinity())); ASSERT_EQ(LayoutUnit(), LayoutUnit::fromFloatRound(Limits::quiet_NaN())); } ___ I think I would remove 'quiet_Nan()' and land this to just have good coverage.
EWS
Comment 3
2024-01-05 14:51:29 PST
Committed
272707@main
(0058f6b04bfb): <
https://commits.webkit.org/272707@main
> Reviewed commits have been landed. Closing PR #22418 and removing active labels.
Radar WebKit Bug Importer
Comment 4
2024-01-05 14:52:18 PST
<
rdar://problem/120561655
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug