summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-12-06 01:28:38 +0100
committerLuboš Luňák <l.lunak@collabora.com>2021-12-06 12:21:31 +0100
commit8b0287ae7275681c28cc278ecdb448d80c223d89 (patch)
tree6060fe3ab460ae35cc917c1d132d05f15ea3ced4 /sc/qa
parent9809441f05e4dbac8e12b042fd4391f1a7580643 (diff)
slightly simpler Intersects() check
For two ranges to intersect, both start points must not be larger than the end points. Change-Id: I69d1c548ff1bac90baea0767e92ca86458808c9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126393 Tested-by: Luboš Luňák <l.lunak@collabora.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/range.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/sc/qa/unit/range.cxx b/sc/qa/unit/range.cxx
index 4935165bd7cc..d704eb2dc4e2 100644
--- a/sc/qa/unit/range.cxx
+++ b/sc/qa/unit/range.cxx
@@ -69,15 +69,36 @@ public:
virtual void tearDown() override;
CPPUNIT_TEST_SUITE(ScRangeTest);
+ CPPUNIT_TEST(testOverlap);
CPPUNIT_TEST(testRangeParsing);
CPPUNIT_TEST_SUITE_END();
+ void testOverlap();
void testRangeParsing();
private:
ScDocShellRef m_xDocShRef;
};
+void ScRangeTest::testOverlap()
+{
+ ScRange aRange1( ScAddress( 0, 0, 0 ), ScAddress( 1, 1, 1 ));
+ CPPUNIT_ASSERT(aRange1.Contains( ScAddress( 0, 0, 0 )));
+ CPPUNIT_ASSERT(aRange1.Contains( ScAddress( 1, 1, 1 )));
+ CPPUNIT_ASSERT(!aRange1.Contains( ScAddress( 2, 1, 1 )));
+ CPPUNIT_ASSERT(!aRange1.Contains( ScAddress( 1, 2, 1 )));
+ CPPUNIT_ASSERT(!aRange1.Contains( ScAddress( 1, 1, 2 )));
+
+ ScRange aRange2( ScAddress( 0, 0, 0 ), ScAddress( 10, 10, 10 ));
+ ScRange aRange3( ScAddress( 5, 5, 5 ), ScAddress( 15, 15, 15 ));
+ CPPUNIT_ASSERT(!aRange2.Contains( aRange3 ));
+ CPPUNIT_ASSERT(!aRange3.Contains( aRange2 ));
+ CPPUNIT_ASSERT(aRange2.Intersects( aRange3 ));
+ CPPUNIT_ASSERT(aRange3.Intersects( aRange2 ));
+ CPPUNIT_ASSERT(!aRange3.Intersects( aRange1 ));
+ CPPUNIT_ASSERT(!aRange1.Intersects( aRange3 ));
+}
+
void ScRangeTest::testRangeParsing()
{
ScRange aRange;