aboutsummaryrefslogtreecommitdiffstats
path: root/poi/src
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-01-25 19:37:37 +0000
committerPJ Fanning <fanningpj@apache.org>2022-01-25 19:37:37 +0000
commit49324459d4cb1d0074e3a210b70d08833743f50b (patch)
tree9ad8233ae2464dc0cdd75f0f7c7e5228eabe4018 /poi/src
parent4fec22f6a915dcb9afab4bcb54f23eea9291559f (diff)
downloadpoi-49324459d4cb1d0074e3a210b70d08833743f50b.tar.gz
poi-49324459d4cb1d0074e3a210b70d08833743f50b.zip
[bug-65846] support numbervalue function
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897468 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src')
-rw-r--r--poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumberValue.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumberValue.java b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumberValue.java
index a2a512bc6a..fd6166f33d 100644
--- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumberValue.java
+++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumberValue.java
@@ -30,6 +30,7 @@ import java.io.IOException;
import static org.apache.poi.ss.util.Utils.addRow;
import static org.apache.poi.ss.util.Utils.assertDouble;
+import static org.apache.poi.ss.util.Utils.assertError;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
@@ -46,6 +47,7 @@ public class TestNumberValue {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
HSSFCell cell = row.createCell(0);
assertDouble(fe, cell, "NUMBERVALUE(\"2.500,27\",\",\",\".\")", 2500.27, 0.000000000001);
+ assertDouble(fe, cell, "NUMBERVALUE(\" 2.500,27 \",\",\",\".\")", 2500.27, 0.000000000001);
}
}
@@ -57,6 +59,19 @@ public class TestNumberValue {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
HSSFCell cell = row.createCell(0);
assertDouble(fe, cell, "NUMBERVALUE(\"3.5%\")", 0.035, 0.000000000001);
+ assertDouble(fe, cell, "NUMBERVALUE(\"9%%\")", 0.0009, 0.000000000001);
+ }
+ }
+
+ @Test
+ void testInvalidValues() throws IOException {
+ try (HSSFWorkbook wb = new HSSFWorkbook()) {
+ HSSFSheet sheet = wb.createSheet();
+ HSSFRow row = sheet.createRow(0);
+ HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
+ HSSFCell cell = row.createCell(0);
+ assertError(fe, cell, "NUMBERVALUE(\"notnum\")", FormulaError.VALUE);
+ assertError(fe, cell, "NUMBERVALUE(\"2,00,27\",\",\",\".\")", FormulaError.VALUE);
}
}
}