diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-12-15 12:06:39 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-12-15 12:06:39 +0000 |
commit | 2a34e5a31eead69646f8670b6863ce9d176af1cf (patch) | |
tree | 4e99dcfcec8541cb7d6ca8f7c6923f385ed27c0d | |
parent | 0d382b4c67549b553db2563ccd030a6c390db5db (diff) | |
download | poi-2a34e5a31eead69646f8670b6863ce9d176af1cf.tar.gz poi-2a34e5a31eead69646f8670b6863ce9d176af1cf.zip |
upgrade mockito and byte-buddy
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1906012 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | build.xml | 6 | ||||
-rw-r--r-- | poi-ooxml-lite-agent/build.gradle | 4 | ||||
-rw-r--r-- | poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java | 14 | ||||
-rw-r--r-- | poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java | 10 |
5 files changed, 24 insertions, 12 deletions
diff --git a/build.gradle b/build.gradle index 556bdc71c1..f62daf4ad1 100644 --- a/build.gradle +++ b/build.gradle @@ -121,7 +121,7 @@ subprojects { commonsMathVersion = '3.6.1' junitVersion = '5.9.0' log4jVersion = '2.19.0' - mockitoVersion = '4.9.0' + mockitoVersion = '4.10.0' hamcrestVersion = '2.2' xmlbeansVersion = '5.1.1' batikVersion = '1.16' @@ -284,9 +284,9 @@ under the License. <dependency prefix="main.jmhAnnotation" artifact="org.openjdk.jmh:jmh-generator-annprocess:1.35" usage="main-tests"/> <dependency prefix="main.hamcrest" artifact="org.hamcrest:hamcrest:2.2" usage="main-tests"/> <dependency prefix="main.xmlunit" artifact="org.xmlunit:xmlunit-core:2.9.0" usage="main-tests"/> - <dependency prefix="main.mockito" artifact="org.mockito:mockito-core:4.9.0" usage="main-tests"/> - <dependency prefix="main.byte-buddy" artifact="net.bytebuddy:byte-buddy:1.12.19" usage="main-tests"/> - <dependency prefix="main.byte-buddy-agent" artifact="net.bytebuddy:byte-buddy-agent:1.12.19" usage="main-tests"/> + <dependency prefix="main.mockito" artifact="org.mockito:mockito-core:4.10.0" usage="main-tests"/> + <dependency prefix="main.byte-buddy" artifact="net.bytebuddy:byte-buddy:1.12.20" usage="main-tests"/> + <dependency prefix="main.byte-buddy-agent" artifact="net.bytebuddy:byte-buddy-agent:1.12.20" usage="main-tests"/> <dependency prefix="main.objenesis" artifact="org.objenesis:objenesis:3.1" usage="main-tests"/> <dependency prefix="main.log4j-core" artifact="org.apache.logging.log4j:log4j-core:2.19.0" usage="main-tests"/> <dependency prefix="main.commons-logging" artifact="commons-logging:commons-logging:1.2" usage="main-tests"/> diff --git a/poi-ooxml-lite-agent/build.gradle b/poi-ooxml-lite-agent/build.gradle index e5720316c8..168caf8bf3 100644 --- a/poi-ooxml-lite-agent/build.gradle +++ b/poi-ooxml-lite-agent/build.gradle @@ -24,8 +24,8 @@ sourceSets { } dependencies { - api 'net.bytebuddy:byte-buddy:1.12.19' - api 'net.bytebuddy:byte-buddy-agent:1.12.19' + api 'net.bytebuddy:byte-buddy:1.12.20' + api 'net.bytebuddy:byte-buddy-agent:1.12.20' api "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}" } diff --git a/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java b/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java index 0acd9d1871..322ee7b0c5 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java @@ -89,17 +89,19 @@ public abstract class TwoOperandNumericOperation extends Fixed2ArgFunction imple if (d1 == 0.0) { throw new EvaluationException(ErrorEval.DIV_ZERO); } - BigDecimal bd0 = new BigDecimal(NumberToTextConverter.toText(d0)); - BigDecimal bd1 = new BigDecimal(NumberToTextConverter.toText(d1)); - return bd0.divide(bd1, MathContext.DECIMAL128).doubleValue(); + BigDecimal bd0 = new BigDecimal(d0); + BigDecimal bd1 = new BigDecimal(d1); + BigDecimal result = bd0.divide(bd1, MathContext.DECIMAL128); + return Double.parseDouble(NumberToTextConverter.toText(result.doubleValue())); } }; public static final Function MultiplyEval = new TwoOperandNumericOperation() { @Override protected double evaluate(double d0, double d1) { - BigDecimal bd0 = new BigDecimal(NumberToTextConverter.toText(d0)); - BigDecimal bd1 = new BigDecimal(NumberToTextConverter.toText(d1)); - return bd0.multiply(bd1).doubleValue(); + BigDecimal bd0 = new BigDecimal(d0); + BigDecimal bd1 = new BigDecimal(d1); + BigDecimal result = bd0.multiply(bd1); + return Double.parseDouble(NumberToTextConverter.toText(result.doubleValue())); } }; public static final Function PowerEval = new TwoOperandNumericOperation() { diff --git a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java index f398b9217a..c857a7f8ef 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestNumericFunction.java @@ -23,6 +23,7 @@ import org.apache.poi.util.LocaleUtil; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import java.io.IOException; import java.util.Locale; import static org.apache.poi.ss.util.Utils.assertDouble; @@ -45,6 +46,15 @@ final class TestNumericFunction { } @Test + void testMultiply() throws IOException { + try (HSSFWorkbook wb = new HSSFWorkbook()) { + HSSFCell cell = wb.createSheet().createRow(0).createCell(0); + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); + assertDouble(fe, cell, "1.2*SQRT(5.678)", 2.85942651592937, 0); + } + } + + @Test void testSIGN() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFCell cell = wb.createSheet().createRow(0).createCell(0); |