aboutsummaryrefslogtreecommitdiffstats
path: root/poi/src
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-10-10 15:46:01 +0000
committerPJ Fanning <fanningpj@apache.org>2021-10-10 15:46:01 +0000
commit84d9ff335a722e5e5f296a8933e42e64721cb389 (patch)
treeb8d55980ac2b763ed8ebd13b7b27f7dacb9feb87 /poi/src
parent08f6de47f69c22de37299d62e00c780350d3dc1a (diff)
downloadpoi-84d9ff335a722e5e5f296a8933e42e64721cb389.tar.gz
poi-84d9ff335a722e5e5f296a8933e42e64721cb389.zip
[bug-64137] increase max iterations for IRR
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894111 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src')
-rw-r--r--poi/src/test/java/org/apache/poi/ss/formula/functions/TestIrr.java9
-rw-r--r--poi/src/test/java/org/apache/poi/ss/util/Utils.java9
2 files changed, 14 insertions, 4 deletions
diff --git a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestIrr.java b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestIrr.java
index d6351a9aaf..b4830e09d3 100644
--- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestIrr.java
+++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestIrr.java
@@ -137,9 +137,10 @@ final class TestIrr {
addRow(sheet, 6, 26000, "Net income for the fifth year");
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
HSSFCell cell = wb.getSheetAt(0).getRow(0).createCell(100);
- assertDouble(fe, cell, "IRR(A2:A6)", -0.02124484827341093);
- assertDouble(fe, cell, "IRR(A2:A7)", 0.08663094803653162);
- assertDouble(fe, cell, "IRR(A2:A4,-0.1)", -0.44350694133474067);
+ final double tolerance = 1E-4;
+ assertDouble(fe, cell, "IRR(A2:A6)", -0.02124484827341093, tolerance);
+ assertDouble(fe, cell, "IRR(A2:A7)", 0.08663094803653162, tolerance);
+ assertDouble(fe, cell, "IRR(A2:A4,-0.1)", -0.44350694133474067, tolerance);
}
}
@@ -154,7 +155,7 @@ final class TestIrr {
1462.8749999999998, 1462.8749999999998, 1462.8749999999998, 1462.8749999999998, 1462.8749999999998,
1462.8749999999998, 1462.8749999999998, 1462.8749999999998, 10000.0};
double result = Irr.irr(incomes);
- assertEquals(-0.009463562705856032, result);
+ assertEquals(-0.009463562705856032, result, 1E-4); // should agree within 0.01%
}
private static void assertFormulaResult(CellValue cv, HSSFCell cell){
diff --git a/poi/src/test/java/org/apache/poi/ss/util/Utils.java b/poi/src/test/java/org/apache/poi/ss/util/Utils.java
index 81ad9e5725..d1e3b78a7d 100644
--- a/poi/src/test/java/org/apache/poi/ss/util/Utils.java
+++ b/poi/src/test/java/org/apache/poi/ss/util/Utils.java
@@ -71,6 +71,15 @@ public class Utils {
assertEquals(expectedResult, result.getNumberValue());
}
+ public static void assertDouble(FormulaEvaluator fe, Cell cell, String formulaText,
+ double expectedResult, double tolerance) {
+ cell.setCellFormula(formulaText);
+ fe.notifyUpdateCell(cell);
+ CellValue result = fe.evaluate(cell);
+ assertEquals(CellType.NUMERIC, result.getCellType());
+ assertEquals(expectedResult, result.getNumberValue(), tolerance);
+ }
+
public static void assertError(FormulaEvaluator fe, Cell cell, String formulaText, FormulaError expectedError) {
cell.setCellFormula(formulaText);
fe.notifyUpdateCell(cell);