]> source.dussan.org Git - poi.git/commitdiff
refactor test
authorPJ Fanning <fanningpj@apache.org>
Mon, 11 Apr 2022 19:29:30 +0000 (19:29 +0000)
committerPJ Fanning <fanningpj@apache.org>
Mon, 11 Apr 2022 19:29:30 +0000 (19:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1899756 13f79535-47bb-0310-9956-ffa450edef68

poi/src/test/java/org/apache/poi/ss/formula/functions/TestRoundFuncs.java

index a0c4b7d7cae2b2ac1ac8b4de1d88088b266f0b7f..df5f033fff7c47f7c95708f8993122bae7dcc0bf 100644 (file)
 
 package org.apache.poi.ss.formula.functions;
 
+import static org.apache.poi.ss.util.Utils.assertDouble;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.eval.StringEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
-import org.junit.jupiter.api.Disabled;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
 import org.junit.jupiter.api.Test;
 
+import java.io.IOException;
+
 /**
  * Test cases for ROUND(), ROUNDUP(), ROUNDDOWN()
  */
@@ -54,11 +61,16 @@ final class TestRoundFuncs {
     }
 
     @Test
-    void testGithub321() {
-        ValueEval strArg = new NumberEval(2.05);
-        ValueEval[] args = { strArg, new NumberEval(1), };
-        NumberEval result = (NumberEval)NumericFunction.ROUND.evaluate(args, -1, (short)-1);
-        assertEquals(2.1, result.getNumberValue());
+    void testGithub321() throws IOException {
+        try (HSSFWorkbook hssfWorkbook = new HSSFWorkbook()) {
+            HSSFSheet hssfSheet = hssfWorkbook.createSheet();
+            HSSFRow hssfRow = hssfSheet.createRow(0);
+            HSSFCell hssfCell = hssfRow.createCell(0);
+            hssfCell.setCellValue(2.05d);
+            FormulaEvaluator formulaEvaluator = hssfWorkbook.getCreationHelper().createFormulaEvaluator();
+            HSSFCell formulaCell = hssfRow.createCell(1);
+            assertDouble(formulaEvaluator, formulaCell, "ROUND(A1, 1)", 2.1d, 1E-25);
+        }
     }
 
     @Test