Kaydet (Commit) 99d35740 authored tarafından Kohei Yoshida's avatar Kohei Yoshida Kaydeden (comit) Kohei Yoshida

tdf#103890: Add unit test for this.

Change-Id: I93a17f90b7e6ff9aa5133401b2630d4b4e0cced5
Reviewed-on: https://gerrit.libreoffice.org/34050Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKohei Yoshida <libreoffice@kohei.us>
üst bf8d4fb6
......@@ -151,6 +151,7 @@ public:
void testFormulaRefUpdateNameCopySheetCheckTab( SCTAB Tab, bool bCheckNames );
void testFormulaRefUpdateNameDelete();
void testFormulaRefUpdateValidity();
void testTokenArrayRefUpdateMove();
void testMultipleOperations();
void testFuncCOLUMN();
void testFuncCOUNT();
......@@ -528,6 +529,7 @@ public:
CPPUNIT_TEST(testFormulaRefUpdateNameCopySheet);
CPPUNIT_TEST(testFormulaRefUpdateNameDelete);
CPPUNIT_TEST(testFormulaRefUpdateValidity);
CPPUNIT_TEST(testTokenArrayRefUpdateMove);
CPPUNIT_TEST(testMultipleOperations);
CPPUNIT_TEST(testFuncCOLUMN);
CPPUNIT_TEST(testFuncCOUNT);
......
......@@ -23,6 +23,7 @@
#include "docfunc.hxx"
#include "paramisc.hxx"
#include "tokenstringcontext.hxx"
#include <refupdatecontext.hxx>
#include "dbdata.hxx"
#include "scmatrix.hxx"
#include <validat.hxx>
......@@ -3330,6 +3331,51 @@ void Test::testFormulaRefUpdateValidity()
m_pDoc->DeleteTab(0);
}
void Test::testTokenArrayRefUpdateMove()
{
m_pDoc->InsertTab(0, "Sheet1");
m_pDoc->InsertTab(1, "Sheet2");
ScAddress aPos(0,0,0); // A1
sc::TokenStringContext aCxt(m_pDoc, m_pDoc->GetGrammar());
// Emulate cell movement from Sheet1.C3 to Sheet2.C3.
sc::RefUpdateContext aRefCxt(*m_pDoc);
aRefCxt.meMode = URM_MOVE;
aRefCxt.maRange = ScAddress(2,2,1); // C3 on Sheet2.
aRefCxt.mnTabDelta = -1;
std::vector<OUString> aTests = {
"B1*C1",
"SUM(B1:C1)"
};
// Since C3 is not referenced in any of the above formulas, moving C3 from
// Sheet1 to Sheet2 should NOT change the displayed formula string at all.
for (const OUString& aTest : aTests)
{
ScCompiler aComp(m_pDoc, aPos);
aComp.SetGrammar(m_pDoc->GetGrammar());
std::unique_ptr<ScTokenArray> pArray(aComp.CompileString(aTest));
OUString aStr = pArray->CreateString(aCxt, aPos);
CPPUNIT_ASSERT_EQUAL(aTest, aStr);
// This formula cell isn't moving its position. The displayed formula
// string should not change.
pArray->AdjustReferenceOnMove(aRefCxt, aPos, aPos);
aStr = pArray->CreateString(aCxt, aPos);
CPPUNIT_ASSERT_EQUAL(aTest, aStr);
}
m_pDoc->DeleteTab(1);
m_pDoc->DeleteTab(0);
}
void Test::testMultipleOperations()
{
m_pDoc->InsertTab(0, "MultiOp");
......
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