summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-24 11:35:27 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-07-24 23:29:41 -0400
commit21f9cb6f5f774d918a33f72d981385c619270943 (patch)
treed5c7cba6021d6fe9762e4aa3fabe176a3cab3aee /sc
parent6e02c49c11c52196fe0b92ef80ca724470dcaad2 (diff)
fdo#67206: Add test for broadcaster relocation on column insertion.
Change-Id: I4358d4572df3d3c69012737d299d41ce8af02799
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.cxx52
1 files changed, 44 insertions, 8 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index adecc55d90d0..7d081bc1ee1f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1027,15 +1027,17 @@ void Test::testCellBroadcaster()
// Clear everything again
clearRange(m_pDoc, ScRange(0,0,0,10,100,0));
- // Switch to R1C1 to make it easier to input relative references in multiple cells.
- FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
-
- // Have B1:B20 reference A1:A20.
- val = 0.0;
- for (SCROW i = 0; i < 20; ++i)
{
- m_pDoc->SetValue(ScAddress(0,i,0), val++);
- m_pDoc->SetString(ScAddress(1,i,0), "=RC[-1]");
+ // Switch to R1C1 to make it easier to input relative references in multiple cells.
+ FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
+
+ // Have B1:B20 reference A1:A20.
+ val = 0.0;
+ for (SCROW i = 0; i < 20; ++i)
+ {
+ m_pDoc->SetValue(ScAddress(0,i,0), val++);
+ m_pDoc->SetString(ScAddress(1,i,0), "=RC[-1]");
+ }
}
// Ensure that the formula cells show correct values, and the referenced
@@ -1059,6 +1061,40 @@ void Test::testCellBroadcaster()
CPPUNIT_ASSERT_MESSAGE("Broadcaster should have been deleted.", !pBC);
}
+ // Clear everything again
+ clearRange(m_pDoc, ScRange(0,0,0,10,100,0));
+
+ m_pDoc->SetValue(ScAddress(0,0,0), 2.0);
+ m_pDoc->SetString(ScAddress(1,0,0), "=A1");
+ m_pDoc->SetString(ScAddress(2,0,0), "=B1");
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0,0,0));
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1,0,0));
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(2,0,0));
+
+ pBC = m_pDoc->GetBroadcaster(ScAddress(0,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Broadcaster should exist here.", pBC);
+ pBC = m_pDoc->GetBroadcaster(ScAddress(1,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Broadcaster should exist here.", pBC);
+
+ // Change the value of A1 and make sure everyone follows suit.
+ m_pDoc->SetValue(ScAddress(0,0,0), 3.5);
+ CPPUNIT_ASSERT_EQUAL(3.5, m_pDoc->GetValue(0,0,0));
+ CPPUNIT_ASSERT_EQUAL(3.5, m_pDoc->GetValue(1,0,0));
+ CPPUNIT_ASSERT_EQUAL(3.5, m_pDoc->GetValue(2,0,0));
+
+ // Insert a column at column B.
+ m_pDoc->InsertCol(ScRange(1,0,0,1,MAXROW,0));
+ pBC = m_pDoc->GetBroadcaster(ScAddress(0,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Broadcaster should exist here.", pBC);
+ pBC = m_pDoc->GetBroadcaster(ScAddress(2,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Broadcaster should exist here.", pBC);
+
+ // Change the value of A1 again.
+ m_pDoc->SetValue(ScAddress(0,0,0), 5.5);
+ CPPUNIT_ASSERT_EQUAL(5.5, m_pDoc->GetValue(0,0,0));
+ CPPUNIT_ASSERT_EQUAL(5.5, m_pDoc->GetValue(2,0,0));
+ CPPUNIT_ASSERT_EQUAL(5.5, m_pDoc->GetValue(3,0,0));
+
m_pDoc->DeleteTab(0);
}