diff options
author | Eike Rathke <erack@redhat.com> | 2015-07-27 15:43:22 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-07-27 15:56:27 +0200 |
commit | 1abc8c1608eca18d5b4a010d8a43fbbe87a6b933 (patch) | |
tree | e6af6162c8575a6a104bc6648ceb98e9ecdc0198 | |
parent | dcec162ea083b3604ff82c4dc3ca43d2b5054ea7 (diff) |
unit test for FORMULA() with and without array context
Change-Id: Ic8e0f5dfad6e9b9a70e6dca89a970c131efc53d9
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 41 |
2 files changed, 43 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 4a3e462093a8..3b24c8537dec 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -181,6 +181,7 @@ public: void testFuncGETPIVOTDATALeafAccess(); void testMatrixOp(); void testFuncRangeOp(); + void testFuncFORMULA(); void testExternalRef(); void testExternalRefFunctions(); @@ -508,6 +509,7 @@ public: CPPUNIT_TEST(testFuncGETPIVOTDATALeafAccess); CPPUNIT_TEST(testMatrixOp); CPPUNIT_TEST(testFuncRangeOp); + CPPUNIT_TEST(testFuncFORMULA); CPPUNIT_TEST(testExternalRef); CPPUNIT_TEST(testExternalRefFunctions); CPPUNIT_TEST(testCopyToDocument); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index b7c4fd76cb9b..b6a6933dd047 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -5325,4 +5325,45 @@ void Test::testFuncRangeOp() m_pDoc->DeleteTab(0); } +void Test::testFuncFORMULA() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc. + + m_pDoc->InsertTab(0, "Sheet1"); + + // Data in B1:D3 + const char* aData[][3] = { + { "=A1", "=FORMULA(B1)", "=FORMULA(B1:B3)" }, + { 0, "=FORMULA(B2)", "=FORMULA(B1:B3)" }, + { "=A3", "=FORMULA(B3)", "=FORMULA(B1:B3)" }, + }; + + ScAddress aPos(1,0,0); + ScRange aRange = insertRangeData(m_pDoc, aPos, aData, SAL_N_ELEMENTS(aData)); + CPPUNIT_ASSERT(aRange.aStart == aPos); + + // Checks of C1:D3, where Cy==Dy, and D4:D6 + const char* aChecks[] = { + "=A1", + "#N/A", + "=A3", + }; + for (size_t i=0; i < SAL_N_ELEMENTS(aChecks); ++i) + { + CPPUNIT_ASSERT_EQUAL( OUString::createFromAscii( aChecks[i]), m_pDoc->GetString(2,i,0)); + CPPUNIT_ASSERT_EQUAL( OUString::createFromAscii( aChecks[i]), m_pDoc->GetString(3,i,0)); + } + + // Matrix in D4:D6, no intersection with B1:B3 + ScMarkData aMark; + aMark.SelectOneTable(0); + m_pDoc->InsertMatrixFormula(3, 3, 3, 5, aMark, "=FORMULA(B1:B3)"); + for (size_t i=0; i < SAL_N_ELEMENTS(aChecks); ++i) + { + CPPUNIT_ASSERT_EQUAL( OUString::createFromAscii( aChecks[i]), m_pDoc->GetString(3,i+3,0)); + } + + m_pDoc->DeleteTab(0); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |