Kaydet (Commit) 0ca473cb authored tarafından Markus Mohrhard's avatar Markus Mohrhard

add test for update address code, related tdf#107289

Change-Id: I955cf49fe5fa47fb38d2c8dacf4aadc8e3f7d651
Reviewed-on: https://gerrit.libreoffice.org/39317Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 238de04d
...@@ -590,7 +590,7 @@ public: ...@@ -590,7 +590,7 @@ public:
SC_DLLPUBLIC static long nLastRowHeightExtra; SC_DLLPUBLIC static long nLastRowHeightExtra;
static long nLastColWidthExtra; static long nLastColWidthExtra;
static void Init(); // during start up SC_DLLPUBLIC static void Init(); // during start up
static void InitAddIns(); static void InitAddIns();
static void Clear(); // at the end of the program static void Clear(); // at the end of the program
......
...@@ -9,11 +9,15 @@ ...@@ -9,11 +9,15 @@
#include <sal/config.h> #include <sal/config.h>
#include <test/bootstrapfixture.hxx> #include <test/bootstrapfixture.hxx>
#include <unotools/configmgr.hxx>
#include "helper/qahelper.hxx" #include "helper/qahelper.hxx"
#include "document.hxx" #include "document.hxx"
#include "docsh.hxx" #include "docsh.hxx"
#include "global.hxx"
#include "address.hxx" #include "address.hxx"
#include "rangeutl.hxx"
#include "refupdatecontext.hxx"
class ScAddressTest : public test::BootstrapFixture class ScAddressTest : public test::BootstrapFixture
{ {
...@@ -98,8 +102,90 @@ void ScRangeTest::tearDown() ...@@ -98,8 +102,90 @@ void ScRangeTest::tearDown()
BootstrapFixture::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(ScAddressTest);
CPPUNIT_TEST_SUITE_REGISTRATION(ScRangeTest); CPPUNIT_TEST_SUITE_REGISTRATION(ScRangeTest);
CPPUNIT_TEST_SUITE_REGISTRATION(ScRangeUpdaterTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment