[Libreoffice-commits] core.git: sc/qa

Eike Rathke erack at redhat.com
Mon Jul 27 06:57:22 PDT 2015


 sc/qa/unit/ucalc.hxx         |    2 ++
 sc/qa/unit/ucalc_formula.cxx |   41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

New commits:
commit 1abc8c1608eca18d5b4a010d8a43fbbe87a6b933
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Jul 27 15:43:22 2015 +0200

    unit test for FORMULA() with and without array context
    
    Change-Id: Ic8e0f5dfad6e9b9a70e6dca89a970c131efc53d9

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 4a3e462..3b24c85 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 b7c4fd7..b6a6933 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: */


More information about the Libreoffice-commits mailing list