Kaydet (Commit) cdc9c6d5 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Add starter test for reference update on range move.

This currently fails.

Change-Id: I83cdcb6ed9620079664ff35375a0457b0c9bcea0
üst cc6e83d5
...@@ -89,6 +89,7 @@ public: ...@@ -89,6 +89,7 @@ public:
void testFormulaRefUpdate(); void testFormulaRefUpdate();
void testFormulaRefUpdateRange(); void testFormulaRefUpdateRange();
void testFormulaRefUpdateSheets(); void testFormulaRefUpdateSheets();
void testFormulaRefUpdateMove();
void testFuncCOLUMN(); void testFuncCOLUMN();
void testFuncROW(); void testFuncROW();
void testFuncSUM(); void testFuncSUM();
...@@ -280,6 +281,7 @@ public: ...@@ -280,6 +281,7 @@ public:
CPPUNIT_TEST(testFormulaRefUpdate); CPPUNIT_TEST(testFormulaRefUpdate);
CPPUNIT_TEST(testFormulaRefUpdateRange); CPPUNIT_TEST(testFormulaRefUpdateRange);
CPPUNIT_TEST(testFormulaRefUpdateSheets); CPPUNIT_TEST(testFormulaRefUpdateSheets);
CPPUNIT_TEST(testFormulaRefUpdateMove);
CPPUNIT_TEST(testFuncCOLUMN); CPPUNIT_TEST(testFuncCOLUMN);
CPPUNIT_TEST(testFuncROW); CPPUNIT_TEST(testFuncROW);
CPPUNIT_TEST(testFuncSUM); CPPUNIT_TEST(testFuncSUM);
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "formulacell.hxx" #include "formulacell.hxx"
#include "inputopt.hxx" #include "inputopt.hxx"
#include "scmod.hxx" #include "scmod.hxx"
#include "docsh.hxx"
#include "docfunc.hxx"
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
...@@ -837,6 +839,54 @@ void Test::testFormulaRefUpdateSheets() ...@@ -837,6 +839,54 @@ void Test::testFormulaRefUpdateSheets()
m_pDoc->DeleteTab(0); m_pDoc->DeleteTab(0);
} }
void Test::testFormulaRefUpdateMove()
{
m_pDoc->InsertTab(0, "Sheet1");
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
// Set value to B4:B6.
m_pDoc->SetValue(ScAddress(1,3,0), 1);
m_pDoc->SetValue(ScAddress(1,4,0), 2);
m_pDoc->SetValue(ScAddress(1,5,0), 3);
// Set formulas to A9:A12 that references B4:B6.
m_pDoc->SetString(ScAddress(0,8,0), "=SUM(B4:B6)");
m_pDoc->SetString(ScAddress(0,9,0), "=SUM($B$4:$B$6)");
m_pDoc->SetString(ScAddress(0,10,0), "=B5");
m_pDoc->SetString(ScAddress(0,11,0), "=$B$6");
CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(0,8,0));
CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(0,9,0));
CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0,10,0));
CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(0,11,0));
// Move B4:B6 to D4 (two columsn to the right).
ScDocFunc& rFunc = getDocShell().GetDocFunc();
bool bMoved = rFunc.MoveBlock(ScRange(1,3,0,1,5,0), ScAddress(3,3,0), true, false, false, false);
CPPUNIT_ASSERT_MESSAGE("Failed to move B4:B6.", bMoved);
// The results of the formula cells that reference the moved range should remain the same.
CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(0,8,0));
CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(0,9,0));
CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0,10,0));
CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(0,11,0));
if (!checkFormula(*m_pDoc, ScAddress(0,8,0), "SUM(D4:D6)"))
CPPUNIT_FAIL("Wrong formula.");
if (!checkFormula(*m_pDoc, ScAddress(0,9,0), "SUM($D$4:$D$6)"))
CPPUNIT_FAIL("Wrong formula.");
if (!checkFormula(*m_pDoc, ScAddress(0,10,0), "D5"))
CPPUNIT_FAIL("Wrong formula.");
if (!checkFormula(*m_pDoc, ScAddress(0,11,0), "$D$6"))
CPPUNIT_FAIL("Wrong formula.");
m_pDoc->DeleteTab(0);
}
void Test::testFuncCOLUMN() void Test::testFuncCOLUMN()
{ {
m_pDoc->InsertTab(0, "Formula"); m_pDoc->InsertTab(0, "Formula");
......
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