summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-01-23 14:07:25 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-01-23 14:12:58 -0500
commit228cd29a48374833bbe305a434f7149a0ef3ddd1 (patch)
treeeb10ce3c79bd15097d7e576186df45e70e1d369e
parent9ce7ba209d28cd284ab5ea584bc130d7a081b0f9 (diff)
fdo#73986: Write unit test for document statistics.
Change-Id: I8ff51fda91627b365cf71be8849d07b92b447ba9
-rw-r--r--sc/qa/unit/ucalc.cxx21
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 23 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 357f596ce869..111b94019bf9 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -634,6 +634,27 @@ void Test::testInput()
m_pDoc->DeleteTab(0);
}
+void Test::testDocStatistics()
+{
+ SCTAB nStartTabs = m_pDoc->GetTableCount();
+ m_pDoc->InsertTab(0, "Sheet1");
+ CPPUNIT_ASSERT_MESSAGE("Failed to increment sheet count.", m_pDoc->GetTableCount() == nStartTabs+1);
+ m_pDoc->InsertTab(1, "Sheet2");
+ CPPUNIT_ASSERT_MESSAGE("Failed to increment sheet count.", m_pDoc->GetTableCount() == nStartTabs+2);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(0), m_pDoc->GetCellCount());
+ m_pDoc->SetValue(ScAddress(0,0,0), 2.0);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(1), m_pDoc->GetCellCount());
+ m_pDoc->SetValue(ScAddress(2,2,0), 2.5);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(2), m_pDoc->GetCellCount());
+ m_pDoc->SetString(ScAddress(1,1,1), "Test");
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(3), m_pDoc->GetCellCount());
+
+ m_pDoc->DeleteTab(1);
+ CPPUNIT_ASSERT_MESSAGE("Failed to decrement sheet count.", m_pDoc->GetTableCount() == nStartTabs+1);
+ m_pDoc->DeleteTab(0); // This may fail in case there is only one sheet in the document.
+}
+
void Test::testDataEntries()
{
m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 1dbfbbc023c4..f6007ff3150f 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -83,6 +83,7 @@ public:
void testSharedStringPool();
void testRangeList();
void testInput();
+ void testDocStatistics();
/**
* The 'data entries' data is a list of strings used for suggestions as
@@ -314,6 +315,7 @@ public:
CPPUNIT_TEST(testSharedStringPool);
CPPUNIT_TEST(testRangeList);
CPPUNIT_TEST(testInput);
+ CPPUNIT_TEST(testDocStatistics);
CPPUNIT_TEST(testDataEntries);
CPPUNIT_TEST(testSelectionFunction);
CPPUNIT_TEST(testFormulaCreateStringFromTokens);