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

Eike Rathke erack at redhat.com
Wed Feb 14 15:33:21 UTC 2018


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

New commits:
commit b05e4eab225a536c3e5bdae2ca991ee9f53ad1a6
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Feb 14 16:32:00 2018 +0100

    Unit test tdf#115493 use matrix as result of jump command, tdf#58874 related
    
    Change-Id: Ic36c5c559d6f650e590ac5f84b4acdb5be0843b3

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 81d100254f93..a130d4ad69c7 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -216,6 +216,7 @@ public:
     void testFuncMDETERM();
     void testFuncSUMIFS();
     void testFuncRefListArraySUBTOTAL();
+    void testFuncJumpMatrixArrayIF();
     void testMatConcat();
     void testMatConcatReplication();
     void testRefR1C1WholeCol();
@@ -635,6 +636,7 @@ public:
     CPPUNIT_TEST(testFuncMDETERM);
     CPPUNIT_TEST(testFuncSUMIFS);
     CPPUNIT_TEST(testFuncRefListArraySUBTOTAL);
+    CPPUNIT_TEST(testFuncJumpMatrixArrayIF);
     CPPUNIT_TEST(testMatConcat);
     CPPUNIT_TEST(testMatConcatReplication);
     CPPUNIT_TEST(testExternalRef);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index e282b0eb3a60..d6764c498e51 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -8360,6 +8360,36 @@ void Test::testFuncRefListArraySUBTOTAL()
     m_pDoc->DeleteTab(0);
 }
 
+// tdf#115493 jump commands return the matrix result instead of the reference
+// list array.
+void Test::testFuncJumpMatrixArrayIF()
+{
+    sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+    m_pDoc->InsertTab(0, "Test");
+
+    m_pDoc->SetString(0,0,0, "a");  // A1
+    std::vector<std::vector<const char*>> aData = {
+        { "a", "1" },
+        { "b", "2" },
+        { "a", "4" }
+    };                              // A7:B9
+    insertRangeData(m_pDoc, ScAddress(0,6,0), aData);
+
+    ScMarkData aMark;
+    aMark.SelectOneTable(0);
+
+    // Matrix in C10, summing B7,B9
+    m_pDoc->InsertMatrixFormula( 2,9, 2,9, aMark, "=SUM(IF(EXACT(A7:A9;A$1);B7:B9;0))");
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula C10 failed", 5.0, m_pDoc->GetValue(ScAddress(2,9,0)));
+
+    // Matrix in C11, summing B7,B9
+    m_pDoc->InsertMatrixFormula( 2,10, 2,10, aMark,
+            "=SUM(IF(EXACT(OFFSET(A7;0;0):OFFSET(A7;2;0);A$1);OFFSET(A7;0;1):OFFSET(A7;2;1);0))");
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula C11 failed", 5.0, m_pDoc->GetValue(ScAddress(2,10,0)));
+
+    m_pDoc->DeleteTab(0);
+}
+
 // Test iterations with circular chain of references.
 void Test::testIterations()
 {


More information about the Libreoffice-commits mailing list