diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-03-17 18:19:07 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-03-17 18:41:58 -0400 |
commit | ca25cdcb398f200ce5d53286eea02d49d8d1c5f4 (patch) | |
tree | 12c63a0642e249032405229ea9ec4ba803f498a7 /sc/qa | |
parent | c33d96aa8bbe94761b609215951a64e380856cac (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
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/data/ods/opencl/financial/XIRR.ods | bin | 0 -> 59488 bytes | |||
-rw-r--r-- | sc/qa/unit/data/xls/opencl/financial/XIRR.xls | bin | 7680 -> 0 bytes | |||
-rw-r--r-- | sc/qa/unit/opencl-test.cxx | 27 |
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 Binary files differnew file mode 100644 index 000000000000..a9d2476d1066 --- /dev/null +++ b/sc/qa/unit/data/ods/opencl/financial/XIRR.ods diff --git a/sc/qa/unit/data/xls/opencl/financial/XIRR.xls b/sc/qa/unit/data/xls/opencl/financial/XIRR.xls Binary files differdeleted file mode 100644 index b9a87ef8b58c..000000000000 --- a/sc/qa/unit/data/xls/opencl/financial/XIRR.xls +++ /dev/null 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() |