[Webkit-unassigned] [Bug 266950] New: Add more `LayoutUnit::fromFloat*` API tests from Blink / Chromium

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Dec 31 07:27:07 PST 2023


https://bugs.webkit.org/show_bug.cgi?id=266950

            Bug ID: 266950
           Summary: Add more `LayoutUnit::fromFloat*` API tests from Blink
                    / Chromium
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Layout and Rendering
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: ahmad.saleem792 at gmail.com
                CC: bfulgham at webkit.org, simon.fraser at apple.com,
                    zalan at apple.com

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!

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20231231/80ac1417/attachment-0001.htm>


More information about the webkit-unassigned mailing list