diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2021-01-17 00:50:47 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2021-01-17 00:50:47 +0000 |
commit | 020f33a940112c44e570eb42cc78f9e6d5ffb7f4 (patch) | |
tree | 2633365345fca5f1fef56a11c39b07f262b42b8e /src/testcases/org/apache/poi/ss/util/TestNumberComparer.java | |
parent | 44efecf42ed62aba1d6c9e149c3683bfd19f6453 (diff) | |
download | poi-020f33a940112c44e570eb42cc78f9e6d5ffb7f4.tar.gz poi-020f33a940112c44e570eb42cc78f9e6d5ffb7f4.zip |
Sonar fixes
add asserts to tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885585 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss/util/TestNumberComparer.java')
-rw-r--r-- | src/testcases/org/apache/poi/ss/util/TestNumberComparer.java | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java b/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java index 42a0edd841..225d9f835c 100644 --- a/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java +++ b/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java @@ -17,6 +17,7 @@ package org.apache.poi.ss.util; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -24,6 +25,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.poi.ss.util.NumberComparisonExamples.ComparisonExample; import org.apache.poi.util.HexDump; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests for {@link NumberComparer} @@ -46,22 +49,15 @@ final class TestNumberComparer { assertTrue(success, "One or more cases failed. See stderr"); } - @Test - void testRoundTripOnComparisonExamples() { - ComparisonExample[] examples = NumberComparisonExamples.getComparisonExamples(); - for(int i=0;i<examples.length; i++) { - ComparisonExample ce = examples[i]; - confirmRoundTrip(i, ce.getA()); - confirmRoundTrip(i, ce.getNegA()); - confirmRoundTrip(i, ce.getB()); - confirmRoundTrip(i, ce.getNegB()); + @ParameterizedTest + @MethodSource("org.apache.poi.ss.util.NumberComparisonExamples#getComparisonExamples") + void testRoundTripOnComparisonExamples(ComparisonExample ce) { + double[] vals = { ce.getA(), ce.getNegA(), ce.getB(), ce.getNegB() }; + for (double a : vals) { + assertDoesNotThrow(() -> new TestExpandedDouble().confirmRoundTrip(Double.doubleToLongBits(a))); } } - private void confirmRoundTrip(int i, double a) { - TestExpandedDouble.confirmRoundTrip(i, Double.doubleToLongBits(a)); - } - /** * The actual example from bug 47598 */ |