[Webkit-unassigned] [Bug 266855] Add infinity check to FloatQuad::boundingBox

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Dec 26 11:59:46 PST 2023


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

--- Comment #4 from Ahmad Saleem <ahmad.saleem792 at gmail.com> ---
TEST(FloatQuad, BoundingBox)
{
    FloatQuad quad(FloatPoint(2, 3), FloatPoint(5, 7), FloatPoint(11, 13), FloatPoint(17, 19));
    FloatRect rect = quad.boundingBox();
    ASSERT_EQ(rect.x(), 2);
    ASSERT_EQ(rect.y(), 3);
    ASSERT_EQ(rect.width(), 17 - 2);
    ASSERT_EQ(rect.height(), 19 - 3);
}

TEST(FloatQuad, BoundingBoxSaturateInf)
{
    constexpr double inf = std::numeric_limits<double>::infinity();
    FloatQuad quad(FloatPoint(-inf, 3), FloatPoint(5, inf), FloatPoint(11, 13), FloatPoint(17, 19));
    FloatRect rect = quad.boundingBox();
    ASSERT_EQ(rect.x(), std::numeric_limits<int>::min());
    ASSERT_EQ(rect.y(), 3.0f);
    ASSERT_EQ(rect.width(), 17.0f - std::numeric_limits<int>::min());
    ASSERT_EQ(rect.height(), static_cast<float>(std::numeric_limits<int>::max()) - 3.0f);
}

TEST(FloatQuad, BoundingBoxSaturateLarge)
{
    constexpr double large = std::numeric_limits<float>::max() * 4;
    FloatQuad quad(FloatPoint(-large, 3), FloatPoint(5, large), FloatPoint(11, 13), FloatPoint(17, 19));
    FloatRect rect = quad.boundingBox();
    ASSERT_EQ(rect.x(), std::numeric_limits<int>::min());
    ASSERT_EQ(rect.y(), 3.0f);
    ASSERT_EQ(rect.width(), 17.0f - std::numeric_limits<int>::min());
    ASSERT_EQ(rect.height(), static_cast<float>(std::numeric_limits<int>::max()) - 3.0f);
}

-- 
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/20231226/f2390c07/attachment.htm>


More information about the webkit-unassigned mailing list