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

Dennis Francis dennisfrancis.in at gmail.com
Sat Oct 24 07:34:21 PDT 2015


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

New commits:
commit c43442dfef3f5b21bec40054b56f406efdc5a84f
Author: Dennis Francis <dennisfrancis.in at gmail.com>
Date:   Sat Oct 24 13:16:14 2015 +0530

    unit test for MDETERM() tdf#32834
    
    Change-Id: Icc55931f5bc64fcc2745ca68f62851ee2c59f711
    Reviewed-on: https://gerrit.libreoffice.org/19569
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 29ca1e0..b1a6af2 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -193,6 +193,7 @@ public:
     void testFuncGCD();
     void testFuncLCM();
     void testFuncSUMSQ();
+    void testFuncMDETERM();
 
     void testExternalRef();
     void testExternalRefFunctions();
@@ -534,6 +535,7 @@ public:
     CPPUNIT_TEST(testFuncGCD);
     CPPUNIT_TEST(testFuncLCM);
     CPPUNIT_TEST(testFuncSUMSQ);
+    CPPUNIT_TEST(testFuncMDETERM);
     CPPUNIT_TEST(testExternalRef);
     CPPUNIT_TEST(testExternalRangeName);
     CPPUNIT_TEST(testExternalRefFunctions);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 8538eae..1e0c06b 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -6572,6 +6572,46 @@ void Test::testFuncSUMSQ()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testFuncMDETERM()
+{
+    sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+    m_pDoc->InsertTab(0, "MDETERM_test");
+    ScAddress aPos(8,0,0);
+    OUString aColCodes("ABCDEFGH");
+    OUString aFormulaTemplate("=MDETERM(A1:B2)");
+    OUStringBuffer aFormulaBuffer(aFormulaTemplate);
+    for( SCSIZE nSize = 3; nSize <= 8; nSize++ )
+    {
+        double fVal = 1.0;
+        // Generate a singular integer matrix
+        for( SCROW nRow = 0; nRow < static_cast<SCROW>(nSize); nRow++ )
+        {
+            for( SCCOL nCol = 0; nCol < static_cast<SCCOL>(nSize); nCol++ )
+            {
+                m_pDoc->SetValue(nCol, nRow, 0, fVal);
+                fVal += 1.0;
+            }
+        }
+        aFormulaBuffer[12] = aColCodes[nSize-1];
+        aFormulaBuffer[13] = static_cast<sal_Unicode>( '0' + nSize );
+        m_pDoc->SetString(aPos, aFormulaBuffer.toString());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of MDETERM incorrect for singular integer matrix",
+                                     0.0, m_pDoc->GetValue(aPos));
+    }
+
+    int aVals[] = {23, 31, 13, 12, 34, 64, 34, 31, 98, 32, 33, 63, 45, 54, 65, 76};
+    int nIdx = 0;
+    for( SCROW nRow = 0; nRow < 4; nRow++ )
+        for( SCCOL nCol = 0; nCol < 4; nCol++ )
+            m_pDoc->SetValue(nCol, nRow, 0, static_cast<double>(aVals[nIdx++]));
+    m_pDoc->SetString(aPos, "=MDETERM(A1:D4)");
+    // Following test is conservative in the sense that on Linux x86_64 the error is less that 1.0E-9
+    CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of MDETERM incorrect for non-singular integer matrix",
+                                         -180655.0, m_pDoc->GetValue(aPos), 1.0E-6);
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testFormulaErrorPropagation()
 {
     sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.


More information about the Libreoffice-commits mailing list