sc/qa/unit/range.cxx |   32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

New commits:
commit 6afb3232d32f1ebad0cefb94c145922e217526bd
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Fri Sep 9 13:36:07 2022 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Fri Sep 9 15:54:11 2022 +0200

    tdf#150312 unit test
    
    Change-Id: I140d94b4022dafe4f54b45d3d335c881d967ea56
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139725
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

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()

Reply via email to