summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-09-09 13:36:07 +0200
committerEike Rathke <erack@redhat.com>2022-09-09 15:54:11 +0200
commit6afb3232d32f1ebad0cefb94c145922e217526bd (patch)
treefa415f66b7368ebbbccf6c546436d4aa082717bf /sc
parent9a6c350d8dff4b5228ec7451006115e387f819f2 (diff)
tdf#150312 unit test
Change-Id: I140d94b4022dafe4f54b45d3d335c881d967ea56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139725 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/range.cxx32
1 files changed, 28 insertions, 4 deletions
diff --git a/sc/qa/unit/range.cxx b/sc/qa/unit/range.cxx
index 843ecddcb596..46c568414302 100644
--- a/sc/qa/unit/range.cxx
+++ b/sc/qa/unit/range.cxx
@@ -202,10 +202,34 @@ void ScRangeUpdaterTest::testUpdateDeleteTabBeforePos()
void ScRangeUpdaterTest::testUpdateDeleteTabAtPos()
{
ScDocument aDoc;
- ScAddress aAddr(1, 1, 1);
- sc::RefUpdateDeleteTabContext aContext(aDoc, 1, 1);
- ScRangeUpdater::UpdateDeleteTab(aAddr, aContext);
- CPPUNIT_ASSERT_EQUAL(ScAddress(1, 1, 0), aAddr);
+
+ // Position within deleted range is moved to the front.
+ {
+ ScAddress aAddr(1, 1, 1);
+ sc::RefUpdateDeleteTabContext aContext(aDoc, 1, 1);
+ ScRangeUpdater::UpdateDeleteTab(aAddr, aContext);
+ CPPUNIT_ASSERT_EQUAL(ScAddress(1, 1, 0), aAddr);
+ }
+ {
+ ScAddress aAddr(1, 1, 2);
+ sc::RefUpdateDeleteTabContext aContext(aDoc, 1, 2);
+ ScRangeUpdater::UpdateDeleteTab(aAddr, aContext);
+ CPPUNIT_ASSERT_EQUAL(ScAddress(1, 1, 0), aAddr);
+ }
+
+ // Would-be negative results are clamped to 0.
+ {
+ ScAddress aAddr(1, 1, 0);
+ sc::RefUpdateDeleteTabContext aContext(aDoc, 0, 1);
+ ScRangeUpdater::UpdateDeleteTab(aAddr, aContext);
+ CPPUNIT_ASSERT_EQUAL(ScAddress(1, 1, 0), aAddr);
+ }
+ {
+ ScAddress aAddr(1, 1, 1);
+ sc::RefUpdateDeleteTabContext aContext(aDoc, 0, 2);
+ ScRangeUpdater::UpdateDeleteTab(aAddr, aContext);
+ CPPUNIT_ASSERT_EQUAL(ScAddress(1, 1, 0), aAddr);
+ }
}
void ScRangeUpdaterTest::testUpdateDeleteTabAfterPos()