summaryrefslogtreecommitdiff
path: root/sc/qa/unit/subsequent_filters-test.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-11-04 13:57:34 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-11-04 13:59:55 -0500
commit2f75a279ccff70aa276e16e8c709c8b4b2924103 (patch)
tree17f7af581e30e4b6f9553387a038d34eb39398ad /sc/qa/unit/subsequent_filters-test.cxx
parente77379bb2c0a6b3869b544b30d8f42137f82cf8b (diff)
Two new test cases for importing data tables from XLSX.
Change-Id: I87da806612ae50fe1d64b851c5180ff1792752cb
Diffstat (limited to 'sc/qa/unit/subsequent_filters-test.cxx')
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx87
1 files changed, 87 insertions, 0 deletions
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 3eae17d9e285..4f7d70214840 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -109,6 +109,8 @@ public:
void testRepeatedColumnsODS();
void testDataValidityODS();
void testDataTableMortgageXLS();
+ void testDataTableOneVarXLSX();
+ void testDataTableMultiTableXLSX();
void testDataBarODS();
void testDataBarXLSX();
@@ -174,6 +176,8 @@ public:
CPPUNIT_TEST(testRepeatedColumnsODS);
CPPUNIT_TEST(testDataValidityODS);
CPPUNIT_TEST(testDataTableMortgageXLS);
+ CPPUNIT_TEST(testDataTableOneVarXLSX);
+ CPPUNIT_TEST(testDataTableMultiTableXLSX);
CPPUNIT_TEST(testBrokenQuotesCSV);
CPPUNIT_TEST(testCellValueXLSX);
CPPUNIT_TEST(testControlImport);
@@ -1077,6 +1081,8 @@ void ScFiltersTest::testDataValidityODS()
void ScFiltersTest::testDataTableMortgageXLS()
{
ScDocShellRef xDocSh = loadDoc("data-table/mortgage.", XLS);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load the document.", xDocSh.Is());
+
ScFormulaOptions aOptions;
aOptions.SetFormulaSepArg(",");
aOptions.SetFormulaSepArrayCol(",");
@@ -1125,6 +1131,87 @@ void ScFiltersTest::testDataTableMortgageXLS()
xDocSh->DoClose();
}
+void ScFiltersTest::testDataTableOneVarXLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("data-table/one-variable.", XLSX);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load the document.", xDocSh.Is());
+
+ ScFormulaOptions aOptions;
+ aOptions.SetFormulaSepArg(",");
+ aOptions.SetFormulaSepArrayCol(",");
+ aOptions.SetFormulaSepArrayRow(";");
+ xDocSh->SetFormulaOptions(aOptions);
+
+ ScDocument* pDoc = xDocSh->GetDocument();
+
+ // Right now, we have a bug that prevents Calc from re-calculating these
+ // cells automatically upon file load. We can remove this call if/when we
+ // fix the aforementioned bug.
+ pDoc->CalcAll();
+
+ // B5:B11 should have multiple operations formula cells. Just check the
+ // top and bottom cells.
+
+ if (!checkFormula(*pDoc, ScAddress(1,4,0), "MULTIPLE.OPERATIONS(B$4,$A$2,$A5)"))
+ CPPUNIT_FAIL("Wrong formula!");
+
+ CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(ScAddress(1,4,0)));
+
+ if (!checkFormula(*pDoc, ScAddress(1,10,0), "MULTIPLE.OPERATIONS(B$4,$A$2,$A11)"))
+ CPPUNIT_FAIL("Wrong formula!");
+
+ CPPUNIT_ASSERT_EQUAL(14.0, pDoc->GetValue(ScAddress(1,10,0)));
+
+ // Likewise, E5:I5 should have multiple operations formula cells. Just
+ // check the left- and right-most cells.
+
+ if (!checkFormula(*pDoc, ScAddress(4,4,0), "MULTIPLE.OPERATIONS($D5,$B$2,E$4)"))
+ CPPUNIT_FAIL("Wrong formula!");
+
+ CPPUNIT_ASSERT_EQUAL(10.0, pDoc->GetValue(ScAddress(4,4,0)));
+
+ if (!checkFormula(*pDoc, ScAddress(8,4,0), "MULTIPLE.OPERATIONS($D5,$B$2,I$4)"))
+ CPPUNIT_FAIL("Wrong formula!");
+
+ CPPUNIT_ASSERT_EQUAL(50.0, pDoc->GetValue(ScAddress(8,4,0)));
+
+ xDocSh->DoClose();
+}
+
+void ScFiltersTest::testDataTableMultiTableXLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("data-table/multi-table.", XLSX);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load the document.", xDocSh.Is());
+
+ ScFormulaOptions aOptions;
+ aOptions.SetFormulaSepArg(",");
+ aOptions.SetFormulaSepArrayCol(",");
+ aOptions.SetFormulaSepArrayRow(";");
+ xDocSh->SetFormulaOptions(aOptions);
+
+ ScDocument* pDoc = xDocSh->GetDocument();
+
+ // Right now, we have a bug that prevents Calc from re-calculating these
+ // cells automatically upon file load. We can remove this call if/when we
+ // fix the aforementioned bug.
+ pDoc->CalcAll();
+
+ // B4:M15 should have multiple operations formula cells. We'll just check
+ // the top-left and bottom-right ones.
+
+ if (!checkFormula(*pDoc, ScAddress(1,3,0), "MULTIPLE.OPERATIONS($A$3,$E$1,$A4,$D$1,B$3)"))
+ CPPUNIT_FAIL("Wrong formula!");
+
+ CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(1,3,0)));
+
+ if (!checkFormula(*pDoc, ScAddress(12,14,0), "MULTIPLE.OPERATIONS($A$3,$E$1,$A15,$D$1,M$3)"))
+ CPPUNIT_FAIL("Wrong formula!");
+
+ CPPUNIT_ASSERT_EQUAL(144.0, pDoc->GetValue(ScAddress(12,14,0)));
+
+ xDocSh->DoClose();
+}
+
void ScFiltersTest::testBrokenQuotesCSV()
{
const OUString aFileNameBase("fdo48621_broken_quotes.");