From a514fcd0506915e6fdb522ec356aeaad112b47f8 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 11 Apr 2022 19:29:30 +0000 Subject: [PATCH] refactor test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1899756 13f79535-47bb-0310-9956-ffa450edef68 --- .../ss/formula/functions/TestRoundFuncs.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) 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 -- 2.39.5