summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-03-17 18:19:07 -0400
committerMichael Meeks <michael.meeks@collabora.com>2014-06-06 09:15:36 +0100
commita6a51ef9dd991e11c90317f4d6c29dfb310e1a17 (patch)
tree551ac207712419a5dbcf587ec6a4125e483c45f6
parent2b959fb871a68f08a06850909abd16f71033aa3a (diff)
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 (cherry picked from commit ca25cdcb398f200ce5d53286eea02d49d8d1c5f4) Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--sc/qa/unit/data/ods/opencl/financial/XIRR.odsbin0 -> 59488 bytes
-rw-r--r--sc/qa/unit/data/xls/opencl/financial/XIRR.xlsbin7680 -> 0 bytes
-rw-r--r--sc/qa/unit/opencl-test.cxx27
3 files changed, 13 insertions, 14 deletions
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 000000000000..a9d2476d1066
--- /dev/null
+++ b/sc/qa/unit/data/ods/opencl/financial/XIRR.ods
Binary files 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 b9a87ef8b58c..000000000000
--- a/sc/qa/unit/data/xls/opencl/financial/XIRR.xls
+++ /dev/null
Binary files differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 843c9a90b2b1..9def7e8bb24a 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()