commit bb807f8739cf89969f3d9a0e042935b853a95f16
parent 377cce1674e539f73fc3af5db471f5e3e017b248
Author: Brad Werth <werth@efn.org>
Date: Tue, 16 Dec 2025 14:52:45 +0000
Bug 2002894 - Part 2: Add unit tests for large rect containment. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D275522
Diffstat:
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/gfx/tests/gtest/TestRect.cpp b/gfx/tests/gtest/TestRect.cpp
@@ -131,7 +131,7 @@ static bool TestEqualityOperator() {
return true;
}
-template <class RectType>
+template <class RectType, class UnitType>
static bool TestContainment() {
RectType rect1(10, 10, 50, 50);
@@ -186,6 +186,12 @@ static bool TestContainment() {
<< "[8] Test against a rect whose bottom edge (only) is outside of rect1";
rect2.MoveByY(-1);
+ // Test rects approaching numeric limits can contain rects
+ RectType rectLarge(10, 10, std::numeric_limits<UnitType>::max(),
+ std::numeric_limits<UnitType>::max());
+ EXPECT_TRUE(rectLarge.Contains(rect2))
+ << "[9] Test rect at numeric limits against a smaller rect";
+
return true;
}
@@ -605,7 +611,7 @@ TEST(Gfx, nsRect)
{
TestConstructors<nsRect>();
TestEqualityOperator<nsRect>();
- TestContainment<nsRect>();
+ TestContainment<nsRect, nscoord>();
TestIntersects<nsRect>();
TestIntersection<nsRect>();
TestUnion<nsRect>();
@@ -619,7 +625,7 @@ TEST(Gfx, nsIntRect)
{
TestConstructors<nsIntRect>();
TestEqualityOperator<nsIntRect>();
- TestContainment<nsIntRect>();
+ TestContainment<nsIntRect, int32_t>();
TestIntersects<nsIntRect>();
TestIntersection<nsIntRect>();
TestUnion<nsIntRect>();
@@ -633,7 +639,7 @@ TEST(Gfx, gfxRect)
{
TestConstructors<gfxRect>();
// Skip TestEqualityOperator<gfxRect>(); as gfxRect::operator== is private
- TestContainment<gfxRect>();
+ TestContainment<gfxRect, double>();
TestIntersects<gfxRect>();
TestIntersection<gfxRect>();
TestUnion<gfxRect>();