summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-05-14 14:20:08 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-05-20 20:13:05 -0400
commit81e1e8e21f84a27e117eeb7fed06b2686bf60249 (patch)
treeec6a6d940f8c08e0e1caeb42780e1b69c4f49635 /sc/qa
parent1d3d107a764ebfab38c50fda04e79f36763b2b12 (diff)
Unit test for range deletion of broadcasters.
Change-Id: I615c9f9e95a44149c8079754e9aa6497f34c76cf
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/ucalc.cxx36
1 files changed, 30 insertions, 6 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 3e881c9b7ba5..d05190804715 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1776,13 +1776,37 @@ void Test::testCellBroadcaster()
// Clear everything again
clearRange(m_pDoc, ScRange(0,0,0,10,100,0));
- m_pDoc->SetString(ScAddress(1,0,0), "=A1"); // B1 references A1.
- m_pDoc->SetValue(ScAddress(0,0,0), 12.3);
- CPPUNIT_ASSERT_EQUAL(12.3, m_pDoc->GetValue(ScAddress(1,0,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]");
+ }
- // Clear the entire column A.
- clearRange(m_pDoc, ScRange(0,0,0,0,MAXROW,0));
- CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+ // Ensure that the formula cells show correct values, and the referenced
+ // cells have broadcasters.
+ val = 0.0;
+ for (SCROW i = 0; i < 20; ++i)
+ {
+ CPPUNIT_ASSERT_EQUAL(val++, m_pDoc->GetValue(ScAddress(1,i,0)));
+ pBC = m_pDoc->GetBroadcaster(ScAddress(0,i,0));
+ CPPUNIT_ASSERT_MESSAGE("Broadcast should exist here.", pBC);
+ }
+
+ // Delete formula cells in B2:B19.
+ clearRange(m_pDoc, ScRange(1,1,0,1,18,0));
+ // Ensure that A2:A19 no longer have broadcasters, but A1 and A20 still do.
+ CPPUNIT_ASSERT_MESSAGE("A1 should still have broadcaster.", m_pDoc->GetBroadcaster(ScAddress(0,0,0)));
+ CPPUNIT_ASSERT_MESSAGE("A20 should still have broadcaster.", m_pDoc->GetBroadcaster(ScAddress(0,19,0)));
+ for (SCROW i = 1; i <= 18; ++i)
+ {
+ pBC = m_pDoc->GetBroadcaster(ScAddress(0,i,0));
+ CPPUNIT_ASSERT_MESSAGE("Broadcaster should have been deleted.", !pBC);
+ }
m_pDoc->DeleteTab(0);
}