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

Kohei Yoshida kohei.yoshida at collabora.com
Mon Mar 17 15:43:34 PDT 2014


 dev/null                                      |binary
 sc/qa/unit/data/ods/opencl/financial/XIRR.ods |binary
 sc/qa/unit/opencl-test.cxx                    |   27 ++++++++++++--------------
 3 files changed, 13 insertions(+), 14 deletions(-)

New commits:
commit ca25cdcb398f200ce5d53286eea02d49d8d1c5f4
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Mar 17 18:19:07 2014 -0400

    fdo#76140: Reimplement XIRR OpenCL test.
    
    1) Use ods format and store the expected formula results as numeric cells,
       to avoid having to load the same file twice (which is slower).
    
    2) Use rtl::math::approxEqual to evaluate two numbers that may be subject
       to numerical instability especially when the expected values are very
       small.
    
    Change-Id: Ie08e91f797065f4593f996df3541da84019cc53c

diff --git a/sc/qa/unit/data/ods/opencl/financial/XIRR.ods b/sc/qa/unit/data/ods/opencl/financial/XIRR.ods
new file mode 100644
index 0000000..a9d2476
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/financial/XIRR.ods differ
diff --git a/sc/qa/unit/data/xls/opencl/financial/XIRR.xls b/sc/qa/unit/data/xls/opencl/financial/XIRR.xls
deleted file mode 100644
index b9a87ef..0000000
Binary files a/sc/qa/unit/data/xls/opencl/financial/XIRR.xls and /dev/null differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 843c9a9..9def7e8 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -3405,28 +3405,27 @@ void ScOpenclTest:: testFinancialXirrFormula()
 {
     if (!detectOpenCLDevice())
         return;
-    ScDocShellRef xDocSh = loadDoc("opencl/financial/XIRR.", XLS);
+
+    ScDocShellRef xDocSh = loadDoc("opencl/financial/XIRR.", ODS);
+    CPPUNIT_ASSERT(xDocSh.Is());
     ScDocument *pDoc = xDocSh->GetDocument();
-    CPPUNIT_ASSERT(pDoc);
     enableOpenCL();
     pDoc->CalcAll();
-    ScDocShellRef xDocShRes = loadDoc("opencl/financial/XIRR.", XLS);
-    ScDocument *pDocRes = xDocShRes->GetDocument();
-    CPPUNIT_ASSERT(pDocRes);
-    for (SCROW i = 0; i <= 9; ++i)
+
+    for (SCROW i = 1; i <= 10; ++i)
     {
-        double fLibre = pDoc->GetValue(ScAddress(2, i, 0));
-        double fExcel = pDocRes->GetValue(ScAddress(2, i, 0));
-        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+        double fFormula  = pDoc->GetValue(ScAddress(2, i, 0));
+        double fExpected = pDoc->GetValue(ScAddress(3, i, 0));
+        CPPUNIT_ASSERT(rtl::math::approxEqual(fExpected, fFormula));
     }
-    for (SCROW i = 18; i <= 26; ++i)
+    for (SCROW i = 18; i <= 27; ++i)
     {
-        double fLibre = pDoc->GetValue(ScAddress(2, i, 0));
-        double fExcel = pDocRes->GetValue(ScAddress(2, i, 0));
-        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+        double fFormula = pDoc->GetValue(ScAddress(2, i, 0));
+        double fExpected = pDoc->GetValue(ScAddress(3, i, 0));
+        CPPUNIT_ASSERT(rtl::math::approxEqual(fExpected, fFormula));
     }
+
     xDocSh->DoClose();
-    xDocShRes->DoClose();
 }
 //[AMLOEXT-139]
 void ScOpenclTest::testStatisticalFormulaChiSqDist()


More information about the Libreoffice-commits mailing list