Kaydet (Commit) a7580593 authored tarafından Eike Rathke's avatar Eike Rathke Kaydeden (comit) Andras Timar

unit test for adjustSingleRefInName() during column insertion

Change-Id: Ie406361c3a3497619f4faf3680f389f3bdf76a4b
(cherry picked from commit 8ade7dce)
üst d7315b52
......@@ -1704,6 +1704,11 @@ void Test::testFormulaRefUpdateInsertColumns()
m_pDoc->InsertTab(0, "Formula");
// Set named range for B2 with absolute column and relative same row.
const ScAddress aNamePos(0,1,0);
bool bInserted = m_pDoc->InsertNewRangeName("RowRelativeRange", aNamePos, "$Formula.$B2");
CPPUNIT_ASSERT(bInserted);
// Set values in B1:B3.
m_pDoc->SetValue(ScAddress(1,0,0), 1.0);
m_pDoc->SetValue(ScAddress(1,1,0), 2.0);
......@@ -1713,6 +1718,10 @@ void Test::testFormulaRefUpdateInsertColumns()
m_pDoc->SetString(ScAddress(1,3,0), "=SUM(B1:B3)");
CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,3,0)));
// Use named range in C2 to reference B2.
m_pDoc->SetString(ScAddress(2,1,0), "=RowRelativeRange");
CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(2,1,0)));
// Inert columns over A:B.
ScMarkData aMark;
aMark.SelectOneTable(0);
......@@ -1725,6 +1734,18 @@ void Test::testFormulaRefUpdateInsertColumns()
CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(3,3,0)));
// Check that the named reference points to the moved cell, now D2.
ScRangeData* pName = m_pDoc->GetRangeName()->findByUpperName("ROWRELATIVERANGE");
CPPUNIT_ASSERT(pName);
OUString aSymbol;
pName->GetSymbol(aSymbol, aNamePos, formula::FormulaGrammar::GRAM_ENGLISH);
CPPUNIT_ASSERT_EQUAL(OUString("$Formula.$D2"), aSymbol);
// Check that the formula using the name, now in E2, still has the same result.
if (!checkFormula(*m_pDoc, ScAddress(4,1,0), "RowRelativeRange"))
CPPUNIT_FAIL("Wrong formula in E2 after column insertion.");
CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(4,1,0)));
m_pDoc->DeleteTab(0);
}
......
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