Unit test for range deletion of broadcasters.

Change-Id: I615c9f9e95a44149c8079754e9aa6497f34c76cf
This commit is contained in:
Kohei Yoshida 2013-05-14 14:20:08 -04:00
parent 1d3d107a76
commit 81e1e8e21f
2 changed files with 31 additions and 6 deletions

View file

@ -39,6 +39,7 @@
#ifdef NDEBUG #ifdef NDEBUG
#undef NDEBUG #undef NDEBUG
#endif #endif
#define MDDS_MULTI_TYPE_VECTOR_DEBUG 1
#endif #endif
#include <mdds/multi_type_vector.hpp> #include <mdds/multi_type_vector.hpp>

View file

@ -1776,13 +1776,37 @@ void Test::testCellBroadcaster()
// Clear everything again // Clear everything again
clearRange(m_pDoc, ScRange(0,0,0,10,100,0)); clearRange(m_pDoc, ScRange(0,0,0,10,100,0));
m_pDoc->SetString(ScAddress(1,0,0), "=A1"); // B1 references A1. // Switch to R1C1 to make it easier to input relative references in multiple cells.
m_pDoc->SetValue(ScAddress(0,0,0), 12.3); FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
CPPUNIT_ASSERT_EQUAL(12.3, m_pDoc->GetValue(ScAddress(1,0,0)));
// Clear the entire column A. // Have B1:B20 reference A1:A20.
clearRange(m_pDoc, ScRange(0,0,0,0,MAXROW,0)); val = 0.0;
CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,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
// 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); m_pDoc->DeleteTab(0);
} }