[Libreoffice-commits] core.git: sc/inc sc/qa

Markus Mohrhard markus.mohrhard at googlemail.com
Thu Jul 27 17:52:13 UTC 2017


 sc/inc/global.hxx    |    2 -
 sc/qa/unit/range.cxx |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+), 1 deletion(-)

New commits:
commit 0ca473cbc5f3299ff0cbfa328f6b04544954fd3d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jun 27 01:46:46 2017 +0200

    add test for update address code, related tdf#107289
    
    Change-Id: I955cf49fe5fa47fb38d2c8dacf4aadc8e3f7d651
    Reviewed-on: https://gerrit.libreoffice.org/39317
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 97cd14bba08f..3a3b879f47aa 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -590,7 +590,7 @@ public:
     SC_DLLPUBLIC static long                nLastRowHeightExtra;
     static long             nLastColWidthExtra;
 
-    static void             Init();                     // during start up
+    SC_DLLPUBLIC static void Init();                     // during start up
     static void             InitAddIns();
     static void             Clear();                    // at the end of the program
 
diff --git a/sc/qa/unit/range.cxx b/sc/qa/unit/range.cxx
index 802175823a10..a84a936afb02 100644
--- a/sc/qa/unit/range.cxx
+++ b/sc/qa/unit/range.cxx
@@ -9,11 +9,15 @@
 
 #include <sal/config.h>
 #include <test/bootstrapfixture.hxx>
+#include <unotools/configmgr.hxx>
 #include "helper/qahelper.hxx"
 #include "document.hxx"
 #include "docsh.hxx"
+#include "global.hxx"
 
 #include "address.hxx"
+#include "rangeutl.hxx"
+#include "refupdatecontext.hxx"
 
 class ScAddressTest : public test::BootstrapFixture
 {
@@ -98,8 +102,90 @@ void ScRangeTest::tearDown()
     BootstrapFixture::tearDown();
 }
 
+class ScRangeUpdaterTest : public CppUnit::TestFixture
+{
+public:
+
+    virtual void setUp() override
+    {
+        utl::ConfigManager::EnableAvoidConfig();
+        ScDLL::Init();
+        ScGlobal::Init();
+    }
+    void testUpdateInsertTabBeforePos();
+    void testUpdateInsertTabAtPos();
+    void testUpdateInsertTabAfterPos();
+    void testUpdateDeleteTabBeforePos();
+    void testUpdateDeleteTabAtPos();
+    void testUpdateDeleteTabAfterPos();
+
+    CPPUNIT_TEST_SUITE(ScRangeUpdaterTest);
+    CPPUNIT_TEST(testUpdateInsertTabBeforePos);
+    CPPUNIT_TEST(testUpdateInsertTabAtPos);
+    CPPUNIT_TEST(testUpdateInsertTabAfterPos);
+    CPPUNIT_TEST(testUpdateDeleteTabBeforePos);
+    CPPUNIT_TEST(testUpdateDeleteTabAtPos);
+    CPPUNIT_TEST(testUpdateDeleteTabAfterPos);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void ScRangeUpdaterTest::testUpdateInsertTabBeforePos()
+{
+    ScDocument aDoc;
+    ScAddress aAddr(1, 1, 1);
+    sc::RefUpdateInsertTabContext aContext(aDoc, 0, 1);
+    ScRangeUpdater::UpdateInsertTab(aAddr, aContext);
+    CPPUNIT_ASSERT_EQUAL(ScAddress(1, 1, 2), aAddr);
+}
+
+void ScRangeUpdaterTest::testUpdateInsertTabAtPos()
+{
+    ScDocument aDoc;
+    ScAddress aAddr(1, 1, 1);
+    sc::RefUpdateInsertTabContext aContext(aDoc, 1, 1);
+    ScRangeUpdater::UpdateInsertTab(aAddr, aContext);
+    CPPUNIT_ASSERT_EQUAL(ScAddress(1, 1, 2), aAddr);
+}
+
+void ScRangeUpdaterTest::testUpdateInsertTabAfterPos()
+{
+    ScDocument aDoc;
+    ScAddress aAddr(1, 1, 1);
+    sc::RefUpdateInsertTabContext aContext(aDoc, 2, 1);
+    ScRangeUpdater::UpdateInsertTab(aAddr, aContext);
+    CPPUNIT_ASSERT_EQUAL(ScAddress(1, 1, 1), aAddr);
+}
+
+void ScRangeUpdaterTest::testUpdateDeleteTabBeforePos()
+{
+    ScDocument aDoc;
+    ScAddress aAddr(1, 1, 1);
+    sc::RefUpdateDeleteTabContext aContext(aDoc, 0, 1);
+    ScRangeUpdater::UpdateDeleteTab(aAddr, aContext);
+    CPPUNIT_ASSERT_EQUAL(ScAddress(1, 1, 0), aAddr);
+}
+
+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);
+}
+
+void ScRangeUpdaterTest::testUpdateDeleteTabAfterPos()
+{
+    ScDocument aDoc;
+    ScAddress aAddr(1, 1, 1);
+    sc::RefUpdateDeleteTabContext aContext(aDoc, 2, 1);
+    ScRangeUpdater::UpdateDeleteTab(aAddr, aContext);
+    CPPUNIT_ASSERT_EQUAL(ScAddress(1, 1, 1), aAddr);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScAddressTest);
 CPPUNIT_TEST_SUITE_REGISTRATION(ScRangeTest);
+CPPUNIT_TEST_SUITE_REGISTRATION(ScRangeUpdaterTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
 


More information about the Libreoffice-commits mailing list