summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-11-11 11:26:30 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-11-11 16:17:30 -0500
commitc40cbf189750f623e065b6ed9596d90977a2f631 (patch)
tree6f4b2388b9fbc38fb5305d05c498aa8e534c3a0d /sc/qa
parent7e2677c02997ad7bf38641b46fd1e7ac2c643cd2 (diff)
Add test for importing some of those functions new in Excel 2010.
Change-Id: Ic3577b3ef0edcfa417ae0065499171bf770c2a32
Diffstat (limited to 'sc/qa')
-rwxr-xr-xsc/qa/unit/data/xlsx/functions-excel-2010.xlsxbin0 -> 11548 bytes
-rw-r--r--sc/qa/unit/helper/qahelper.cxx9
-rw-r--r--sc/qa/unit/helper/qahelper.hxx6
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx23
4 files changed, 38 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/functions-excel-2010.xlsx b/sc/qa/unit/data/xlsx/functions-excel-2010.xlsx
new file mode 100755
index 000000000000..03e570e56173
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/functions-excel-2010.xlsx
Binary files differ
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 905abefc2ba3..23b45c8f89e5 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -430,6 +430,15 @@ bool checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected
return true;
}
+bool isFormulaWithoutError(ScDocument& rDoc, const ScAddress& rPos)
+{
+ ScFormulaCell* pFC = rDoc.GetFormulaCell(rPos);
+ if (!pFC)
+ return false;
+
+ return pFC->GetErrCode() == 0;
+}
+
OUString toString(
ScDocument& rDoc, const ScAddress& rPos, ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram)
{
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index a6d5a025e898..657f66b033e9 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -121,6 +121,12 @@ SCQAHELPER_DLLPUBLIC ScRangeList getChartRanges(ScDocument& rDoc, const SdrOle2O
SCQAHELPER_DLLPUBLIC bool checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected);
/**
+ * Check if the cell at specified position is a formula cell that doesn't
+ * have an error value.
+ */
+SCQAHELPER_DLLPUBLIC bool isFormulaWithoutError(ScDocument& rDoc, const ScAddress& rPos);
+
+/**
* Convert formula token array to a formula string.
*/
SCQAHELPER_DLLPUBLIC OUString toString(
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 4f7d70214840..b2dc2b6d762c 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -87,6 +87,7 @@ public:
void testRangeNameXLSX();
void testHardRecalcODS();
void testFunctionsODS();
+ void testFunctionsExcel2010();
void testCachedFormulaResultsODS();
void testCachedMatrixFormulaResultsODS();
void testDatabaseRangesODS();
@@ -155,6 +156,7 @@ public:
CPPUNIT_TEST(testRangeNameXLSX);
CPPUNIT_TEST(testHardRecalcODS);
CPPUNIT_TEST(testFunctionsODS);
+ CPPUNIT_TEST(testFunctionsExcel2010);
CPPUNIT_TEST(testCachedFormulaResultsODS);
CPPUNIT_TEST(testCachedMatrixFormulaResultsODS);
CPPUNIT_TEST(testDatabaseRangesODS);
@@ -371,6 +373,27 @@ void ScFiltersTest::testFunctionsODS()
xDocSh->DoClose();
}
+void ScFiltersTest::testFunctionsExcel2010()
+{
+ ScDocShellRef xDocSh = loadDoc("functions-excel-2010.", XLSX);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load the document.", xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
+ pDoc->CalcAll(); // perform hard re-calculation.
+
+ // B2:B6 and B8 should all be formula cells, and shouldn't have errors.
+ CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,1,0)));
+ CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,2,0)));
+ CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,3,0)));
+ CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,4,0)));
+#if 0 // CHISQ.TEST and F.DIST.RT are not yet supported in the core.
+ CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,5,0)));
+ // Skip B7.
+ CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,7,0)));
+#endif
+
+ xDocSh->DoClose();
+}
+
void ScFiltersTest::testCachedFormulaResultsODS()
{
{