Kaydet (Commit) ca25cdcb authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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
üst c33d96aa
...@@ -3405,28 +3405,27 @@ void ScOpenclTest:: testFinancialXirrFormula() ...@@ -3405,28 +3405,27 @@ void ScOpenclTest:: testFinancialXirrFormula()
{ {
if (!detectOpenCLDevice()) if (!detectOpenCLDevice())
return; return;
ScDocShellRef xDocSh = loadDoc("opencl/financial/XIRR.", XLS);
ScDocShellRef xDocSh = loadDoc("opencl/financial/XIRR.", ODS);
CPPUNIT_ASSERT(xDocSh.Is());
ScDocument *pDoc = xDocSh->GetDocument(); ScDocument *pDoc = xDocSh->GetDocument();
CPPUNIT_ASSERT(pDoc);
enableOpenCL(); enableOpenCL();
pDoc->CalcAll(); pDoc->CalcAll();
ScDocShellRef xDocShRes = loadDoc("opencl/financial/XIRR.", XLS);
ScDocument *pDocRes = xDocShRes->GetDocument(); for (SCROW i = 1; i <= 10; ++i)
CPPUNIT_ASSERT(pDocRes);
for (SCROW i = 0; i <= 9; ++i)
{ {
double fLibre = pDoc->GetValue(ScAddress(2, i, 0)); double fFormula = pDoc->GetValue(ScAddress(2, i, 0));
double fExcel = pDocRes->GetValue(ScAddress(2, i, 0)); double fExpected = pDoc->GetValue(ScAddress(3, i, 0));
CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel)); 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 fFormula = pDoc->GetValue(ScAddress(2, i, 0));
double fExcel = pDocRes->GetValue(ScAddress(2, i, 0)); double fExpected = pDoc->GetValue(ScAddress(3, i, 0));
CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel)); CPPUNIT_ASSERT(rtl::math::approxEqual(fExpected, fFormula));
} }
xDocSh->DoClose(); xDocSh->DoClose();
xDocShRes->DoClose();
} }
//[AMLOEXT-139] //[AMLOEXT-139]
void ScOpenclTest::testStatisticalFormulaChiSqDist() void ScOpenclTest::testStatisticalFormulaChiSqDist()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment