From 2f75a279ccff70aa276e16e8c709c8b4b2924103 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 4 Nov 2013 13:57:34 -0500 Subject: Two new test cases for importing data tables from XLSX. Change-Id: I87da806612ae50fe1d64b851c5180ff1792752cb --- sc/qa/unit/data/xlsx/data-table/multi-table.xlsx | Bin 0 -> 9578 bytes sc/qa/unit/data/xlsx/data-table/one-variable.xlsx | Bin 0 -> 9018 bytes sc/qa/unit/subsequent_filters-test.cxx | 87 ++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 sc/qa/unit/data/xlsx/data-table/multi-table.xlsx create mode 100644 sc/qa/unit/data/xlsx/data-table/one-variable.xlsx diff --git a/sc/qa/unit/data/xlsx/data-table/multi-table.xlsx b/sc/qa/unit/data/xlsx/data-table/multi-table.xlsx new file mode 100644 index 000000000000..c2bf48878b7c Binary files /dev/null and b/sc/qa/unit/data/xlsx/data-table/multi-table.xlsx differ diff --git a/sc/qa/unit/data/xlsx/data-table/one-variable.xlsx b/sc/qa/unit/data/xlsx/data-table/one-variable.xlsx new file mode 100644 index 000000000000..7ff098b228e1 Binary files /dev/null and b/sc/qa/unit/data/xlsx/data-table/one-variable.xlsx differ 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."); -- cgit v1.2.3