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
This commit is contained in:
parent
c33d96aa8b
commit
ca25cdcb39
3 changed files with 13 additions and 14 deletions
BIN
sc/qa/unit/data/ods/opencl/financial/XIRR.ods
Normal file
BIN
sc/qa/unit/data/ods/opencl/financial/XIRR.ods
Normal file
Binary file not shown.
Binary file not shown.
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue