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

Eike Rathke erack at redhat.com
Wed Nov 2 15:16:40 UTC 2016


 sc/qa/unit/ucalc_formula.cxx |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

New commits:
commit 01875c4514c777a43ee18014d9b0cb3f34eebbba
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Nov 2 16:15:36 2016 +0100

    unit test for tdf#99291, empty array elements match 0.0, not empty
    
    Change-Id: I65cac442583ecd90831ebea01d2be6c0b1e60b9a

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 2780d08..b572c54 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -3924,6 +3924,30 @@ void Test::testFuncCOUNTIF()
     // We should correctly count with empty string key.
     CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(0,4,0)));
 
+    // Another test case adopted from tdf#99291, empty array elements should
+    // not match empty cells, but cells with 0.
+    clearSheet(m_pDoc, 0);
+    ScMarkData aMark;
+    aMark.SelectOneTable(0);
+    m_pDoc->InsertMatrixFormula(0,0, 0,1, aMark, "=COUNTIF(B1:B5;C1:C2)");
+    // As we will be testing for 0.0 values, check that formulas are actually present.
+    OUString aFormula;
+    m_pDoc->GetFormula(0,0,0, aFormula);
+    CPPUNIT_ASSERT_EQUAL(OUString("{=COUNTIF(B1:B5;C1:C2)}"), aFormula);
+    m_pDoc->GetFormula(0,1,0, aFormula);
+    CPPUNIT_ASSERT_EQUAL(OUString("{=COUNTIF(B1:B5;C1:C2)}"), aFormula);
+    // The 0.0 results expected.
+    CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+    CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+    // 0.0 in B2, 1.0 in B3 and B4
+    m_pDoc->SetValue( ScAddress(1,1,0), 0.0);
+    m_pDoc->SetValue( ScAddress(1,2,0), 1.0);
+    m_pDoc->SetValue( ScAddress(1,3,0), 1.0);
+    // Matched by 0.0 produced by empty cell in array, and 1.0 in C2.
+    m_pDoc->SetValue( ScAddress(2,1,0), 1.0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("One cell with 0.0",  1.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Two cells with 1.0", 2.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+
     m_pDoc->DeleteTab(0);
 }
 


More information about the Libreoffice-commits mailing list