summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-09-14 12:37:15 -0400
committerKohei Yoshida <kohei.yoshida@suse.com>2011-09-14 12:38:01 -0400
commit27dcdb171686204d9d684d9265a124853c270af2 (patch)
tree58d925e407ab640a3d84fe4546beb6dbc2d5ddfc /sc
parentdd482fde498c71025397f5f5c21ce6c65aa15892 (diff)
New unit test case for testing SHEETS function result.
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 9b355dc7448c..e1c7da2a3f6a 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -244,6 +244,12 @@ public:
void testCollator();
void testInput();
void testCellFunctions();
+
+ /**
+ * Make sure the SHEETS function gets properly updated during sheet
+ * insertion and removal.
+ */
+ void testSheetsFunc();
void testVolatileFunc();
void testFuncParam();
void testNamedRange();
@@ -283,6 +289,7 @@ public:
CPPUNIT_TEST(testCollator);
CPPUNIT_TEST(testInput);
CPPUNIT_TEST(testCellFunctions);
+ CPPUNIT_TEST(testSheetsFunc);
CPPUNIT_TEST(testVolatileFunc);
CPPUNIT_TEST(testFuncParam);
CPPUNIT_TEST(testNamedRange);
@@ -512,6 +519,39 @@ void Test::testCellFunctions()
m_pDoc->DeleteTab(0);
}
+void Test::testSheetsFunc()
+{
+ rtl::OUString aTabName1(RTL_CONSTASCII_USTRINGPARAM("test1"));
+ rtl::OUString aTabName2(RTL_CONSTASCII_USTRINGPARAM("test2"));
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (SC_TAB_APPEND, aTabName1));
+
+ m_pDoc->SetString(0, 0, 0, OUString(RTL_CONSTASCII_USTRINGPARAM("=SHEETS()")));
+ m_pDoc->CalcFormulaTree(false, true);
+ double original;
+ m_pDoc->GetValue(0, 0, 0, original);
+
+ CPPUNIT_ASSERT_MESSAGE("result of SHEETS() should equal the number of sheets, but doesn't.",
+ static_cast<SCTAB>(original) == m_pDoc->GetTableCount());
+
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (SC_TAB_APPEND, aTabName2));
+
+ double modified;
+ m_pDoc->GetValue(0, 0, 0, modified);
+ CPPUNIT_ASSERT_MESSAGE("result of SHEETS() did not get updated after sheet insertion.",
+ modified - original == 1.0);
+
+ SCTAB nTabCount = m_pDoc->GetTableCount();
+ m_pDoc->DeleteTab(--nTabCount);
+
+ m_pDoc->GetValue(0, 0, 0, modified);
+ CPPUNIT_ASSERT_MESSAGE("result of SHEETS() did not get updated after sheet removal.",
+ modified - original == 0.0);
+
+ m_pDoc->DeleteTab(--nTabCount);
+}
+
void Test::testVolatileFunc()
{
rtl::OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("foo"));