From: PJ Fanning Date: Mon, 11 Apr 2022 19:29:30 +0000 (+0000) Subject: refactor test X-Git-Tag: REL_5_2_3~357 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a514fcd0506915e6fdb522ec356aeaad112b47f8;p=poi.git refactor test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1899756 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestRoundFuncs.java b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestRoundFuncs.java index a0c4b7d7ca..df5f033fff 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestRoundFuncs.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestRoundFuncs.java @@ -17,15 +17,22 @@ 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