You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2022/01/25 19:37:38 UTC
svn commit: r1897468 - /poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumberValue.java
Author: fanningpj
Date: Tue Jan 25 19:37:37 2022
New Revision: 1897468
URL: http://svn.apache.org/viewvc?rev=1897468&view=rev
Log:
[bug-65846] support numbervalue function
Modified:
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumberValue.java
Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumberValue.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumberValue.java?rev=1897468&r1=1897467&r2=1897468&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumberValue.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumberValue.java Tue Jan 25 19:37:37 2022
@@ -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);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org