summaryrefslogtreecommitdiff
path: root/tools/qa
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-09-17 21:49:21 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-09-20 12:10:44 +0200
commitb22d4785310eac35696df771803dfba0871a50ac (patch)
tree56e394a3c38a2e1f17530fbc18dd8e6b3c5d5098 /tools/qa
parent3e2370260f2b79c43b4f8a86b123861aa95d3ef2 (diff)
clean up ambiguous confusing rectangle APIs like IsInside()
Reading 'rectA.IsInside( rectB )' kind of suggests that the code checks whether 'rectA is inside rectB', but it's actually the other way around. Rename IsInside() -> Contains(), IsOver() -> Overlaps(), which should make it clear which way the logic goes. Change-Id: I9347450fe7dc34c96df6d636a4e3e660de1801ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122271 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Luboš Luňák <l.lunak@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'tools/qa')
-rw-r--r--tools/qa/cppunit/test_rectangle.cxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/qa/cppunit/test_rectangle.cxx b/tools/qa/cppunit/test_rectangle.cxx
index e213ed28daf8..2b6518d797c4 100644
--- a/tools/qa/cppunit/test_rectangle.cxx
+++ b/tools/qa/cppunit/test_rectangle.cxx
@@ -92,6 +92,21 @@ void Test::test_rectangle()
static_assert(aRectMm100.GetWidth() == 0);
static_assert(aRectMm100.GetHeight() == 0);
}
+
+ {
+ constexpr tools::Rectangle rect(Point(0, 0), Size(20, 20));
+ constexpr tools::Rectangle inside(Point(10, 10), Size(10, 10));
+ constexpr tools::Rectangle overlap(Point(10, 10), Size(20, 20));
+ constexpr tools::Rectangle outside(Point(20, 20), Size(10, 10));
+ CPPUNIT_ASSERT(rect.Contains(inside));
+ CPPUNIT_ASSERT(rect.Contains(rect));
+ CPPUNIT_ASSERT(!rect.Contains(overlap));
+ CPPUNIT_ASSERT(!rect.Contains(outside));
+ CPPUNIT_ASSERT(rect.Overlaps(inside));
+ CPPUNIT_ASSERT(rect.Overlaps(rect));
+ CPPUNIT_ASSERT(rect.Overlaps(overlap));
+ CPPUNIT_ASSERT(!rect.Overlaps(outside));
+ }
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);