Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-numbers
diff --git a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java
index 79b62eb..a320e26 100644
--- a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java
+++ b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java
@@ -22,10 +22,10 @@
/**
* Test cases for the {@link PlaneAngleRadians} class.
*/
-public class PlaneAngleRadiansTest {
+class PlaneAngleRadiansTest {
@Test
@SuppressWarnings("squid:S3415")
- public void testConstants() {
+ void testConstants() {
final double eps = 0;
Assertions.assertEquals(Math.PI, PlaneAngleRadians.PI, eps);
@@ -36,7 +36,7 @@
// Test constants using "sin" and "cos".
@Test
- public void testConstants2() {
+ void testConstants2() {
final double eps = Math.ulp(1d);
Assertions.assertEquals(0d, Math.sin(PlaneAngleRadians.PI), eps);
@@ -53,7 +53,7 @@
}
@Test
- public void testNormalize() {
+ void testNormalize() {
for (double a = -15.0; a <= 15.0; a += 0.1) {
for (double b = -15.0; b <= 15.0; b += 0.2) {
final double c = PlaneAngleRadians.normalize(a, b);
@@ -66,7 +66,7 @@
}
@Test
- public void testNormalizeBetweenMinusPiAndPi1() {
+ void testNormalizeBetweenMinusPiAndPi1() {
final double value = 1.25 * PlaneAngleRadians.TWO_PI;
final double expected = PlaneAngleRadians.PI_OVER_TWO;
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
@@ -74,7 +74,7 @@
Assertions.assertEquals(expected, actual, tol);
}
@Test
- public void testNormalizeBetweenMinusPiAndPi2() {
+ void testNormalizeBetweenMinusPiAndPi2() {
final double value = 0.75 * PlaneAngleRadians.TWO_PI;
final double expected = -PlaneAngleRadians.PI_OVER_TWO;
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
@@ -82,7 +82,7 @@
Assertions.assertEquals(expected, actual, tol);
}
@Test
- public void testNormalizeBetweenMinusPiAndPi3() {
+ void testNormalizeBetweenMinusPiAndPi3() {
final double value = PlaneAngleRadians.PI + 1e-10;
final double expected = -PlaneAngleRadians.PI + 1e-10;
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
@@ -90,7 +90,7 @@
Assertions.assertEquals(expected, actual, tol);
}
@Test
- public void testNormalizeBetweenMinusPiAndPi4() {
+ void testNormalizeBetweenMinusPiAndPi4() {
final double value = 5 * PlaneAngleRadians.PI / 4;
final double expected = PlaneAngleRadians.PI * (1d / 4 - 1);
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
@@ -99,7 +99,7 @@
}
@Test
- public void testNormalizeBetweenMinusPiAndPi_lowerBound() {
+ void testNormalizeBetweenMinusPiAndPi_lowerBound() {
final double value = PlaneAngleRadians.PI;
final double expected = -PlaneAngleRadians.PI;
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
@@ -107,7 +107,7 @@
Assertions.assertEquals(expected, actual, tol);
}
@Test
- public void testNormalizeBetweenMinusPiAndPi_upperBound() {
+ void testNormalizeBetweenMinusPiAndPi_upperBound() {
final double value = PlaneAngleRadians.PI;
final double expected = -PlaneAngleRadians.PI;
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
@@ -116,7 +116,7 @@
}
@Test
- public void testNormalizeBetweenZeroAndTwoPi1() {
+ void testNormalizeBetweenZeroAndTwoPi1() {
final double value = 1.25 * PlaneAngleRadians.TWO_PI;
final double expected = PlaneAngleRadians.PI_OVER_TWO;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
@@ -124,7 +124,7 @@
Assertions.assertEquals(expected, actual, tol);
}
@Test
- public void testNormalizeBetweenZeroAndTwoPi2() {
+ void testNormalizeBetweenZeroAndTwoPi2() {
final double value = 1.75 * PlaneAngleRadians.TWO_PI;
final double expected = PlaneAngleRadians.THREE_PI_OVER_TWO;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
@@ -132,7 +132,7 @@
Assertions.assertEquals(expected, actual, tol);
}
@Test
- public void testNormalizeBetweenZeroAndTwoPi3() {
+ void testNormalizeBetweenZeroAndTwoPi3() {
final double value = -PlaneAngleRadians.PI + 1e-10;
final double expected = PlaneAngleRadians.PI + 1e-10;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
@@ -140,7 +140,7 @@
Assertions.assertEquals(expected, actual, tol);
}
@Test
- public void testNormalizeBetweenZeroAndTwoPi4() {
+ void testNormalizeBetweenZeroAndTwoPi4() {
final double value = 9 * PlaneAngleRadians.PI / 4;
final double expected = PlaneAngleRadians.PI / 4;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
@@ -149,7 +149,7 @@
}
@Test
- public void testNormalizeBetweenZeroAndTwoPi_lowerBound() {
+ void testNormalizeBetweenZeroAndTwoPi_lowerBound() {
final double value = 0.0;
final double expected = 0.0;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
@@ -157,7 +157,7 @@
Assertions.assertEquals(expected, actual, tol);
}
@Test
- public void testNormalizeBetweenZeroAndTwoPi_upperBound() {
+ void testNormalizeBetweenZeroAndTwoPi_upperBound() {
final double value = PlaneAngleRadians.TWO_PI;
final double expected = 0.0;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
diff --git a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
index 5cd2039..bf37b89 100644
--- a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
+++ b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
@@ -22,32 +22,32 @@
/**
* Test cases for the {@link PlaneAngle} class.
*/
-public class PlaneAngleTest {
+class PlaneAngleTest {
@Test
- public void testConversionTurns() {
+ void testConversionTurns() {
final double value = 12.3456;
final PlaneAngle a = PlaneAngle.ofTurns(value);
- Assertions.assertEquals(value, a.toTurns(), 0d);
+ Assertions.assertEquals(value, a.toTurns());
}
@Test
- public void testConversionRadians() {
+ void testConversionRadians() {
final double one = 2 * Math.PI;
final double value = 12.3456 * one;
final PlaneAngle a = PlaneAngle.ofRadians(value);
- Assertions.assertEquals(value, a.toRadians(), 0d);
+ Assertions.assertEquals(value, a.toRadians());
}
@Test
- public void testConversionDegrees() {
+ void testConversionDegrees() {
final double one = 360;
final double value = 12.3456 * one;
final PlaneAngle a = PlaneAngle.ofDegrees(value);
- Assertions.assertEquals(value, a.toDegrees(), 0d);
+ Assertions.assertEquals(value, a.toDegrees());
}
@Test
- public void testNormalizeRadians() {
+ void testNormalizeRadians() {
for (double a = -15.0; a <= 15.0; a += 0.1) {
for (double b = -15.0; b <= 15.0; b += 0.2) {
final PlaneAngle aA = PlaneAngle.ofRadians(a);
@@ -62,7 +62,7 @@
}
@Test
- public void testNormalizeMixed() {
+ void testNormalizeMixed() {
for (double a = -15.0; a <= 15.0; a += 0.1) {
for (double b = -15.0; b <= 15.0; b += 0.2) {
final PlaneAngle aA = PlaneAngle.ofDegrees(a);
@@ -77,7 +77,7 @@
}
@Test
- public void testNormalizeAroundZero1() {
+ void testNormalizeAroundZero1() {
final double value = 1.25;
final double expected = 0.25;
final double actual = PlaneAngle.ofTurns(value).normalize(PlaneAngle.ZERO).toTurns();
@@ -85,7 +85,7 @@
Assertions.assertEquals(expected, actual, tol);
}
@Test
- public void testNormalizeAroundZero2() {
+ void testNormalizeAroundZero2() {
final double value = 0.75;
final double expected = -0.25;
final double actual = PlaneAngle.ofTurns(value).normalize(PlaneAngle.ZERO).toTurns();
@@ -93,7 +93,7 @@
Assertions.assertEquals(expected, actual, tol);
}
@Test
- public void testNormalizeAroundZero3() {
+ void testNormalizeAroundZero3() {
final double value = 0.5 + 1e-10;
final double expected = -0.5 + 1e-10;
final double actual = PlaneAngle.ofTurns(value).normalize(PlaneAngle.ZERO).toTurns();
@@ -101,7 +101,7 @@
Assertions.assertEquals(expected, actual, tol);
}
@Test
- public void testNormalizeAroundZero4() {
+ void testNormalizeAroundZero4() {
final double value = 5 * Math.PI / 4;
final double expected = Math.PI * (1d / 4 - 1);
final double actual = PlaneAngle.ofRadians(value).normalize(PlaneAngle.ZERO).toRadians();
@@ -110,7 +110,7 @@
}
@Test
- public void testNormalizeUpperAndLowerBounds() {
+ void testNormalizeUpperAndLowerBounds() {
// arrange
double eps = 1e-15;
@@ -129,7 +129,7 @@
}
@Test
- public void testNormalizeVeryCloseToBounds() {
+ void testNormalizeVeryCloseToBounds() {
// arrange
double eps = 1e-22;
@@ -151,7 +151,7 @@
}
@Test
- public void testHashCode() {
+ void testHashCode() {
// Test assumes that the internal representation is in "turns".
final double value = -123.456789;
final int expected = Double.valueOf(value).hashCode();
@@ -160,7 +160,7 @@
}
@Test
- public void testEquals() {
+ void testEquals() {
final double value = 12345.6789;
final PlaneAngle a = PlaneAngle.ofRadians(value);
Assertions.assertTrue(a.equals(a));
@@ -171,11 +171,11 @@
}
@Test
- public void testZero() {
- Assertions.assertEquals(0, PlaneAngle.ZERO.toRadians(), 0d);
+ void testZero() {
+ Assertions.assertEquals(0, PlaneAngle.ZERO.toRadians());
}
@Test
- public void testPi() {
- Assertions.assertEquals(Math.PI, PlaneAngle.PI.toRadians(), 0d);
+ void testPi() {
+ Assertions.assertEquals(Math.PI, PlaneAngle.PI.toRadians());
}
}
diff --git a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/CosAngleTest.java b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/CosAngleTest.java
index 758ee3f..90fdcf1 100644
--- a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/CosAngleTest.java
+++ b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/CosAngleTest.java
@@ -22,19 +22,19 @@
/**
* Test cases for the {@link CosAngle} class.
*/
-public class CosAngleTest {
+class CosAngleTest {
@Test
- public void testCosAngle2D() {
+ void testCosAngle2D() {
double expected;
final double[] v1 = {1, 0};
expected = 1;
- Assertions.assertEquals(expected, CosAngle.value(v1, v1), 0d);
+ Assertions.assertEquals(expected, CosAngle.value(v1, v1));
final double[] v2 = {0, 1};
expected = 0;
- Assertions.assertEquals(expected, CosAngle.value(v1, v2), 0d);
+ Assertions.assertEquals(expected, CosAngle.value(v1, v2));
final double[] v3 = {7, 7};
expected = Math.sqrt(2) / 2;
@@ -43,15 +43,15 @@
final double[] v4 = {-5, 0};
expected = -1;
- Assertions.assertEquals(expected, CosAngle.value(v1, v4), 0);
+ Assertions.assertEquals(expected, CosAngle.value(v1, v4));
final double[] v5 = {-100, 100};
expected = 0;
- Assertions.assertEquals(expected, CosAngle.value(v3, v5), 0);
+ Assertions.assertEquals(expected, CosAngle.value(v3, v5));
}
@Test
- public void testCosAngle3D() {
+ void testCosAngle3D() {
double expected;
final double[] v1 = {1, 1, 0};
@@ -64,7 +64,7 @@
}
@Test
- public void testCosAngleExtreme() {
+ void testCosAngleExtreme() {
double expected;
final double tiny = 1e-200;
@@ -80,7 +80,7 @@
}
@Test
- public void testCosAngle_dimensionMismatch() {
+ void testCosAngle_dimensionMismatch() {
final double[] a = {1.0};
final double[] b = {1.0, 2.0};
diff --git a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/LinearCombinationTest.java b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/LinearCombinationTest.java
index 82894f6..6711b0c 100644
--- a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/LinearCombinationTest.java
+++ b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/LinearCombinationTest.java
@@ -26,18 +26,18 @@
/**
* Test cases for the {@link LinearCombination} class.
*/
-public class LinearCombinationTest {
+class LinearCombinationTest {
// MATH-1005
@Test
- public void testSingleElementArray() {
+ void testSingleElementArray() {
final double[] a = {1.23456789};
final double[] b = {98765432.1};
- Assertions.assertEquals(a[0] * b[0], LinearCombination.value(a, b), 0d);
+ Assertions.assertEquals(a[0] * b[0], LinearCombination.value(a, b));
}
@Test
- public void testTwoSums() {
+ void testTwoSums() {
final BigFraction[] aF = new BigFraction[] {
BigFraction.of(-1321008684645961L, 268435456L),
BigFraction.of(-5774608829631843L, 268435456L),
@@ -62,7 +62,7 @@
a[1], b[1],
a[2], b[2]);
final double abSumArray = LinearCombination.value(a, b);
- Assertions.assertEquals(abSumInline, abSumArray, 0);
+ Assertions.assertEquals(abSumInline, abSumArray);
// Compare with arbitrary precision computation.
BigFraction result = BigFraction.ZERO;
@@ -77,7 +77,7 @@
}
@Test
- public void testArrayVsInline() {
+ void testArrayVsInline() {
final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_SHI_RO_256_PP);
double sInline;
@@ -97,24 +97,24 @@
sInline = LinearCombination.value(u1, v1, u2, v2);
sArray = LinearCombination.value(new double[] {u1, u2},
new double[] {v1, v2});
- Assertions.assertEquals(sInline, sArray, 0);
+ Assertions.assertEquals(sInline, sArray);
// Two sums.
sInline = LinearCombination.value(u1, v1, u2, v2, u3, v3);
sArray = LinearCombination.value(new double[] {u1, u2, u3},
new double[] {v1, v2, v3});
- Assertions.assertEquals(sInline, sArray, 0);
+ Assertions.assertEquals(sInline, sArray);
// Three sums.
sInline = LinearCombination.value(u1, v1, u2, v2, u3, v3, u4, v4);
sArray = LinearCombination.value(new double[] {u1, u2, u3, u4},
new double[] {v1, v2, v3, v4});
- Assertions.assertEquals(sInline, sArray, 0);
+ Assertions.assertEquals(sInline, sArray);
}
}
@Test
- public void testHuge() {
+ void testHuge() {
int scale = 971;
final double[] a = new double[] {
-1321008684645961.0 / 268435456.0,
@@ -139,7 +139,7 @@
scaledA[2], scaledB[2]);
final double abSumArray = LinearCombination.value(scaledA, scaledB);
- Assertions.assertEquals(abSumInline, abSumArray, 0);
+ Assertions.assertEquals(abSumInline, abSumArray);
Assertions.assertEquals(-1.8551294182586248737720779899, abSumInline, 1e-15);
final double naive = scaledA[0] * scaledB[0] + scaledA[1] * scaledB[1] + scaledA[2] * scaledB[2];
@@ -147,7 +147,7 @@
}
@Test
- public void testInfinite() {
+ void testInfinite() {
final double[][] a = new double[][] {
{1, 2, 3, 4},
{1, Double.POSITIVE_INFINITY, 3, 4},
diff --git a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/MultidimensionalCounterTest.java b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/MultidimensionalCounterTest.java
index 88f5815..7307eb5 100644
--- a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/MultidimensionalCounterTest.java
+++ b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/MultidimensionalCounterTest.java
@@ -25,9 +25,9 @@
* Test cases for the {@link MultidimensionalCounter} class.
*
*/
-public class MultidimensionalCounterTest {
+class MultidimensionalCounterTest {
@Test
- public void testPreconditions() {
+ void testPreconditions() {
Assertions.assertThrows(IllegalArgumentException.class, () -> MultidimensionalCounter.of(0, 1));
Assertions.assertThrows(IllegalArgumentException.class, () -> MultidimensionalCounter.of(2, 0));
Assertions.assertThrows(IllegalArgumentException.class, () -> MultidimensionalCounter.of(-1, 1));
@@ -43,7 +43,7 @@
}
@Test
- public void testMulti2UniConversion() {
+ void testMulti2UniConversion() {
final MultidimensionalCounter c = MultidimensionalCounter.of(2, 4, 5);
Assertions.assertEquals(33, c.toUni(1, 2, 3));
@@ -53,7 +53,7 @@
}
@Test
- public void testAccessors() {
+ void testAccessors() {
final int[] originalSize = new int[] {2, 6, 5};
final MultidimensionalCounter c = MultidimensionalCounter.of(originalSize);
final int nDim = c.getDimension();
@@ -66,7 +66,7 @@
}
@Test
- public void testIterationConsistency() {
+ void testIterationConsistency() {
final MultidimensionalCounter c = MultidimensionalCounter.of(2, 3, 4);
final int[][] expected = new int[][] {
{0, 0, 0},
@@ -112,7 +112,7 @@
}
@Test
- public void testToString() {
+ void testToString() {
final int[] sizes = new int[] {7, 5, 3, 1};
final MultidimensionalCounter c = MultidimensionalCounter.of(sizes);
Assertions.assertEquals(Arrays.toString(sizes), c.toString());
diff --git a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SafeNormTest.java b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SafeNormTest.java
index 82de37c..169c498 100644
--- a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SafeNormTest.java
+++ b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SafeNormTest.java
@@ -22,51 +22,51 @@
/**
* Test cases for the {@link SafeNorm} class.
*/
-public class SafeNormTest {
+class SafeNormTest {
@Test
- public void testTiny() {
+ void testTiny() {
final double s = 1e-320;
final double[] v = new double[] {s, s};
Assertions.assertEquals(Math.sqrt(2) * s, SafeNorm.value(v));
}
@Test
- public void testBig() {
+ void testBig() {
final double s = 1e300;
final double[] v = new double[] {s, s};
Assertions.assertEquals(Math.sqrt(2) * s, SafeNorm.value(v));
}
@Test
- public void testOne3D() {
+ void testOne3D() {
final double s = 1;
final double[] v = new double[] {s, s, s};
Assertions.assertEquals(Math.sqrt(3), SafeNorm.value(v));
}
@Test
- public void testUnit3D() {
- Assertions.assertEquals(1, SafeNorm.value(new double[] {1, 0, 0}), 0d);
- Assertions.assertEquals(1, SafeNorm.value(new double[] {0, 1, 0}), 0d);
- Assertions.assertEquals(1, SafeNorm.value(new double[] {0, 0, 1}), 0d);
+ void testUnit3D() {
+ Assertions.assertEquals(1, SafeNorm.value(new double[] {1, 0, 0}));
+ Assertions.assertEquals(1, SafeNorm.value(new double[] {0, 1, 0}));
+ Assertions.assertEquals(1, SafeNorm.value(new double[] {0, 0, 1}));
}
@Test
- public void testSimple() {
+ void testSimple() {
final double[] v = new double[] {-0.9, 8.7, -6.5, -4.3, -2.1, 0, 1.2, 3.4, -5.6, 7.8, 9.0};
final double expected = direct(v);
Assertions.assertEquals(expected, SafeNorm.value(v));
}
@Test
- public void testZero() {
+ void testZero() {
final double[] v = new double[] {0, 0, 0, 0, 0};
Assertions.assertEquals(0d, SafeNorm.value(v));
}
@Test
- public void testTinyAndSmallNormal() {
+ void testTinyAndSmallNormal() {
// Ensure the sum of the squared values for 'normal' values (1e-19*1e-19)
// is less than largest tiny value (1e-20)
final double[] v = new double[] {1e-20, 1e-19};
diff --git a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/FactorialDouble.java b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/FactorialDouble.java
index 32cd5d1..f3c34dc 100644
--- a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/FactorialDouble.java
+++ b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/FactorialDouble.java
@@ -54,9 +54,14 @@
}
final int beginCopy = 2;
- final int endCopy = cache == null || cache.length <= beginCopy ?
- beginCopy : cache.length <= numValues ?
- cache.length : numValues;
+ int endCopy;
+ if (cache == null || cache.length <= beginCopy) {
+ endCopy = beginCopy;
+ } else if (cache.length <= numValues) {
+ endCopy = cache.length;
+ } else {
+ endCopy = numValues;
+ }
// Copy available values.
for (int i = beginCopy; i < endCopy; i++) {
diff --git a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogFactorial.java b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogFactorial.java
index 00b6813..76af8a2 100644
--- a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogFactorial.java
+++ b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogFactorial.java
@@ -52,9 +52,14 @@
logFactorials = new double[numValues];
final int beginCopy = 2;
- final int endCopy = cache == null || cache.length <= beginCopy ?
- beginCopy : cache.length <= numValues ?
- cache.length : numValues;
+ int endCopy;
+ if (cache == null || cache.length <= beginCopy) {
+ endCopy = beginCopy;
+ } else if (cache.length <= numValues) {
+ endCopy = cache.length;
+ } else {
+ endCopy = numValues;
+ }
// Copy available values.
for (int i = beginCopy; i < endCopy; i++) {
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDoubleTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDoubleTest.java
index 1a17721..367aa50 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDoubleTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDoubleTest.java
@@ -22,15 +22,15 @@
/**
* Test cases for the {@link BinomialCoefficient} class.
*/
-public class BinomialCoefficientDoubleTest {
+class BinomialCoefficientDoubleTest {
/** Verify that b(0,0) = 1 */
@Test
- public void test0Choose0() {
- Assertions.assertEquals(1d, BinomialCoefficientDouble.value(0, 0), 0);
+ void test0Choose0() {
+ Assertions.assertEquals(1d, BinomialCoefficientDouble.value(0, 0));
}
@Test
- public void testBinomialCoefficient() {
+ void testBinomialCoefficient() {
final long[] bcoef5 = {1, 5, 10, 10, 5, 1};
final long[] bcoef6 = {1, 6, 15, 20, 15, 6, 1};
@@ -59,21 +59,21 @@
}
@Test
- public void testBinomialCoefficientFail1() {
+ void testBinomialCoefficientFail1() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficientDouble.value(4, 5)
);
}
@Test
- public void testBinomialCoefficientFail2() {
+ void testBinomialCoefficientFail2() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficientDouble.value(-1, -2)
);
}
@Test
- public void testBinomialCoefficientFail3() {
+ void testBinomialCoefficientFail3() {
final double x = BinomialCoefficientDouble.value(1030, 515);
Assertions.assertTrue(Double.isInfinite(x), "expecting infinite binomial coefficient");
}
@@ -83,7 +83,7 @@
* JIRA: MATH-241
*/
@Test
- public void testBinomialCoefficientLarge() throws Exception {
+ void testBinomialCoefficientLarge() throws Exception {
// This tests all legal and illegal values for n <= 200.
for (int n = 0; n <= 200; n++) {
for (int k = 0; k <= n; k++) {
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientTest.java
index 8080f80..a843fcb 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientTest.java
@@ -27,18 +27,18 @@
/**
* Test cases for the {@link BinomialCoefficient} class.
*/
-public class BinomialCoefficientTest {
+class BinomialCoefficientTest {
/** Cached binomial coefficients. */
private static final List<Map<Integer, Long>> binomialCache = new ArrayList<>();
/** Verify that b(0,0) = 1 */
@Test
- public void test0Choose0() {
+ void test0Choose0() {
Assertions.assertEquals(1, BinomialCoefficient.value(0, 0));
}
@Test
- public void testBinomialCoefficient() {
+ void testBinomialCoefficient() {
final long[] bcoef5 = {1, 5, 10, 10, 5, 1};
final long[] bcoef6 = {1, 6, 15, 20, 15, 6, 1};
@@ -72,28 +72,28 @@
}
@Test
- public void testBinomialCoefficientKLargerThanN() {
+ void testBinomialCoefficientKLargerThanN() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficient.value(4, 5)
);
}
@Test
- public void testBinomialCoefficientNegativeN() {
+ void testBinomialCoefficientNegativeN() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficient.value(-1, 1)
);
}
@Test
- public void testBinomialCoefficientNegativeK() {
+ void testBinomialCoefficientNegativeK() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficient.value(10, -1)
);
}
@Test
- public void testBinomialCoefficientNAbove66ResultOverflow() {
+ void testBinomialCoefficientNAbove66ResultOverflow() {
Assertions.assertThrows(ArithmeticException.class,
() -> BinomialCoefficient.value(67, 30)
);
@@ -104,7 +104,7 @@
* JIRA: MATH-241
*/
@Test
- public void testBinomialCoefficientLarge() throws Exception {
+ void testBinomialCoefficientLarge() throws Exception {
// This tests all legal and illegal values for n <= 200.
for (int n = 0; n <= 200; n++) {
for (int k = 0; k <= n; k++) {
@@ -144,21 +144,21 @@
}
@Test
- public void checkNLessThanOne() {
+ void checkNLessThanOne() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficient.checkBinomial(-1, -2)
);
}
@Test
- public void checkKGreaterThanN() {
+ void checkKGreaterThanN() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficient.checkBinomial(4, 5)
);
}
@Test
- public void testCheckBinomial3() {
+ void testCheckBinomial3() {
// OK (no exception thrown)
BinomialCoefficient.checkBinomial(5, 4);
}
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/CombinationsTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/CombinationsTest.java
index ca3ead1..b26f862 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/CombinationsTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/CombinationsTest.java
@@ -26,23 +26,23 @@
/**
* Tests for the {@link Combinations} class.
*/
-public class CombinationsTest {
+class CombinationsTest {
@Test
- public void testGetN() {
+ void testGetN() {
final int n = 5;
final int k = 3;
Assertions.assertEquals(n, Combinations.of(n, k).getN());
}
@Test
- public void testGetK() {
+ void testGetK() {
final int n = 5;
final int k = 3;
Assertions.assertEquals(k, Combinations.of(n, k).getK());
}
@Test
- public void testLexicographicIterator() {
+ void testLexicographicIterator() {
checkLexicographicIterator(5, 3);
checkLexicographicIterator(6, 4);
checkLexicographicIterator(8, 2);
@@ -57,14 +57,14 @@
}
@Test
- public void testLexicographicIteratorThrows() {
+ void testLexicographicIteratorThrows() {
checkLexicographicIteratorThrows(2, 1);
// Only 1 combination
checkLexicographicIteratorThrows(1, 1);
}
@Test
- public void testLexicographicComparatorWrongIterate1() {
+ void testLexicographicComparatorWrongIterate1() {
final int n = 5;
final int k = 3;
final Comparator<int[]> comp = Combinations.of(n, k).comparator();
@@ -74,7 +74,7 @@
}
@Test
- public void testLexicographicComparatorWrongIterate2() {
+ void testLexicographicComparatorWrongIterate2() {
final int n = 5;
final int k = 3;
final Comparator<int[]> comp = Combinations.of(n, k).comparator();
@@ -84,7 +84,7 @@
}
@Test
- public void testLexicographicComparatorWrongIterate3() {
+ void testLexicographicComparatorWrongIterate3() {
final int n = 5;
final int k = 3;
final Comparator<int[]> comp = Combinations.of(n, k).comparator();
@@ -94,7 +94,7 @@
}
@Test
- public void testLexicographicComparatorWrongIterate4() {
+ void testLexicographicComparatorWrongIterate4() {
final int n = 5;
final int k = 3;
final Comparator<int[]> comp = Combinations.of(n, k).comparator();
@@ -104,7 +104,7 @@
}
@Test
- public void testLexicographicComparator() {
+ void testLexicographicComparator() {
final int n = 5;
final int k = 3;
final Comparator<int[]> comp = Combinations.of(n, k).comparator();
@@ -120,7 +120,7 @@
* Check that iterates can be passed unsorted.
*/
@Test
- public void testLexicographicComparatorUnsorted() {
+ void testLexicographicComparatorUnsorted() {
final int n = 5;
final int k = 3;
final Comparator<int[]> comp = Combinations.of(n, k).comparator();
@@ -133,7 +133,7 @@
}
@Test
- public void testEmptyCombination() {
+ void testEmptyCombination() {
final Iterator<int[]> iter = Combinations.of(12345, 0).iterator();
Assertions.assertTrue(iter.hasNext());
final int[] c = iter.next();
@@ -142,7 +142,7 @@
}
@Test
- public void testFullSetCombination() {
+ void testFullSetCombination() {
final int n = 67;
final Iterator<int[]> iter = Combinations.of(n, n).iterator();
Assertions.assertTrue(iter.hasNext());
@@ -215,28 +215,28 @@
}
@Test
- public void testBinomialCoefficientKLargerThanN() {
+ void testBinomialCoefficientKLargerThanN() {
Assertions.assertThrows(CombinatoricsException.class,
() -> Combinations.of(4, 5)
);
}
@Test
- public void testBinomialCoefficientNegativeN() {
+ void testBinomialCoefficientNegativeN() {
Assertions.assertThrows(CombinatoricsException.class,
() -> Combinations.of(-1, 1)
);
}
@Test
- public void testBinomialCoefficientNegativeK() {
+ void testBinomialCoefficientNegativeK() {
Assertions.assertThrows(CombinatoricsException.class,
() -> Combinations.of(10, -1)
);
}
@Test
- public void testBinomialCoefficientKAboveN() {
+ void testBinomialCoefficientKAboveN() {
Assertions.assertThrows(CombinatoricsException.class,
() -> Combinations.of(10, 20)
);
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialDoubleTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialDoubleTest.java
index c4075ea..fa4824e 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialDoubleTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialDoubleTest.java
@@ -22,50 +22,50 @@
/**
* Test cases for the {@link FactorialDouble} class.
*/
-public class FactorialDoubleTest {
+class FactorialDoubleTest {
@Test
- public void testFactorialZero() {
- Assertions.assertEquals(1, FactorialDouble.create().value(0), 0d, "0!");
+ void testFactorialZero() {
+ Assertions.assertEquals(1, FactorialDouble.create().value(0), "0!");
}
@Test
- public void testFactorialDirect() {
+ void testFactorialDirect() {
for (int i = 1; i < 21; i++) {
Assertions.assertEquals(
- factorialDirect(i), FactorialDouble.create().value(i), 0d, i + "!");
+ factorialDirect(i), FactorialDouble.create().value(i), i + "!");
}
}
@Test
- public void testLargestFactorialDouble() {
+ void testLargestFactorialDouble() {
final int n = 170;
- Assertions.assertTrue(
- Double.POSITIVE_INFINITY != FactorialDouble.create().value(n), n + "!");
+ Assertions.assertNotEquals(
+ Double.POSITIVE_INFINITY, FactorialDouble.create().value(n), () -> n + "!");
}
@Test
- public void testFactorialDoubleTooLarge() {
+ void testFactorialDoubleTooLarge() {
final int n = 171;
Assertions.assertEquals(
- Double.POSITIVE_INFINITY, FactorialDouble.create().value(n), 0d, n + "!");
+ Double.POSITIVE_INFINITY, FactorialDouble.create().value(n), () -> n + "!");
}
@Test
- public void testNonPositiveArgumentWithCache() {
+ void testNonPositiveArgumentWithCache() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> FactorialDouble.create().withCache(-1)
);
}
@Test
- public void testNonPositiveArgument() {
+ void testNonPositiveArgument() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> FactorialDouble.create().value(-1)
);
}
@Test
- public void testCompareDirectWithoutCache() {
+ void testCompareDirectWithoutCache() {
// This test shows that delegating to the "Gamma" class will also lead to a
// less accurate result.
@@ -80,7 +80,7 @@
}
@Test
- public void testCompareDirectWithCache() {
+ void testCompareDirectWithCache() {
final int max = 100;
final FactorialDouble f = FactorialDouble.create().withCache(max);
@@ -92,25 +92,25 @@
}
@Test
- public void testCacheIncrease() {
+ void testCacheIncrease() {
final int max = 100;
final FactorialDouble f1 = FactorialDouble.create().withCache(max);
final FactorialDouble f2 = f1.withCache(2 * max);
final int val = max + max / 2;
- Assertions.assertEquals(f1.value(val), f2.value(val), 0d);
+ Assertions.assertEquals(f1.value(val), f2.value(val));
}
@Test
- public void testZeroCache() {
+ void testZeroCache() {
// Ensure that no exception is thrown.
final FactorialDouble f = FactorialDouble.create().withCache(0);
- Assertions.assertEquals(1, f.value(0), 0d);
- Assertions.assertEquals(1, f.value(1), 0d);
+ Assertions.assertEquals(1, f.value(0));
+ Assertions.assertEquals(1, f.value(1));
}
@Test
- public void testUselessCache() {
+ void testUselessCache() {
Assertions.assertDoesNotThrow(() -> {
LogFactorial.create().withCache(1);
LogFactorial.create().withCache(2);
@@ -118,13 +118,13 @@
}
@Test
- public void testCacheDecrease() {
+ void testCacheDecrease() {
final int max = 100;
final FactorialDouble f1 = FactorialDouble.create().withCache(max);
final FactorialDouble f2 = f1.withCache(max / 2);
final int val = max / 4;
- Assertions.assertEquals(f1.value(val), f2.value(val), 0d);
+ Assertions.assertEquals(f1.value(val), f2.value(val));
}
/**
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialTest.java
index 4dba998..689739d 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialTest.java
@@ -22,28 +22,28 @@
/**
* Test cases for the {@link Factorial} class.
*/
-public class FactorialTest {
+class FactorialTest {
@Test
- public void testFactorialZero() {
+ void testFactorialZero() {
Assertions.assertEquals(1, Factorial.value(0), "0!");
}
@Test
- public void testFactorial() {
+ void testFactorial() {
for (int i = 1; i < 21; i++) {
Assertions.assertEquals(factorial(i), Factorial.value(i), i + "!");
}
}
@Test
- public void testPrecondition1() {
+ void testPrecondition1() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> Factorial.value(-1)
);
}
@Test
- public void testPrecondition2() {
+ void testPrecondition2() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> Factorial.value(21)
);
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficientTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficientTest.java
index e8c20b6..88f05a1 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficientTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficientTest.java
@@ -22,15 +22,15 @@
/**
* Test cases for the {@link LogBinomialCoefficient} class.
*/
-public class LogBinomialCoefficientTest {
+class LogBinomialCoefficientTest {
/** Verify that b(0,0) = 1 */
@Test
- public void test0Choose0() {
- Assertions.assertEquals(0d, LogBinomialCoefficient.value(0, 0), 0);
+ void test0Choose0() {
+ Assertions.assertEquals(0d, LogBinomialCoefficient.value(0, 0));
}
@Test
- public void testBinomialCoefficient() {
+ void testBinomialCoefficient() {
final long[] bcoef5 = {1, 5, 10, 10, 5, 1};
final long[] bcoef6 = {1, 6, 15, 20, 15, 6, 1};
@@ -54,14 +54,14 @@
}
@Test
- public void testBinomialCoefficientFail1() {
+ void testBinomialCoefficientFail1() {
Assertions.assertThrows(CombinatoricsException.class,
() -> LogBinomialCoefficient.value(4, 5)
);
}
@Test
- public void testBinomialCoefficientFail2() {
+ void testBinomialCoefficientFail2() {
Assertions.assertThrows(CombinatoricsException.class,
() -> LogBinomialCoefficient.value(-1, -2)
);
@@ -72,7 +72,7 @@
* JIRA: MATH-241
*/
@Test
- public void testBinomialCoefficientLarge() throws Exception {
+ void testBinomialCoefficientLarge() throws Exception {
// This tests all legal and illegal values for n <= 200.
for (int n = 0; n <= 200; n++) {
for (int k = 0; k <= n; k++) {
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogFactorialTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogFactorialTest.java
index 291c557..0367d1f 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogFactorialTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogFactorialTest.java
@@ -24,16 +24,16 @@
/**
* Test cases for the {@link LogFactorial} class.
*/
-public class LogFactorialTest {
+class LogFactorialTest {
@Test
- public void testNonPositiveArgumentWithCache() {
+ void testNonPositiveArgumentWithCache() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> LogFactorial.create().withCache(-1)
);
}
@Test
- public void testNonPositiveArgument() {
+ void testNonPositiveArgument() {
final LogFactorial f = LogFactorial.create();
Assertions.assertThrows(IllegalArgumentException.class,
() -> f.value(-1)
@@ -41,7 +41,7 @@
}
@Test
- public void testDelegation() {
+ void testDelegation() {
final LogFactorial f = LogFactorial.create();
// Starting at 21 because for smaller arguments, there is no delegation to the
@@ -54,7 +54,7 @@
}
@Test
- public void testCompareDirectWithoutCache() {
+ void testCompareDirectWithoutCache() {
// This test shows that delegating to the "Gamma" class leads to difference
// wrt the "direct" computation.
@@ -69,7 +69,7 @@
}
@Test
- public void testCompareDirectWithCache() {
+ void testCompareDirectWithCache() {
final int max = 1000;
final LogFactorial f = LogFactorial.create().withCache(max);
@@ -81,40 +81,45 @@
}
@Test
- public void testZeroCache() {
+ void testZeroCache() {
// Ensure that no exception is thrown.
final LogFactorial f = LogFactorial.create().withCache(0);
- Assertions.assertEquals(0, f.value(0), 0d);
- Assertions.assertEquals(0, f.value(1), 0d);
+ Assertions.assertEquals(0, f.value(0));
+ Assertions.assertEquals(0, f.value(1));
}
@Test
- public void testUselessCache() {
+ void testUselessCache() {
// Ensure that no exception is thrown.
- LogFactorial.create().withCache(1);
- LogFactorial.create().withCache(2);
+ LogFactorial f = LogFactorial.create().withCache(1);
+ Assertions.assertEquals(0, f.value(0));
+ Assertions.assertEquals(0, f.value(1));
+
+ f = LogFactorial.create().withCache(2);
+ Assertions.assertEquals(0, f.value(0));
+ Assertions.assertEquals(0, f.value(1));
}
@Test
- public void testCacheIncrease() {
+ void testCacheIncrease() {
final int max = 100;
final LogFactorial f1 = LogFactorial.create().withCache(max);
final LogFactorial f2 = f1.withCache(2 * max);
final int val = max + max / 2;
final double expected = logFactorial(val);
- Assertions.assertEquals(expected, f2.value(val), 0d);
+ Assertions.assertEquals(expected, f2.value(val));
}
@Test
- public void testCacheDecrease() {
+ void testCacheDecrease() {
final int max = 100;
final LogFactorial f1 = LogFactorial.create().withCache(max);
final LogFactorial f2 = f1.withCache(max / 2);
final int val = max / 4;
final double expected = logFactorial(val);
- Assertions.assertEquals(expected, f2.value(val), 0d);
+ Assertions.assertEquals(expected, f2.value(val));
}
// Direct implementation.
diff --git a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
index 3c43298..ffafec5 100644
--- a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
+++ b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
@@ -25,7 +25,7 @@
/**
* Tests for {@link ComplexUtils}.
*/
-public class ComplexUtilsTest {
+class ComplexUtilsTest {
private static final double inf = Double.POSITIVE_INFINITY;
private static final double negInf = Double.NEGATIVE_INFINITY;
@@ -237,7 +237,7 @@
// CHECKSTYLE: resume MethodLength
@Test
- public void testPolar2Complex() {
+ void testPolar2Complex() {
TestUtils.assertEquals(Complex.ONE, ComplexUtils.polar2Complex(1, 0), 10e-12);
TestUtils.assertEquals(Complex.ZERO, ComplexUtils.polar2Complex(0, 1), 10e-12);
TestUtils.assertEquals(Complex.ZERO, ComplexUtils.polar2Complex(0, -1), 10e-12);
@@ -312,42 +312,42 @@
}
@Test
- public void testPolar2ComplexIllegalModulus() {
+ void testPolar2ComplexIllegalModulus() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.polar2Complex(-1, 0)
);
}
@Test
- public void testPolar2ComplexIllegalModulus1D() {
+ void testPolar2ComplexIllegalModulus1D() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.polar2Complex(new double[]{0, -1, 2}, new double[]{0, 1, 2})
);
}
@Test
- public void testPolar2ComplexIllegalModulus2D() {
+ void testPolar2ComplexIllegalModulus2D() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.polar2Complex(new double[][]{{0, 2, 2}, {0, -1, 2}}, new double[][]{{0, 1, 2}, {0, 1, 2}})
);
}
@Test
- public void testPolar2ComplexIllegalModulus3D() {
+ void testPolar2ComplexIllegalModulus3D() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.polar2Complex(new double[][][]{{{0, 2, 2}}, {{0, -1, 2}}}, new double[][][]{{{0, 1, 2}}, {{0, 1, 2}}})
);
}
@Test
- public void testPolar2ComplexNaN() {
+ void testPolar2ComplexNaN() {
TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(nan, 1));
TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, nan));
TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(nan, nan));
}
@Test
- public void testPolar2ComplexInf() {
+ void testPolar2ComplexInf() {
TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, inf));
TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, negInf));
TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(inf, inf));
@@ -360,19 +360,19 @@
}
@Test
- public void testCExtract() {
+ void testCExtract() {
final double[] real = new double[] {negInf, -123.45, 0, 1, 234.56, pi, inf};
final Complex[] complex = ComplexUtils.real2Complex(real);
for (int i = 0; i < real.length; i++) {
- Assertions.assertEquals(real[i], complex[i].getReal(), 0d);
+ Assertions.assertEquals(real[i], complex[i].getReal());
}
}
// EXTRACTION METHODS
@Test
- public void testExtractionMethods() {
+ void testExtractionMethods() {
setArrays();
// Extract complex from real double array, index 3
TestUtils.assertSame(Complex.ofCartesian(3, 0), ComplexUtils.extractComplexFromRealArray(d, 3));
@@ -408,7 +408,7 @@
// REAL <-> COMPLEX
@Test
- public void testRealToComplex() {
+ void testRealToComplex() {
setArrays();
// Real double to complex, whole array
TestUtils.assertEquals(msg, cr, ComplexUtils.real2Complex(d), Math.ulp(1.0));
@@ -428,7 +428,7 @@
}
@Test
- public void testComplexToReal() {
+ void testComplexToReal() {
setArrays();
// Real complex to double, whole array
Assertions.assertArrayEquals(sr, ComplexUtils.complex2Real(c), Math.ulp(1.0), msg);
@@ -451,7 +451,7 @@
// IMAGINARY <-> COMPLEX
@Test
- public void testImaginaryToComplex() {
+ void testImaginaryToComplex() {
setArrays();
// Imaginary double to complex, whole array
TestUtils.assertEquals(msg, ci, ComplexUtils.imaginary2Complex(d), Math.ulp(1.0));
@@ -469,7 +469,7 @@
}
@Test
- public void testComplexToImaginary() {
+ void testComplexToImaginary() {
setArrays();
// Imaginary complex to double, whole array
Assertions.assertArrayEquals(si, ComplexUtils.complex2Imaginary(c), Math.ulp(1.0), msg);
@@ -492,147 +492,147 @@
// INTERLEAVED <-> COMPLEX
@Test
- public void testComplex2InterleavedIllegalIndex2Dmin() {
+ void testComplex2InterleavedIllegalIndex2Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c2d, -1)
);
}
@Test
- public void testComplex2InterleavedIllegalIndex2Dmax() {
+ void testComplex2InterleavedIllegalIndex2Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c2d, 2)
);
}
@Test
- public void testComplex2InterleavedIllegalIndex3Dmin() {
+ void testComplex2InterleavedIllegalIndex3Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c3d, -1)
);
}
@Test
- public void testComplex2InterleavedIllegalIndex3Dmax() {
+ void testComplex2InterleavedIllegalIndex3Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c3d, 3)
);
}
@Test
- public void testComplex2InterleavedIllegalIndex4Dmin() {
+ void testComplex2InterleavedIllegalIndex4Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c4d, -1)
);
}
@Test
- public void testComplex2InterleavedIllegalIndex4Dmax() {
+ void testComplex2InterleavedIllegalIndex4Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c4d, 4)
);
}
@Test
- public void testComplex2InterleavedFloatIllegalIndex2Dmin() {
+ void testComplex2InterleavedFloatIllegalIndex2Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2InterleavedFloat(c2d, -1)
);
}
@Test
- public void testComplex2InterleavedFloatIllegalIndex2Dmax() {
+ void testComplex2InterleavedFloatIllegalIndex2Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2InterleavedFloat(c2d, 2)
);
}
@Test
- public void testComplex2InterleavedFloatIllegalIndex3Dmin() {
+ void testComplex2InterleavedFloatIllegalIndex3Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2InterleavedFloat(c3d, -1)
);
}
@Test
- public void testComplex2InterleavedFloatIllegalIndex3Dmax() {
+ void testComplex2InterleavedFloatIllegalIndex3Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2InterleavedFloat(c3d, 3)
);
}
@Test
- public void testInterleaved2ComplexIllegalIndex2Dmin() {
+ void testInterleaved2ComplexIllegalIndex2Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(di2d0, -1)
);
}
@Test
- public void testInterleaved2ComplexIllegalIndex2Dmax() {
+ void testInterleaved2ComplexIllegalIndex2Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(di2d0, 2)
);
}
@Test
- public void testInterleaved2ComplexIllegalIndex3Dmin() {
+ void testInterleaved2ComplexIllegalIndex3Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(di3d0, -1)
);
}
@Test
- public void testInterleaved2ComplexIllegalIndex3Dmax() {
+ void testInterleaved2ComplexIllegalIndex3Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(di3d0, 3)
);
}
@Test
- public void testInterleaved2ComplexIllegalIndex4Dmin() {
+ void testInterleaved2ComplexIllegalIndex4Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(di4d0, -1)
);
}
@Test
- public void testInterleaved2ComplexIllegalIndex4Dmax() {
+ void testInterleaved2ComplexIllegalIndex4Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(di4d0, 4)
);
}
@Test
- public void testInterleaved2ComplexFloatIllegalIndex2Dmin() {
+ void testInterleaved2ComplexFloatIllegalIndex2Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(fi2d0, -1)
);
}
@Test
- public void testInterleaved2ComplexFloatIllegalIndex2Dmax() {
+ void testInterleaved2ComplexFloatIllegalIndex2Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(fi2d0, 2)
);
}
@Test
- public void testInterleaved2ComplexFloatIllegalIndex3Dmin() {
+ void testInterleaved2ComplexFloatIllegalIndex3Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(fi3d0, -1)
);
}
@Test
- public void testInterleaved2ComplexFloatIllegalIndex3Dmax() {
+ void testInterleaved2ComplexFloatIllegalIndex3Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(fi3d0, 3)
);
}
@Test
- public void testInterleavedToComplex() {
+ void testInterleavedToComplex() {
setArrays();
// Interleaved double to complex, whole array
TestUtils.assertEquals(msg, c, ComplexUtils.interleaved2Complex(di), Math.ulp(1.0));
@@ -667,7 +667,7 @@
}
@Test
- public void testComplexToInterleaved() {
+ void testComplexToInterleaved() {
setArrays();
Assertions.assertArrayEquals(di, ComplexUtils.complex2Interleaved(c), Math.ulp(1.0), msg);
// Interleaved complex to float, whole array
@@ -703,7 +703,7 @@
// SPLIT TO COMPLEX
@Test
- public void testSplit2Complex() {
+ void testSplit2Complex() {
setArrays();
// Split double to complex, whole array
TestUtils.assertEquals(msg, c, ComplexUtils.split2Complex(sr, si), Math.ulp(1.0));
@@ -718,7 +718,7 @@
// INITIALIZATION METHODS
@Test
- public void testInitialize() {
+ void testInitialize() {
Complex[] complexes = new Complex[10];
ComplexUtils.initialize(complexes);
for (Complex cc : complexes) {
@@ -727,7 +727,7 @@
}
@Test
- public void testInitialize2d() {
+ void testInitialize2d() {
Complex[][] complexes = new Complex[10][10];
ComplexUtils.initialize(complexes);
for (Complex[] c1 : complexes) {
@@ -738,7 +738,7 @@
}
@Test
- public void testInitialize3d() {
+ void testInitialize3d() {
Complex[][][] complexes = new Complex[10][10][10];
ComplexUtils.initialize(complexes);
for (Complex[][] c2 : complexes) {
@@ -751,22 +751,22 @@
}
@Test
- public void testAbs() {
+ void testAbs() {
setArrays();
double[] observed = ComplexUtils.abs(c);
Assertions.assertEquals(c.length, observed.length);
for (int i = 0; i < c.length; i++) {
- Assertions.assertEquals(c[i].abs(), observed[i], 0);
+ Assertions.assertEquals(c[i].abs(), observed[i]);
}
}
@Test
- public void testArg() {
+ void testArg() {
setArrays();
double[] observed = ComplexUtils.arg(c);
Assertions.assertEquals(c.length, observed.length);
for (int i = 0; i < c.length; i++) {
- Assertions.assertEquals(c[i].arg(), observed[i], 0);
+ Assertions.assertEquals(c[i].arg(), observed[i]);
}
}
}
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CReferenceTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CReferenceTest.java
index 6eab130..cf72442 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CReferenceTest.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CReferenceTest.java
@@ -36,7 +36,7 @@
* @see <a href="http://www.open-std.org/JTC1/SC22/WG14/www/standards">
* ISO/IEC 9899 - Programming languages - C</a>
*/
-public class CReferenceTest {
+class CReferenceTest {
/** Positive zero bits. */
private static final long POSITIVE_ZERO_DOUBLE_BITS = Double.doubleToRawLongBits(+0.0);
/** Negative zero bits. */
@@ -266,72 +266,72 @@
}
@Test
- public void testAcos() {
+ void testAcos() {
assertOperation("acos", Complex::acos, 2);
}
@Test
- public void testAcosh() {
+ void testAcosh() {
assertOperation("acosh", Complex::acosh, 2);
}
@Test
- public void testAsinh() {
+ void testAsinh() {
// Odd function: negative real cases defined by positive real cases
assertOperation("asinh", Complex::asinh, 3);
}
@Test
- public void testAtanh() {
+ void testAtanh() {
// Odd function: negative real cases defined by positive real cases
assertOperation("atanh", Complex::atanh, 1);
}
@Test
- public void testCosh() {
+ void testCosh() {
// Even function: negative real cases defined by positive real cases
assertOperation("cosh", Complex::cosh, 2);
}
@Test
- public void testSinh() {
+ void testSinh() {
// Odd function: negative real cases defined by positive real cases
assertOperation("sinh", Complex::sinh, 2);
}
@Test
- public void testTanh() {
+ void testTanh() {
// Odd function: negative real cases defined by positive real cases
assertOperation("tanh", Complex::tanh, 2);
}
@Test
- public void testExp() {
+ void testExp() {
assertOperation("exp", Complex::exp, 2);
}
@Test
- public void testLog() {
+ void testLog() {
assertOperation("log", Complex::log, 1);
}
@Test
- public void testSqrt() {
+ void testSqrt() {
assertOperation("sqrt", Complex::sqrt, 1);
}
@Test
- public void testMultiply() {
+ void testMultiply() {
assertBiOperation("multiply", Complex::multiply, 0);
}
@Test
- public void testDivide() {
+ void testDivide() {
assertBiOperation("divide", Complex::divide, 7);
}
@Test
- public void testPowComplex() {
+ void testPowComplex() {
assertBiOperation("pow", Complex::pow, 9);
}
}
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CStandardTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CStandardTest.java
index cd9b47c..c4cf9be 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CStandardTest.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CStandardTest.java
@@ -37,7 +37,7 @@
* @see <a href="http://www.open-std.org/JTC1/SC22/WG14/www/standards">
* ISO/IEC 9899 - Programming languages - C</a>
*/
-public class CStandardTest {
+class CStandardTest {
private static final double inf = Double.POSITIVE_INFINITY;
private static final double negInf = Double.NEGATIVE_INFINITY;
@@ -724,7 +724,7 @@
* ISO C Standard G.5 (4).
*/
@Test
- public void testMultiply() {
+ void testMultiply() {
final ArrayList<Complex> infinites = createInfinites();
final ArrayList<Complex> nonZeroFinites = createNonZeroFinites();
final ArrayList<Complex> zeroFinites = createZeroFinites();
@@ -783,7 +783,7 @@
* ISO C Standard G.5 (4).
*/
@Test
- public void testDivide() {
+ void testDivide() {
final ArrayList<Complex> infinites = createInfinites();
final ArrayList<Complex> nonZeroFinites = createNonZeroFinites();
final ArrayList<Complex> zeroFinites = createZeroFinites();
@@ -850,7 +850,7 @@
* ISO C Standard G.6 (3).
*/
@Test
- public void testSqrt1() {
+ void testSqrt1() {
assertComplex(complex(-2.0, 0.0).sqrt(), complex(0.0, Math.sqrt(2)));
assertComplex(complex(-2.0, -0.0).sqrt(), complex(0.0, -Math.sqrt(2)));
}
@@ -859,7 +859,7 @@
* ISO C Standard G.6 (7).
*/
@Test
- public void testImplicitTrig() {
+ void testImplicitTrig() {
final UniformRandomProvider rng = RandomSource.create(RandomSource.SPLIT_MIX_64);
for (int i = 0; i < 100; i++) {
final double re = next(rng);
@@ -890,7 +890,7 @@
* Functionality is defined by ISO C Standard F.9.4.3 hypot function.
*/
@Test
- public void testAbs() {
+ void testAbs() {
Assertions.assertEquals(inf, complex(inf, nan).abs());
Assertions.assertEquals(inf, complex(negInf, nan).abs());
final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP);
@@ -975,7 +975,7 @@
* ISO C Standard G.6.1.1.
*/
@Test
- public void testAcos() {
+ void testAcos() {
final UnaryOperator<Complex> operation = Complex::acos;
assertConjugateEquality(operation);
assertComplex(Complex.ZERO, operation, piTwoNegZero);
@@ -1012,7 +1012,7 @@
* Complex math functions cacosh and ctanh</a>
*/
@Test
- public void testAcosh() {
+ void testAcosh() {
final UnaryOperator<Complex> operation = Complex::acosh;
assertConjugateEquality(operation);
assertComplex(Complex.ZERO, operation, zeroPiTwo);
@@ -1046,7 +1046,7 @@
* ISO C Standard G.6.2.2.
*/
@Test
- public void testAsinh() {
+ void testAsinh() {
final UnaryOperator<Complex> operation = Complex::asinh;
final FunctionType type = FunctionType.ODD;
assertConjugateEquality(operation);
@@ -1075,7 +1075,7 @@
* ISO C Standard G.6.2.3.
*/
@Test
- public void testAtanh() {
+ void testAtanh() {
final UnaryOperator<Complex> operation = Complex::atanh;
final FunctionType type = FunctionType.ODD;
assertConjugateEquality(operation);
@@ -1106,7 +1106,7 @@
* ISO C Standard G.6.2.4.
*/
@Test
- public void testCosh() {
+ void testCosh() {
final UnaryOperator<Complex> operation = Complex::cosh;
final FunctionType type = FunctionType.EVEN;
assertConjugateEquality(operation);
@@ -1137,7 +1137,7 @@
* ISO C Standard G.6.2.5.
*/
@Test
- public void testSinh() {
+ void testSinh() {
final UnaryOperator<Complex> operation = Complex::sinh;
final FunctionType type = FunctionType.ODD;
assertConjugateEquality(operation);
@@ -1172,7 +1172,7 @@
* Complex math functions cacosh and ctanh</a>
*/
@Test
- public void testTanh() {
+ void testTanh() {
final UnaryOperator<Complex> operation = Complex::tanh;
final FunctionType type = FunctionType.ODD;
assertConjugateEquality(operation);
@@ -1202,7 +1202,7 @@
* ISO C Standard G.6.3.1.
*/
@Test
- public void testExp() {
+ void testExp() {
final UnaryOperator<Complex> operation = Complex::exp;
assertConjugateEquality(operation);
assertComplex(Complex.ZERO, operation, oneZero);
@@ -1235,7 +1235,7 @@
* ISO C Standard G.6.3.2.
*/
@Test
- public void testLog() {
+ void testLog() {
final UnaryOperator<Complex> operation = Complex::log;
assertConjugateEquality(operation);
assertComplex(negZeroZero, operation, negInfPi);
@@ -1268,7 +1268,7 @@
* has no effect on infinite or nan.
*/
@Test
- public void testLog10() {
+ void testLog10() {
final UnaryOperator<Complex> operation = Complex::log10;
assertConjugateEquality(operation);
assertComplex(negZeroZero, operation, negInfPi);
@@ -1300,7 +1300,7 @@
* ISO C Standard G.6.4.2.
*/
@Test
- public void testSqrt() {
+ void testSqrt() {
final UnaryOperator<Complex> operation = Complex::sqrt;
assertConjugateEquality(operation);
assertComplex(negZeroZero, operation, Complex.ZERO);
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexEdgeCaseTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexEdgeCaseTest.java
index 4f76f4d..95a3952 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexEdgeCaseTest.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexEdgeCaseTest.java
@@ -36,7 +36,7 @@
* @see <a href="http://www.open-std.org/JTC1/SC22/WG14/www/standards">
* ISO/IEC 9899 - Programming languages - C</a>
*/
-public class ComplexEdgeCaseTest {
+class ComplexEdgeCaseTest {
private static final double inf = Double.POSITIVE_INFINITY;
private static final double nan = Double.NaN;
@@ -129,7 +129,7 @@
}
@Test
- public void testAcos() {
+ void testAcos() {
// acos(z) = (pi / 2) + i ln(iz + sqrt(1 - z^2))
final String name = "acos";
final UnaryOperator<Complex> operation = Complex::acos;
@@ -165,7 +165,7 @@
// acosh is defined by acos so is not tested
@Test
- public void testAsin() {
+ void testAsin() {
// asin(z) = -i (ln(iz + sqrt(1 - z^2)))
final String name = "asin";
final UnaryOperator<Complex> operation = Complex::asin;
@@ -198,7 +198,7 @@
// asinh is defined by asin so is not tested
@Test
- public void testAtanh() {
+ void testAtanh() {
// atanh(z) = (1/2) ln((1 + z) / (1 - z))
// Odd function: negative real cases defined by positive real cases
final String name = "atanh";
@@ -227,7 +227,7 @@
}
@Test
- public void testCosh() {
+ void testCosh() {
// cosh(a + b i) = cosh(a)cos(b) + i sinh(a)sin(b)
// Even function: negative real cases defined by positive real cases
final String name = "cosh";
@@ -292,7 +292,7 @@
}
@Test
- public void testSinh() {
+ void testSinh() {
// sinh(a + b i) = sinh(a)cos(b) + i cosh(a)sin(b)
// Odd function: negative real cases defined by positive real cases
final String name = "sinh";
@@ -355,7 +355,7 @@
}
@Test
- public void testTanh() {
+ void testTanh() {
// tan(a + b i) = sinh(2a)/(cosh(2a)+cos(2b)) + i [sin(2b)/(cosh(2a)+cos(2b))]
// Odd function: negative real cases defined by positive real cases
final String name = "tanh";
@@ -402,7 +402,7 @@
}
@Test
- public void testExp() {
+ void testExp() {
final String name = "exp";
final UnaryOperator<Complex> operation = Complex::exp;
@@ -424,7 +424,7 @@
}
@Test
- public void testLog() {
+ void testLog() {
final String name = "log";
final UnaryOperator<Complex> operation = Complex::log;
@@ -558,7 +558,7 @@
}
@Test
- public void testSqrt() {
+ void testSqrt() {
final String name = "sqrt";
final UnaryOperator<Complex> operation = Complex::sqrt;
@@ -640,7 +640,7 @@
// multiply/divide are tested in CStandardTest
@Test
- public void testDivide() {
+ void testDivide() {
final String name = "divide";
final BiFunction<Complex, Complex, Complex> operation = Complex::divide;
@@ -680,7 +680,7 @@
}
@Test
- public void testPow() {
+ void testPow() {
final String name = "pow";
final BiFunction<Complex, Complex, Complex> operation = Complex::pow;
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
index 1dcf513..4e2ba6c 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
@@ -43,7 +43,7 @@
* imaginary parts that can create intermediate overflow or underflow.
* </ul>
*/
-public class ComplexTest {
+class ComplexTest {
private static final double inf = Double.POSITIVE_INFINITY;
private static final double neginf = Double.NEGATIVE_INFINITY;
@@ -96,7 +96,7 @@
@Test
@Disabled("Used to output the java environment")
@SuppressWarnings("squid:S2699")
- public void testJava() {
+ void testJava() {
// CHECKSTYLE: stop Regexp
System.out.println(">>testJava()");
// MathTest#testExpSpecialCases() checks the following:
@@ -126,14 +126,14 @@
}
@Test
- public void testCartesianConstructor() {
+ void testCartesianConstructor() {
final Complex z = Complex.ofCartesian(3.0, 4.0);
Assertions.assertEquals(3.0, z.getReal());
Assertions.assertEquals(4.0, z.getImaginary());
}
@Test
- public void testPolarConstructor() {
+ void testPolarConstructor() {
final double r = 98765;
final double theta = 0.12345;
final Complex z = Complex.ofPolar(r, theta);
@@ -167,7 +167,7 @@
}
@Test
- public void testPolarConstructorAbsArg() {
+ void testPolarConstructorAbsArg() {
// The test should work with any seed but use a fixed seed to avoid build
// instability.
final UniformRandomProvider rng = RandomSource.create(RandomSource.SPLIT_MIX_64, 678678638L);
@@ -183,7 +183,7 @@
}
@Test
- public void testCisConstructor() {
+ void testCisConstructor() {
final double x = 0.12345;
final Complex z = Complex.ofCis(x);
Assertions.assertEquals(Math.cos(x), z.getReal());
@@ -194,7 +194,7 @@
* Test parse and toString are compatible.
*/
@Test
- public void testParseAndToString() {
+ void testParseAndToString() {
final double[] parts = {Double.NEGATIVE_INFINITY, -1, -0.0, 0.0, 1, Math.PI, Double.POSITIVE_INFINITY,
Double.NaN};
for (final double x : parts) {
@@ -217,42 +217,42 @@
}
@Test
- public void testParseNull() {
+ void testParseNull() {
Assertions.assertThrows(NullPointerException.class, () -> Complex.parse(null));
}
@Test
- public void testParseEmpty() {
+ void testParseEmpty() {
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse(""));
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse(" "));
}
@Test
- public void testParseWrongStart() {
+ void testParseWrongStart() {
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("1.0,2.0)"));
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("[1.0,2.0)"));
}
@Test
- public void testParseWrongEnd() {
+ void testParseWrongEnd() {
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("(1.0,2.0"));
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("(1.0,2.0]"));
}
@Test
- public void testParseWrongSeparator() {
+ void testParseWrongSeparator() {
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("(1.0 2.0)"));
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("(1.0:2.0)"));
}
@Test
- public void testParseSeparatorOutsideStartAndEnd() {
+ void testParseSeparatorOutsideStartAndEnd() {
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("(1.0,2.0),"));
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse(",(1.0,2.0)"));
}
@Test
- public void testParseExtraSeparator() {
+ void testParseExtraSeparator() {
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("(1.0,,2.0)"));
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("(1.0,2.0,)"));
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("(,1.0,2.0)"));
@@ -260,17 +260,17 @@
}
@Test
- public void testParseInvalidRe() {
+ void testParseInvalidRe() {
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("(I.0,2.0)"));
}
@Test
- public void testParseInvalidIm() {
+ void testParseInvalidIm() {
Assertions.assertThrows(NumberFormatException.class, () -> Complex.parse("(1.0,2.G)"));
}
@Test
- public void testParseSpaceAllowedAroundNumbers() {
+ void testParseSpaceAllowedAroundNumbers() {
final double re = 1.234;
final double im = 5.678;
final Complex z = Complex.ofCartesian(re, im);
@@ -283,7 +283,7 @@
}
@Test
- public void testCGrammar() {
+ void testCGrammar() {
final UniformRandomProvider rng = RandomSource.create(RandomSource.SPLIT_MIX_64);
for (int i = 0; i < 10; i++) {
final Complex z = Complex.ofCartesian(rng.nextDouble(), rng.nextDouble());
@@ -293,13 +293,13 @@
}
@Test
- public void testAbs() {
+ void testAbs() {
final Complex z = Complex.ofCartesian(3.0, 4.0);
Assertions.assertEquals(5.0, z.abs());
}
@Test
- public void testAbsNaN() {
+ void testAbsNaN() {
// The result is NaN if either argument is NaN and the other is not infinite
Assertions.assertEquals(nan, NAN.abs());
Assertions.assertEquals(nan, Complex.ofCartesian(3.0, nan).abs());
@@ -319,7 +319,7 @@
* Test standard values
*/
@Test
- public void testArg() {
+ void testArg() {
Complex z = Complex.ofCartesian(1, 0);
assertArgument(0.0, z, 1.0e-12);
@@ -349,7 +349,7 @@
* Verify atan2-style handling of infinite parts
*/
@Test
- public void testArgInf() {
+ void testArgInf() {
assertArgument(Math.PI / 4, infInf, 1.0e-12);
assertArgument(Math.PI / 2, oneInf, 1.0e-12);
assertArgument(0.0, infOne, 1.0e-12);
@@ -364,7 +364,7 @@
* Verify that either part NaN results in NaN
*/
@Test
- public void testArgNaN() {
+ void testArgNaN() {
assertArgument(Double.NaN, nanZero, 0);
assertArgument(Double.NaN, zeroNan, 0);
assertArgument(Double.NaN, NAN, 0);
@@ -377,13 +377,13 @@
}
@Test
- public void testNorm() {
+ void testNorm() {
final Complex z = Complex.ofCartesian(3.0, 4.0);
Assertions.assertEquals(25.0, z.norm());
}
@Test
- public void testNormNaN() {
+ void testNormNaN() {
// The result is NaN if either argument is NaN and the other is not infinite
Assertions.assertEquals(nan, NAN.norm());
Assertions.assertEquals(nan, Complex.ofCartesian(3.0, nan).norm());
@@ -399,7 +399,7 @@
* Test all number types: isNaN, isInfinite, isFinite.
*/
@Test
- public void testNumberType() {
+ void testNumberType() {
assertNumberType(0, 0, NumberType.FINITE);
assertNumberType(1, 0, NumberType.FINITE);
assertNumberType(0, 1, NumberType.FINITE);
@@ -457,7 +457,7 @@
}
@Test
- public void testConjugate() {
+ void testConjugate() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final Complex z = x.conj();
Assertions.assertEquals(3.0, z.getReal());
@@ -465,13 +465,13 @@
}
@Test
- public void testConjugateNaN() {
+ void testConjugateNaN() {
final Complex z = NAN.conj();
Assertions.assertTrue(z.isNaN());
}
@Test
- public void testConjugateInfinite() {
+ void testConjugateInfinite() {
Complex z = Complex.ofCartesian(0, inf);
Assertions.assertEquals(neginf, z.conj().getImaginary());
z = Complex.ofCartesian(0, neginf);
@@ -479,7 +479,7 @@
}
@Test
- public void testNegate() {
+ void testNegate() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final Complex z = x.negate();
Assertions.assertEquals(-3.0, z.getReal());
@@ -487,13 +487,13 @@
}
@Test
- public void testNegateNaN() {
+ void testNegateNaN() {
final Complex z = NAN.negate();
Assertions.assertTrue(z.isNaN());
}
@Test
- public void testProj() {
+ void testProj() {
final Complex z = Complex.ofCartesian(3.0, 4.0);
Assertions.assertSame(z, z.proj());
// Sign must be the same for projection
@@ -509,7 +509,7 @@
}
@Test
- public void testAdd() {
+ void testAdd() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final Complex y = Complex.ofCartesian(5.0, 6.0);
final Complex z = x.add(y);
@@ -518,7 +518,7 @@
}
@Test
- public void testAddInf() {
+ void testAddInf() {
Complex x = Complex.ofCartesian(1, 1);
final Complex z = Complex.ofCartesian(inf, 0);
final Complex w = x.add(z);
@@ -530,7 +530,7 @@
}
@Test
- public void testAddReal() {
+ void testAddReal() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 5.0;
final Complex z = x.add(y);
@@ -541,7 +541,7 @@
}
@Test
- public void testAddRealNaN() {
+ void testAddRealNaN() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = nan;
final Complex z = x.add(y);
@@ -552,7 +552,7 @@
}
@Test
- public void testAddRealInf() {
+ void testAddRealInf() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = inf;
final Complex z = x.add(y);
@@ -563,7 +563,7 @@
}
@Test
- public void testAddRealWithNegZeroImaginary() {
+ void testAddRealWithNegZeroImaginary() {
final Complex x = Complex.ofCartesian(3.0, -0.0);
final double y = 5.0;
final Complex z = x.add(y);
@@ -576,7 +576,7 @@
}
@Test
- public void testAddImaginary() {
+ void testAddImaginary() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 5.0;
final Complex z = x.addImaginary(y);
@@ -587,7 +587,7 @@
}
@Test
- public void testAddImaginaryNaN() {
+ void testAddImaginaryNaN() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = nan;
final Complex z = x.addImaginary(y);
@@ -598,7 +598,7 @@
}
@Test
- public void testAddImaginaryInf() {
+ void testAddImaginaryInf() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = inf;
final Complex z = x.addImaginary(y);
@@ -609,7 +609,7 @@
}
@Test
- public void testAddImaginaryWithNegZeroReal() {
+ void testAddImaginaryWithNegZeroReal() {
final Complex x = Complex.ofCartesian(-0.0, 4.0);
final double y = 5.0;
final Complex z = x.addImaginary(y);
@@ -622,7 +622,7 @@
}
@Test
- public void testSubtract() {
+ void testSubtract() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final Complex y = Complex.ofCartesian(5.0, 7.0);
final Complex z = x.subtract(y);
@@ -631,7 +631,7 @@
}
@Test
- public void testSubtractInf() {
+ void testSubtractInf() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final Complex y = Complex.ofCartesian(inf, 7.0);
Complex z = x.subtract(y);
@@ -644,7 +644,7 @@
}
@Test
- public void testSubtractReal() {
+ void testSubtractReal() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 5.0;
final Complex z = x.subtract(y);
@@ -655,7 +655,7 @@
}
@Test
- public void testSubtractRealNaN() {
+ void testSubtractRealNaN() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = nan;
final Complex z = x.subtract(y);
@@ -666,7 +666,7 @@
}
@Test
- public void testSubtractRealInf() {
+ void testSubtractRealInf() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = inf;
final Complex z = x.subtract(y);
@@ -677,7 +677,7 @@
}
@Test
- public void testSubtractRealWithNegZeroImaginary() {
+ void testSubtractRealWithNegZeroImaginary() {
final Complex x = Complex.ofCartesian(3.0, -0.0);
final double y = 5.0;
final Complex z = x.subtract(y);
@@ -689,7 +689,7 @@
}
@Test
- public void testSubtractImaginary() {
+ void testSubtractImaginary() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 5.0;
final Complex z = x.subtractImaginary(y);
@@ -700,7 +700,7 @@
}
@Test
- public void testSubtractImaginaryNaN() {
+ void testSubtractImaginaryNaN() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = nan;
final Complex z = x.subtractImaginary(y);
@@ -711,7 +711,7 @@
}
@Test
- public void testSubtractImaginaryInf() {
+ void testSubtractImaginaryInf() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = inf;
final Complex z = x.subtractImaginary(y);
@@ -722,7 +722,7 @@
}
@Test
- public void testSubtractImaginaryWithNegZeroReal() {
+ void testSubtractImaginaryWithNegZeroReal() {
final Complex x = Complex.ofCartesian(-0.0, 4.0);
final double y = 5.0;
final Complex z = x.subtractImaginary(y);
@@ -734,7 +734,7 @@
}
@Test
- public void testSubtractFromReal() {
+ void testSubtractFromReal() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 5.0;
final Complex z = x.subtractFrom(y);
@@ -745,7 +745,7 @@
}
@Test
- public void testSubtractFromRealNaN() {
+ void testSubtractFromRealNaN() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = nan;
final Complex z = x.subtractFrom(y);
@@ -756,7 +756,7 @@
}
@Test
- public void testSubtractFromRealInf() {
+ void testSubtractFromRealInf() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = inf;
final Complex z = x.subtractFrom(y);
@@ -767,7 +767,7 @@
}
@Test
- public void testSubtractFromRealWithPosZeroImaginary() {
+ void testSubtractFromRealWithPosZeroImaginary() {
final Complex x = Complex.ofCartesian(3.0, 0.0);
final double y = 5.0;
final Complex z = x.subtractFrom(y);
@@ -778,7 +778,7 @@
}
@Test
- public void testSubtractFromImaginary() {
+ void testSubtractFromImaginary() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 5.0;
final Complex z = x.subtractFromImaginary(y);
@@ -789,7 +789,7 @@
}
@Test
- public void testSubtractFromImaginaryNaN() {
+ void testSubtractFromImaginaryNaN() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = nan;
final Complex z = x.subtractFromImaginary(y);
@@ -800,7 +800,7 @@
}
@Test
- public void testSubtractFromImaginaryInf() {
+ void testSubtractFromImaginaryInf() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = inf;
final Complex z = x.subtractFromImaginary(y);
@@ -811,7 +811,7 @@
}
@Test
- public void testSubtractFromImaginaryWithPosZeroReal() {
+ void testSubtractFromImaginaryWithPosZeroReal() {
final Complex x = Complex.ofCartesian(0.0, 4.0);
final double y = 5.0;
final Complex z = x.subtractFromImaginary(y);
@@ -822,7 +822,7 @@
}
@Test
- public void testMultiply() {
+ void testMultiply() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final Complex y = Complex.ofCartesian(5.0, 6.0);
final Complex z = x.multiply(y);
@@ -831,7 +831,7 @@
}
@Test
- public void testMultiplyInfInf() {
+ void testMultiplyInfInf() {
final Complex z = infInf.multiply(infInf);
// Assert.assertTrue(z.isNaN()); // MATH-620
Assertions.assertTrue(z.isInfinite());
@@ -844,7 +844,7 @@
}
@Test
- public void testMultiplyReal() {
+ void testMultiplyReal() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 2.0;
Complex z = x.multiply(y);
@@ -861,7 +861,7 @@
}
@Test
- public void testMultiplyRealNaN() {
+ void testMultiplyRealNaN() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = nan;
final Complex z = x.multiply(y);
@@ -872,7 +872,7 @@
}
@Test
- public void testMultiplyRealInf() {
+ void testMultiplyRealInf() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = inf;
Complex z = x.multiply(y);
@@ -889,7 +889,7 @@
}
@Test
- public void testMultiplyRealZero() {
+ void testMultiplyRealZero() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 0.0;
Complex z = x.multiply(y);
@@ -908,7 +908,7 @@
}
@Test
- public void testMultiplyImaginary() {
+ void testMultiplyImaginary() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 2.0;
Complex z = x.multiplyImaginary(y);
@@ -925,7 +925,7 @@
}
@Test
- public void testMultiplyImaginaryNaN() {
+ void testMultiplyImaginaryNaN() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = nan;
final Complex z = x.multiplyImaginary(y);
@@ -936,7 +936,7 @@
}
@Test
- public void testMultiplyImaginaryInf() {
+ void testMultiplyImaginaryInf() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = inf;
Complex z = x.multiplyImaginary(y);
@@ -953,7 +953,7 @@
}
@Test
- public void testMultiplyImaginaryZero() {
+ void testMultiplyImaginaryZero() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 0.0;
Complex z = x.multiplyImaginary(y);
@@ -974,7 +974,7 @@
}
@Test
- public void testNonZeroMultiplyI() {
+ void testNonZeroMultiplyI() {
final double[] parts = {3.0, 4.0};
for (final double a : parts) {
for (final double b : parts) {
@@ -990,7 +990,7 @@
}
@Test
- public void testNonZeroMultiplyNegativeI() {
+ void testNonZeroMultiplyNegativeI() {
// This works no matter how you represent -I as a Complex
final double[] parts = {3.0, 4.0};
final Complex[] negIs = {Complex.ofCartesian(-0.0, -1), Complex.ofCartesian(0.0, -1)};
@@ -1010,7 +1010,7 @@
}
@Test
- public void testMultiplyZeroByI() {
+ void testMultiplyZeroByI() {
final double[] zeros = {-0.0, 0.0};
for (final double a : zeros) {
for (final double b : zeros) {
@@ -1024,6 +1024,7 @@
if (Double.compare(b, 0.0) == 0) {
// (-0.0, 0.0).multiply( (0,1) ) => (-0.0, 0.0) expected (-0.0,-0.0)
// ( 0.0, 0.0).multiply( (0,1) ) => ( 0.0, 0.0) expected (-0.0, 0.0)
+ // Sign is allowed to be different for zero.
Assertions.assertEquals(0, z.getReal(), 0.0);
Assertions.assertEquals(0, z.getImaginary(), 0.0);
Assertions.assertNotEquals(x, z);
@@ -1035,7 +1036,7 @@
}
@Test
- public void testMultiplyZeroByNegativeI() {
+ void testMultiplyZeroByNegativeI() {
// Depending on how we represent -I this does not work for 2/4 cases
// but the cases are different. Here we test the negation of I.
final Complex negI = Complex.I.negate();
@@ -1051,10 +1052,9 @@
final Complex z2 = c.multiply(Complex.I).negate();
// Does not work when imaginary part is -0.0.
if (Double.compare(b, -0.0) == 0) {
- // (-0.0,-0.0).multiply( (-0.0,-1) ) => ( 0.0, 0.0) expected (-0.0,
- // 0.0)
- // ( 0.0,-0.0).multiply( (-0.0,-1) ) => (-0.0, 0.0) expected
- // (-0.0,-0.0)
+ // (-0.0,-0.0).multiply( (-0.0,-1) ) => ( 0.0, 0.0) expected (-0.0, 0.0)
+ // ( 0.0,-0.0).multiply( (-0.0,-1) ) => (-0.0, 0.0) expected (-0.0,-0.0)
+ // Sign is allowed to be different for zero.
Assertions.assertEquals(0, z.getReal(), 0.0);
Assertions.assertEquals(0, z.getImaginary(), 0.0);
Assertions.assertNotEquals(x, z);
@@ -1072,7 +1072,7 @@
}
@Test
- public void testDivide() {
+ void testDivide() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final Complex y = Complex.ofCartesian(5.0, 6.0);
final Complex z = x.divide(y);
@@ -1081,31 +1081,31 @@
}
@Test
- public void testDivideZero() {
+ void testDivideZero() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final Complex z = x.divide(Complex.ZERO);
Assertions.assertEquals(INF, z);
}
@Test
- public void testDivideZeroZero() {
+ void testDivideZeroZero() {
final Complex x = Complex.ofCartesian(0.0, 0.0);
final Complex z = x.divide(Complex.ZERO);
Assertions.assertEquals(NAN, z);
}
@Test
- public void testDivideNaN() {
+ void testDivideNaN() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final Complex z = x.divide(NAN);
Assertions.assertTrue(z.isNaN());
}
@Test
- public void testDivideNanInf() {
+ void testDivideNanInf() {
Complex z = oneInf.divide(Complex.ONE);
Assertions.assertTrue(Double.isNaN(z.getReal()));
- Assertions.assertEquals(inf, z.getImaginary(), 0);
+ Assertions.assertEquals(inf, z.getImaginary());
z = negInfNegInf.divide(oneNan);
Assertions.assertTrue(Double.isNaN(z.getReal()));
@@ -1117,7 +1117,7 @@
}
@Test
- public void testDivideReal() {
+ void testDivideReal() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 2.0;
Complex z = x.divide(y);
@@ -1134,7 +1134,7 @@
}
@Test
- public void testDivideRealNaN() {
+ void testDivideRealNaN() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = nan;
final Complex z = x.divide(y);
@@ -1145,7 +1145,7 @@
}
@Test
- public void testDivideRealInf() {
+ void testDivideRealInf() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = inf;
Complex z = x.divide(y);
@@ -1162,7 +1162,7 @@
}
@Test
- public void testDivideRealZero() {
+ void testDivideRealZero() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 0.0;
Complex z = x.divide(y);
@@ -1179,7 +1179,7 @@
}
@Test
- public void testDivideImaginary() {
+ void testDivideImaginary() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 2.0;
Complex z = x.divideImaginary(y);
@@ -1196,7 +1196,7 @@
}
@Test
- public void testDivideImaginaryNaN() {
+ void testDivideImaginaryNaN() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = nan;
final Complex z = x.divideImaginary(y);
@@ -1207,7 +1207,7 @@
}
@Test
- public void testDivideImaginaryInf() {
+ void testDivideImaginaryInf() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = inf;
Complex z = x.divideImaginary(y);
@@ -1224,7 +1224,7 @@
}
@Test
- public void testDivideImaginaryZero() {
+ void testDivideImaginaryZero() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final double y = 0.0;
Complex z = x.divideImaginary(y);
@@ -1253,7 +1253,7 @@
* differences should be the sign of zero in certain cases.
*/
@Test
- public void testSignedArithmetic() {
+ void testSignedArithmetic() {
// The following lists the conditions for the double primitive operation where
// the Complex operation is different. Here the double argument can be:
// x : any value
@@ -1362,7 +1362,7 @@
* by zero using a Complex then multiplied by I.
*/
@Test
- public void testSignedDivideImaginaryArithmetic() {
+ void testSignedDivideImaginaryArithmetic() {
// Cases for divide by non-zero:
// 2: (-0.0,+x) / -y
// 4: (+x,+/-0.0) / -/+y
@@ -1385,8 +1385,7 @@
Complex z = c.divide(ofImaginary(arg));
final boolean expectedFailure = (expectedFailures & 0x1) == 1;
expectedFailures >>>= 1;
- // If divide by zero then the divide(Complex) method matches divide by
- // real.
+ // If divide by zero then the divide(Complex) method matches divide by real.
// To match divide by imaginary requires multiplication by I.
if (arg == 0) {
// Same result if multiplied by I. The sign may not match so
@@ -1399,8 +1398,7 @@
Assertions.assertEquals(ya, za, () -> c + " divideImaginary " + arg + ": real");
Assertions.assertEquals(yb, zb, () -> c + " divideImaginary " + arg + ": imaginary");
} else {
- // Check the same answer. Sign is allowed to be different for
- // zero.
+ // Check the same answer. Sign is allowed to be different for zero.
Assertions.assertEquals(y.getReal(), z.getReal(), 0,
() -> c + " divideImaginary " + arg + ": real");
Assertions.assertEquals(y.getImaginary(), z.getImaginary(), 0,
@@ -1414,7 +1412,7 @@
}
@Test
- public void testLog10() {
+ void testLog10() {
final double ln10 = Math.log(10);
final UniformRandomProvider rng = RandomSource.create(RandomSource.SPLIT_MIX_64);
for (int i = 0; i < 10; i++) {
@@ -1429,7 +1427,7 @@
}
@Test
- public void testPow() {
+ void testPow() {
final Complex x = Complex.ofCartesian(3, 4);
final double yDouble = 5.0;
final Complex yComplex = ofReal(yDouble);
@@ -1437,7 +1435,7 @@
}
@Test
- public void testPowComplexRealZero() {
+ void testPowComplexRealZero() {
// Hits the edge case when real == 0 but imaginary != 0
final Complex x = Complex.ofCartesian(0, 1);
final Complex z = Complex.ofCartesian(2, 3);
@@ -1448,7 +1446,7 @@
}
@Test
- public void testPowComplexZeroBase() {
+ void testPowComplexZeroBase() {
final double x = Double.MIN_VALUE;
assertPowComplexZeroBase(0, 0, NAN);
assertPowComplexZeroBase(0, x, NAN);
@@ -1463,7 +1461,7 @@
}
@Test
- public void testPowScalerRealZero() {
+ void testPowScalerRealZero() {
// Hits the edge case when real == 0 but imaginary != 0
final Complex x = Complex.ofCartesian(0, 1);
final Complex c = x.pow(2);
@@ -1473,7 +1471,7 @@
}
@Test
- public void testPowScalarZeroBase() {
+ void testPowScalarZeroBase() {
final double x = Double.MIN_VALUE;
assertPowScalarZeroBase(0, NAN);
assertPowScalarZeroBase(x, Complex.ZERO);
@@ -1485,7 +1483,7 @@
}
@Test
- public void testPowNanBase() {
+ void testPowNanBase() {
final Complex x = NAN;
final double yDouble = 5.0;
final Complex yComplex = ofReal(yDouble);
@@ -1493,7 +1491,7 @@
}
@Test
- public void testPowNanExponent() {
+ void testPowNanExponent() {
final Complex x = Complex.ofCartesian(3, 4);
final double yDouble = Double.NaN;
final Complex yComplex = ofReal(yDouble);
@@ -1501,7 +1499,7 @@
}
@Test
- public void testSqrtPolar() {
+ void testSqrtPolar() {
final double tol = 1e-12;
double r = 1;
for (int i = 0; i < 5; i++) {
@@ -1517,7 +1515,7 @@
}
@Test
- public void testZerothRootThrows() {
+ void testZerothRootThrows() {
final Complex c = Complex.ofCartesian(1, 1);
Assertions.assertThrows(IllegalArgumentException.class, () -> c.nthRoot(0),
"zeroth root should not be allowed");
@@ -1536,7 +1534,7 @@
* </pre>
*/
@Test
- public void testNthRootNormalThirdRoot() {
+ void testNthRootNormalThirdRoot() {
// The complex number we want to compute all third-roots for.
final Complex z = Complex.ofCartesian(-2, 2);
// The List holding all third roots
@@ -1568,7 +1566,7 @@
* </pre>
*/
@Test
- public void testNthRootNormalFourthRoot() {
+ void testNthRootNormalFourthRoot() {
// The complex number we want to compute all third-roots for.
final Complex z = Complex.ofCartesian(5, -2);
// The List holding all fourth roots
@@ -1602,7 +1600,7 @@
* </pre>
*/
@Test
- public void testNthRootCornercaseThirdRootImaginaryPartEmpty() {
+ void testNthRootCornercaseThirdRootImaginaryPartEmpty() {
// The number 8 has three third roots. One we all already know is the number 2.
// But there are two more complex roots.
final Complex z = Complex.ofCartesian(8, 0);
@@ -1634,7 +1632,7 @@
* </pre>
*/
@Test
- public void testNthRootCornercaseThirdRootRealPartZero() {
+ void testNthRootCornercaseThirdRootRealPartZero() {
// complex number with only imaginary part
final Complex z = Complex.ofCartesian(0, 2);
// The List holding all third roots
@@ -1668,7 +1666,7 @@
* </pre>
*/
@Test
- public void testNthRootNegativeArg() {
+ void testNthRootNegativeArg() {
// The complex number we want to compute all third-roots for.
final Complex z = Complex.ofCartesian(1, 0);
// The List holding all fourth roots
@@ -1702,7 +1700,7 @@
}
@Test
- public void testNthRootNan() {
+ void testNthRootNan() {
final int n = 3;
final Complex z = ofReal(Double.NaN);
final List<Complex> r = z.nthRoot(n);
@@ -1714,7 +1712,7 @@
}
@Test
- public void testNthRootInf() {
+ void testNthRootInf() {
final int n = 3;
final Complex z = ofReal(Double.NEGATIVE_INFINITY);
final List<Complex> r = z.nthRoot(n);
@@ -1722,39 +1720,39 @@
}
@Test
- public void testEqualsWithNull() {
+ void testEqualsWithNull() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
Assertions.assertFalse(x.equals(null));
}
@Test
- public void testEqualsWithAnotherClass() {
+ void testEqualsWithAnotherClass() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
Assertions.assertFalse(x.equals(new Object()));
}
@Test
- public void testEqualsWithSameObject() {
+ void testEqualsWithSameObject() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
Assertions.assertEquals(x, x);
}
@Test
- public void testEqualsWithCopyObject() {
+ void testEqualsWithCopyObject() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
final Complex y = Complex.ofCartesian(3.0, 4.0);
Assertions.assertEquals(x, y);
}
@Test
- public void testEqualsWithRealDifference() {
+ void testEqualsWithRealDifference() {
final Complex x = Complex.ofCartesian(0.0, 0.0);
final Complex y = Complex.ofCartesian(0.0 + Double.MIN_VALUE, 0.0);
Assertions.assertNotEquals(x, y);
}
@Test
- public void testEqualsWithImaginaryDifference() {
+ void testEqualsWithImaginaryDifference() {
final Complex x = Complex.ofCartesian(0.0, 0.0);
final Complex y = Complex.ofCartesian(0.0, 0.0 + Double.MIN_VALUE);
Assertions.assertNotEquals(x, y);
@@ -1766,7 +1764,7 @@
* complex numbers.
*/
@Test
- public void testEqualsIsConsistentWithArraysEquals() {
+ void testEqualsIsConsistentWithArraysEquals() {
// Explicit check of the cases documented in the Javadoc:
assertEqualsIsConsistentWithArraysEquals(Complex.ofCartesian(Double.NaN, 0.0),
Complex.ofCartesian(Double.NaN, 1.0), "NaN real and different non-NaN imaginary");
@@ -1804,7 +1802,7 @@
* {@link Complex#isNaN()} are {@code false} for {@link Complex#equals(Object)}.
*/
@Test
- public void testEqualsWithDifferentNaNs() {
+ void testEqualsWithDifferentNaNs() {
// Test some NaN combinations
final double[] values = {Double.NaN, 0, 1};
final ArrayList<Complex> list = createCombinations(values);
@@ -1847,7 +1845,7 @@
* hash codes are {@code false} for {@link Object#equals(Object)}.
*/
@Test
- public void testHashCode() {
+ void testHashCode() {
// Test some values match Arrays.hashCode(double[])
final double[] values = {Double.NaN, Double.NEGATIVE_INFINITY, -3.45, -1, -0.0, 0.0, Double.MIN_VALUE, 1, 3.45,
Double.POSITIVE_INFINITY};
@@ -1900,7 +1898,7 @@
* href="https://issues.apache.org/jira/projects/MATH/issues/MATH-1118">MATH-1118</a>
*/
@Test
- public void testHashCodeWithDifferentZeros() {
+ void testHashCodeWithDifferentZeros() {
final double[] values = {-0.0, 0.0};
final ArrayList<Complex> list = createCombinations(values);
@@ -1951,7 +1949,7 @@
}
@Test
- public void testAtanhEdgeConditions() {
+ void testAtanhEdgeConditions() {
// Hits the edge case when imaginary == 0 but real != 0 or 1
final Complex c = Complex.ofCartesian(2, 0).atanh();
// Answer from g++
@@ -1960,7 +1958,7 @@
}
@Test
- public void testAtanhAssumptions() {
+ void testAtanhAssumptions() {
// Compute the same constants used by atanh
final double safeUpper = Math.sqrt(Double.MAX_VALUE) / 2;
final double safeLower = Math.sqrt(Double.MIN_NORMAL) * 2;
@@ -1990,7 +1988,7 @@
}
@Test
- public void testCoshSinhTanhAssumptions() {
+ void testCoshSinhTanhAssumptions() {
// Use the same constants used to approximate cosh/sinh with e^|x| / 2
final double safeExpMax = 708;
@@ -2042,7 +2040,7 @@
* of sin and cos together when |x| is small.
*/
@Test
- public void testSinCosLinearAssumptions() {
+ void testSinCosLinearAssumptions() {
// Are cos and sin linear around zero?
// If cos is still 1 then since d(sin) dx = cos then sin is linear.
Assertions.assertEquals(1.0, Math.cos(Double.MIN_NORMAL));
@@ -2065,7 +2063,7 @@
* different numbers.
*/
@Test
- public void testAbsVsSqrt() {
+ void testAbsVsSqrt() {
final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP);
// Note: All methods implement scaling to ensure the magnitude can be computed.
// Try very large or small numbers that will over/underflow to test that the
@@ -2129,7 +2127,7 @@
* different numbers.
*/
@Test
- public void testAbsVsLog() {
+ void testAbsVsLog() {
final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP);
// Note: All methods implement scaling to ensure the magnitude can be computed.
// Try very large or small numbers that will over/underflow to test that the
diff --git a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
index fbeb78e..5a4bb73 100644
--- a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
+++ b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
@@ -27,10 +27,10 @@
* Test cases for the {@link ArithmeticUtils} class.
*
*/
-public class ArithmeticUtilsTest {
+class ArithmeticUtilsTest {
@Test
- public void testGcd() {
+ void testGcd() {
int a = 30;
int b = 50;
int c = 77;
@@ -81,7 +81,7 @@
}
@Test
- public void testGcdConsistency() {
+ void testGcdConsistency() {
// Use Integer to prevent varargs vs array issue with Arrays.asList
Integer[] primeList = {19, 23, 53, 67, 73, 79, 101, 103, 111, 131};
@@ -102,7 +102,7 @@
}
@Test
- public void testGcdLong() {
+ void testGcdLong() {
long a = 30;
long b = 50;
long c = 77;
@@ -156,7 +156,7 @@
@Test
- public void testLcm() {
+ void testLcm() {
int a = 30;
int b = 50;
int c = 77;
@@ -203,7 +203,7 @@
}
@Test
- public void testLcmLong() {
+ void testLcmLong() {
long a = 30;
long b = 50;
long c = 77;
@@ -254,7 +254,7 @@
}
@Test
- public void testPow() {
+ void testPow() {
Assertions.assertEquals(1801088541, ArithmeticUtils.pow(21, 7));
Assertions.assertEquals(1, ArithmeticUtils.pow(21, 0));
@@ -304,12 +304,8 @@
Assertions.assertEquals(BigInteger.valueOf(1801088541L), ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(7L)));
Assertions.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, BigInteger.ZERO));
- try {
- ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(-7L));
- Assertions.fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // expected behavior
- }
+ Assertions.assertThrows(IllegalArgumentException.class, () ->
+ ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(-7L)));
BigInteger bigOne =
new BigInteger("1543786922199448028351389769265814882661837148" +
@@ -322,14 +318,14 @@
}
@Test
- public void testPowIntOverflow() {
+ void testPowIntOverflow() {
Assertions.assertThrows(ArithmeticException.class,
() -> ArithmeticUtils.pow(21, 8)
);
}
@Test
- public void testPowInt() {
+ void testPowInt() {
final int base = 21;
Assertions.assertEquals(85766121L,
@@ -339,14 +335,14 @@
}
@Test
- public void testPowNegativeIntOverflow() {
+ void testPowNegativeIntOverflow() {
Assertions.assertThrows(ArithmeticException.class,
() -> ArithmeticUtils.pow(-21, 8)
);
}
@Test
- public void testPowNegativeInt() {
+ void testPowNegativeInt() {
final int base = -21;
Assertions.assertEquals(85766121,
@@ -356,7 +352,7 @@
}
@Test
- public void testPowMinusOneInt() {
+ void testPowMinusOneInt() {
final int base = -1;
for (int i = 0; i < 100; i++) {
final int pow = ArithmeticUtils.pow(base, i);
@@ -365,7 +361,7 @@
}
@Test
- public void testPowOneInt() {
+ void testPowOneInt() {
final int base = 1;
for (int i = 0; i < 100; i++) {
final int pow = ArithmeticUtils.pow(base, i);
@@ -374,14 +370,14 @@
}
@Test
- public void testPowLongOverflow() {
+ void testPowLongOverflow() {
Assertions.assertThrows(ArithmeticException.class,
() -> ArithmeticUtils.pow(21, 15)
);
}
@Test
- public void testPowLong() {
+ void testPowLong() {
final long base = 21;
Assertions.assertEquals(154472377739119461L,
@@ -391,14 +387,14 @@
}
@Test
- public void testPowNegativeLongOverflow() {
+ void testPowNegativeLongOverflow() {
Assertions.assertThrows(ArithmeticException.class,
() -> ArithmeticUtils.pow(-21L, 15)
);
}
@Test
- public void testPowNegativeLong() {
+ void testPowNegativeLong() {
final long base = -21;
Assertions.assertEquals(-154472377739119461L,
@@ -408,7 +404,7 @@
}
@Test
- public void testPowMinusOneLong() {
+ void testPowMinusOneLong() {
final long base = -1;
for (int i = 0; i < 100; i++) {
final long pow = ArithmeticUtils.pow(base, i);
@@ -417,7 +413,7 @@
}
@Test
- public void testPowOneLong() {
+ void testPowOneLong() {
final long base = 1;
for (int i = 0; i < 100; i++) {
final long pow = ArithmeticUtils.pow(base, i);
@@ -426,7 +422,7 @@
}
@Test
- public void testIsPowerOfTwo() {
+ void testIsPowerOfTwo() {
final int n = 1025;
final boolean[] expected = new boolean[n];
Arrays.fill(expected, false);
@@ -533,13 +529,13 @@
}
@Test
- public void testRemainderUnsignedInt() {
+ void testRemainderUnsignedInt() {
Assertions.assertEquals(36, ArithmeticUtils.remainderUnsigned(-2147479015, 63));
Assertions.assertEquals(6, ArithmeticUtils.remainderUnsigned(-2147479015, 25));
}
@Test
- public void testRemainderUnsignedIntSpecialCases() {
+ void testRemainderUnsignedIntSpecialCases() {
int[] ints = getIntSpecialCases();
for (int dividend : ints) {
for (int divisor : ints) {
@@ -555,12 +551,12 @@
}
@Test
- public void testRemainderUnsignedLong() {
+ void testRemainderUnsignedLong() {
Assertions.assertEquals(48L, ArithmeticUtils.remainderUnsigned(-2147479015L, 63L));
}
@Test
- public void testRemainderUnsignedLongSpecialCases() {
+ void testRemainderUnsignedLongSpecialCases() {
long[] longs = getLongSpecialCases();
for (long dividend : longs) {
for (long divisor : longs) {
@@ -579,7 +575,7 @@
}
@Test
- public void testDivideUnsignedInt() {
+ void testDivideUnsignedInt() {
Assertions.assertEquals(34087115, ArithmeticUtils.divideUnsigned(-2147479015, 63));
Assertions.assertEquals(85899531, ArithmeticUtils.divideUnsigned(-2147479015, 25));
Assertions.assertEquals(2147483646, ArithmeticUtils.divideUnsigned(-3, 2));
@@ -593,7 +589,7 @@
}
@Test
- public void testDivideUnsignedIntSpecialCases() {
+ void testDivideUnsignedIntSpecialCases() {
int[] ints = getIntSpecialCases();
for (int dividend : ints) {
for (int divisor : ints) {
@@ -609,12 +605,12 @@
}
@Test
- public void testDivideUnsignedLong() {
+ void testDivideUnsignedLong() {
Assertions.assertEquals(292805461453366231L, ArithmeticUtils.divideUnsigned(-2147479015L, 63L));
}
@Test
- public void testDivideUnsignedLongSpecialCases() {
+ void testDivideUnsignedLongSpecialCases() {
long[] longs = getLongSpecialCases();
for (long dividend : longs) {
for (long divisor : longs) {
diff --git a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java
index 92e193f..8e784bf 100644
--- a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java
+++ b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java
@@ -25,7 +25,7 @@
* Test cases for the {@link Precision} class.
*
*/
-public class PrecisionTest {
+class PrecisionTest {
// Interfaces to allow testing equals variants with the same conditions
@@ -50,7 +50,7 @@
}
@Test
- public void testEqualsWithRelativeTolerance() {
+ void testEqualsWithRelativeTolerance() {
Assertions.assertTrue(Precision.equalsWithRelativeTolerance(0d, 0d, 0d));
Assertions.assertTrue(Precision.equalsWithRelativeTolerance(0d, 1 / Double.NEGATIVE_INFINITY, 0d));
@@ -77,7 +77,7 @@
}
@Test
- public void testEqualsIncludingNaN() {
+ void testEqualsIncludingNaN() {
double[] testArray = {
Double.NaN,
Double.POSITIVE_INFINITY,
@@ -98,12 +98,12 @@
}
@Test
- public void testEqualsWithAllowedDelta() {
+ void testEqualsWithAllowedDelta() {
assertEqualsWithAllowedDelta(Precision::equalsIncludingNaN, true);
}
@Test
- public void testEqualsIncludingNaNWithAllowedDelta() {
+ void testEqualsIncludingNaNWithAllowedDelta() {
assertEqualsWithAllowedDelta(Precision::equalsIncludingNaN, true);
}
@@ -120,18 +120,18 @@
}
@Test
- public void testEqualsWithAllowedUlps() {
+ void testEqualsWithAllowedUlps() {
assertEqualsIncludingNaNWithAllowedUlps(Precision::equals, false, false);
}
@Test
- public void testEqualsWithImplicitAllowedUlpsOf1() {
+ void testEqualsWithImplicitAllowedUlpsOf1() {
// Use the version without the ulp argument
assertEqualsIncludingNaNWithAllowedUlps((a, b, ulp) -> Precision.equals(a, b), false, true);
}
@Test
- public void testEqualsIncludingNaNWithAllowedUlps() {
+ void testEqualsIncludingNaNWithAllowedUlps() {
assertEqualsIncludingNaNWithAllowedUlps(Precision::equalsIncludingNaN, true, false);
}
@@ -176,7 +176,7 @@
// converted to float
@Test
- public void testFloatEqualsIncludingNaN() {
+ void testFloatEqualsIncludingNaN() {
float[] testArray = {
Float.NaN,
Float.POSITIVE_INFINITY,
@@ -197,12 +197,12 @@
}
@Test
- public void testFloatEqualsWithAllowedDelta() {
+ void testFloatEqualsWithAllowedDelta() {
assertFloatEqualsWithAllowedDelta(Precision::equalsIncludingNaN, true);
}
@Test
- public void testFloatEqualsIncludingNaNWithAllowedDelta() {
+ void testFloatEqualsIncludingNaNWithAllowedDelta() {
assertFloatEqualsWithAllowedDelta(Precision::equalsIncludingNaN, true);
}
@@ -219,18 +219,18 @@
}
@Test
- public void testFloatEqualsWithAllowedUlps() {
+ void testFloatEqualsWithAllowedUlps() {
assertFloatEqualsIncludingNaNWithAllowedUlps(Precision::equals, false, false);
}
@Test
- public void testFloatEqualsWithImplicitAllowedUlpsOf1() {
+ void testFloatEqualsWithImplicitAllowedUlpsOf1() {
// Use the version without the ulp argument
assertFloatEqualsIncludingNaNWithAllowedUlps((a, b, ulp) -> Precision.equals(a, b), false, true);
}
@Test
- public void testFloatEqualsIncludingNaNWithAllowedUlps() {
+ void testFloatEqualsIncludingNaNWithAllowedUlps() {
assertFloatEqualsIncludingNaNWithAllowedUlps(Precision::equalsIncludingNaN, true, false);
}
@@ -272,7 +272,7 @@
}
@Test
- public void testCompareToEpsilon() {
+ void testCompareToEpsilon() {
Assertions.assertEquals(0, Precision.compareTo(152.33, 152.32, .011));
Assertions.assertTrue(Precision.compareTo(152.308, 152.32, .011) < 0);
Assertions.assertTrue(Precision.compareTo(152.33, 152.318, .011) > 0);
@@ -281,7 +281,7 @@
}
@Test
- public void testCompareToMaxUlps() {
+ void testCompareToMaxUlps() {
double a = 152.32;
double delta = Math.ulp(a);
for (int i = 0; i <= 10; ++i) {
@@ -318,82 +318,82 @@
}
@Test
- public void testRoundDouble() {
+ void testRoundDouble() {
double x = 1.234567890;
- Assertions.assertEquals(1.23, Precision.round(x, 2), 0.0);
- Assertions.assertEquals(1.235, Precision.round(x, 3), 0.0);
- Assertions.assertEquals(1.2346, Precision.round(x, 4), 0.0);
+ Assertions.assertEquals(1.23, Precision.round(x, 2));
+ Assertions.assertEquals(1.235, Precision.round(x, 3));
+ Assertions.assertEquals(1.2346, Precision.round(x, 4));
// JIRA MATH-151
- Assertions.assertEquals(39.25, Precision.round(39.245, 2), 0.0);
- Assertions.assertEquals(39.24, Precision.round(39.245, 2, RoundingMode.DOWN), 0.0);
+ Assertions.assertEquals(39.25, Precision.round(39.245, 2));
+ Assertions.assertEquals(39.24, Precision.round(39.245, 2, RoundingMode.DOWN));
double xx = 39.0;
xx += 245d / 1000d;
- Assertions.assertEquals(39.25, Precision.round(xx, 2), 0.0);
+ Assertions.assertEquals(39.25, Precision.round(xx, 2));
// BZ 35904
- Assertions.assertEquals(30.1d, Precision.round(30.095d, 2), 0.0d);
- Assertions.assertEquals(30.1d, Precision.round(30.095d, 1), 0.0d);
- Assertions.assertEquals(33.1d, Precision.round(33.095d, 1), 0.0d);
- Assertions.assertEquals(33.1d, Precision.round(33.095d, 2), 0.0d);
- Assertions.assertEquals(50.09d, Precision.round(50.085d, 2), 0.0d);
- Assertions.assertEquals(50.19d, Precision.round(50.185d, 2), 0.0d);
- Assertions.assertEquals(50.01d, Precision.round(50.005d, 2), 0.0d);
- Assertions.assertEquals(30.01d, Precision.round(30.005d, 2), 0.0d);
- Assertions.assertEquals(30.65d, Precision.round(30.645d, 2), 0.0d);
+ Assertions.assertEquals(30.1d, Precision.round(30.095d, 2));
+ Assertions.assertEquals(30.1d, Precision.round(30.095d, 1));
+ Assertions.assertEquals(33.1d, Precision.round(33.095d, 1));
+ Assertions.assertEquals(33.1d, Precision.round(33.095d, 2));
+ Assertions.assertEquals(50.09d, Precision.round(50.085d, 2));
+ Assertions.assertEquals(50.19d, Precision.round(50.185d, 2));
+ Assertions.assertEquals(50.01d, Precision.round(50.005d, 2));
+ Assertions.assertEquals(30.01d, Precision.round(30.005d, 2));
+ Assertions.assertEquals(30.65d, Precision.round(30.645d, 2));
- Assertions.assertEquals(1.24, Precision.round(x, 2, RoundingMode.CEILING), 0.0);
- Assertions.assertEquals(1.235, Precision.round(x, 3, RoundingMode.CEILING), 0.0);
- Assertions.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.CEILING), 0.0);
- Assertions.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.CEILING), 0.0);
- Assertions.assertEquals(-1.234, Precision.round(-x, 3, RoundingMode.CEILING), 0.0);
- Assertions.assertEquals(-1.2345, Precision.round(-x, 4, RoundingMode.CEILING), 0.0);
+ Assertions.assertEquals(1.24, Precision.round(x, 2, RoundingMode.CEILING));
+ Assertions.assertEquals(1.235, Precision.round(x, 3, RoundingMode.CEILING));
+ Assertions.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.CEILING));
+ Assertions.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.CEILING));
+ Assertions.assertEquals(-1.234, Precision.round(-x, 3, RoundingMode.CEILING));
+ Assertions.assertEquals(-1.2345, Precision.round(-x, 4, RoundingMode.CEILING));
- Assertions.assertEquals(1.23, Precision.round(x, 2, RoundingMode.DOWN), 0.0);
- Assertions.assertEquals(1.234, Precision.round(x, 3, RoundingMode.DOWN), 0.0);
- Assertions.assertEquals(1.2345, Precision.round(x, 4, RoundingMode.DOWN), 0.0);
- Assertions.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.DOWN), 0.0);
- Assertions.assertEquals(-1.234, Precision.round(-x, 3, RoundingMode.DOWN), 0.0);
- Assertions.assertEquals(-1.2345, Precision.round(-x, 4, RoundingMode.DOWN), 0.0);
+ Assertions.assertEquals(1.23, Precision.round(x, 2, RoundingMode.DOWN));
+ Assertions.assertEquals(1.234, Precision.round(x, 3, RoundingMode.DOWN));
+ Assertions.assertEquals(1.2345, Precision.round(x, 4, RoundingMode.DOWN));
+ Assertions.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.DOWN));
+ Assertions.assertEquals(-1.234, Precision.round(-x, 3, RoundingMode.DOWN));
+ Assertions.assertEquals(-1.2345, Precision.round(-x, 4, RoundingMode.DOWN));
- Assertions.assertEquals(1.23, Precision.round(x, 2, RoundingMode.FLOOR), 0.0);
- Assertions.assertEquals(1.234, Precision.round(x, 3, RoundingMode.FLOOR), 0.0);
- Assertions.assertEquals(1.2345, Precision.round(x, 4, RoundingMode.FLOOR), 0.0);
- Assertions.assertEquals(-1.24, Precision.round(-x, 2, RoundingMode.FLOOR), 0.0);
- Assertions.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.FLOOR), 0.0);
- Assertions.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.FLOOR), 0.0);
+ Assertions.assertEquals(1.23, Precision.round(x, 2, RoundingMode.FLOOR));
+ Assertions.assertEquals(1.234, Precision.round(x, 3, RoundingMode.FLOOR));
+ Assertions.assertEquals(1.2345, Precision.round(x, 4, RoundingMode.FLOOR));
+ Assertions.assertEquals(-1.24, Precision.round(-x, 2, RoundingMode.FLOOR));
+ Assertions.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.FLOOR));
+ Assertions.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.FLOOR));
- Assertions.assertEquals(1.23, Precision.round(x, 2, RoundingMode.HALF_DOWN), 0.0);
- Assertions.assertEquals(1.235, Precision.round(x, 3, RoundingMode.HALF_DOWN), 0.0);
- Assertions.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.HALF_DOWN), 0.0);
- Assertions.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.HALF_DOWN), 0.0);
- Assertions.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.HALF_DOWN), 0.0);
- Assertions.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.HALF_DOWN), 0.0);
- Assertions.assertEquals(1.234, Precision.round(1.2345, 3, RoundingMode.HALF_DOWN), 0.0);
- Assertions.assertEquals(-1.234, Precision.round(-1.2345, 3, RoundingMode.HALF_DOWN), 0.0);
+ Assertions.assertEquals(1.23, Precision.round(x, 2, RoundingMode.HALF_DOWN));
+ Assertions.assertEquals(1.235, Precision.round(x, 3, RoundingMode.HALF_DOWN));
+ Assertions.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.HALF_DOWN));
+ Assertions.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.HALF_DOWN));
+ Assertions.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.HALF_DOWN));
+ Assertions.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.HALF_DOWN));
+ Assertions.assertEquals(1.234, Precision.round(1.2345, 3, RoundingMode.HALF_DOWN));
+ Assertions.assertEquals(-1.234, Precision.round(-1.2345, 3, RoundingMode.HALF_DOWN));
- Assertions.assertEquals(1.23, Precision.round(x, 2, RoundingMode.HALF_EVEN), 0.0);
- Assertions.assertEquals(1.235, Precision.round(x, 3, RoundingMode.HALF_EVEN), 0.0);
- Assertions.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.HALF_EVEN), 0.0);
- Assertions.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.HALF_EVEN), 0.0);
- Assertions.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.HALF_EVEN), 0.0);
- Assertions.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.HALF_EVEN), 0.0);
- Assertions.assertEquals(1.234, Precision.round(1.2345, 3, RoundingMode.HALF_EVEN), 0.0);
- Assertions.assertEquals(-1.234, Precision.round(-1.2345, 3, RoundingMode.HALF_EVEN), 0.0);
- Assertions.assertEquals(1.236, Precision.round(1.2355, 3, RoundingMode.HALF_EVEN), 0.0);
- Assertions.assertEquals(-1.236, Precision.round(-1.2355, 3, RoundingMode.HALF_EVEN), 0.0);
+ Assertions.assertEquals(1.23, Precision.round(x, 2, RoundingMode.HALF_EVEN));
+ Assertions.assertEquals(1.235, Precision.round(x, 3, RoundingMode.HALF_EVEN));
+ Assertions.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.HALF_EVEN));
+ Assertions.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.HALF_EVEN));
+ Assertions.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.HALF_EVEN));
+ Assertions.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.HALF_EVEN));
+ Assertions.assertEquals(1.234, Precision.round(1.2345, 3, RoundingMode.HALF_EVEN));
+ Assertions.assertEquals(-1.234, Precision.round(-1.2345, 3, RoundingMode.HALF_EVEN));
+ Assertions.assertEquals(1.236, Precision.round(1.2355, 3, RoundingMode.HALF_EVEN));
+ Assertions.assertEquals(-1.236, Precision.round(-1.2355, 3, RoundingMode.HALF_EVEN));
- Assertions.assertEquals(1.23, Precision.round(x, 2, RoundingMode.HALF_UP), 0.0);
- Assertions.assertEquals(1.235, Precision.round(x, 3, RoundingMode.HALF_UP), 0.0);
- Assertions.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.HALF_UP), 0.0);
- Assertions.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.HALF_UP), 0.0);
- Assertions.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.HALF_UP), 0.0);
- Assertions.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.HALF_UP), 0.0);
- Assertions.assertEquals(1.235, Precision.round(1.2345, 3, RoundingMode.HALF_UP), 0.0);
- Assertions.assertEquals(-1.235, Precision.round(-1.2345, 3, RoundingMode.HALF_UP), 0.0);
+ Assertions.assertEquals(1.23, Precision.round(x, 2, RoundingMode.HALF_UP));
+ Assertions.assertEquals(1.235, Precision.round(x, 3, RoundingMode.HALF_UP));
+ Assertions.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.HALF_UP));
+ Assertions.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.HALF_UP));
+ Assertions.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.HALF_UP));
+ Assertions.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.HALF_UP));
+ Assertions.assertEquals(1.235, Precision.round(1.2345, 3, RoundingMode.HALF_UP));
+ Assertions.assertEquals(-1.235, Precision.round(-1.2345, 3, RoundingMode.HALF_UP));
- Assertions.assertEquals(-1.23, Precision.round(-1.23, 2, RoundingMode.UNNECESSARY), 0.0);
- Assertions.assertEquals(1.23, Precision.round(1.23, 2, RoundingMode.UNNECESSARY), 0.0);
+ Assertions.assertEquals(-1.23, Precision.round(-1.23, 2, RoundingMode.UNNECESSARY));
+ Assertions.assertEquals(1.23, Precision.round(1.23, 2, RoundingMode.UNNECESSARY));
try {
Precision.round(1.234, 2, RoundingMode.UNNECESSARY);
@@ -402,28 +402,28 @@
// expected
}
- Assertions.assertEquals(1.24, Precision.round(x, 2, RoundingMode.UP), 0.0);
- Assertions.assertEquals(1.235, Precision.round(x, 3, RoundingMode.UP), 0.0);
- Assertions.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.UP), 0.0);
- Assertions.assertEquals(-1.24, Precision.round(-x, 2, RoundingMode.UP), 0.0);
- Assertions.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.UP), 0.0);
- Assertions.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.UP), 0.0);
+ Assertions.assertEquals(1.24, Precision.round(x, 2, RoundingMode.UP));
+ Assertions.assertEquals(1.235, Precision.round(x, 3, RoundingMode.UP));
+ Assertions.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.UP));
+ Assertions.assertEquals(-1.24, Precision.round(-x, 2, RoundingMode.UP));
+ Assertions.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.UP));
+ Assertions.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.UP));
// MATH-151
- Assertions.assertEquals(39.25, Precision.round(39.245, 2, RoundingMode.HALF_UP), 0.0);
+ Assertions.assertEquals(39.25, Precision.round(39.245, 2, RoundingMode.HALF_UP));
// special values
- Assertions.assertEquals(Double.NaN, Precision.round(Double.NaN, 2), 0.0);
- Assertions.assertEquals(0.0, Precision.round(0.0, 2), 0.0);
- Assertions.assertEquals(Double.POSITIVE_INFINITY, Precision.round(Double.POSITIVE_INFINITY, 2), 0.0);
- Assertions.assertEquals(Double.NEGATIVE_INFINITY, Precision.round(Double.NEGATIVE_INFINITY, 2), 0.0);
+ Assertions.assertEquals(Double.NaN, Precision.round(Double.NaN, 2));
+ Assertions.assertEquals(0.0, Precision.round(0.0, 2));
+ Assertions.assertEquals(Double.POSITIVE_INFINITY, Precision.round(Double.POSITIVE_INFINITY, 2));
+ Assertions.assertEquals(Double.NEGATIVE_INFINITY, Precision.round(Double.NEGATIVE_INFINITY, 2));
// comparison of positive and negative zero is not possible -> always equal thus do string comparison
Assertions.assertEquals("-0.0", Double.toString(Precision.round(-0.0, 0)));
Assertions.assertEquals("-0.0", Double.toString(Precision.round(-1e-10, 0)));
}
@Test
- public void testRepresentableDelta() {
+ void testRepresentableDelta() {
int nonRepresentableCount = 0;
final double x = 100;
final int numTrials = 10000;
@@ -439,13 +439,13 @@
}
@Test
- public void testIssue721() {
+ void testIssue721() {
Assertions.assertEquals(-53, Math.getExponent(Precision.EPSILON));
Assertions.assertEquals(-1022, Math.getExponent(Precision.SAFE_MIN));
}
@Test
- public void testMath475() {
+ void testMath475() {
final double a = 1.7976931348623182E16;
final double b = Math.nextUp(a);
@@ -464,7 +464,7 @@
}
@Test
- public void testMath475Float() {
+ void testMath475Float() {
final float a = 1.7976931348623182E16f;
final float b = Math.nextUp(a);
@@ -483,7 +483,7 @@
}
@Test
- public void testMath843() {
+ void testMath843() {
final double afterEpsilon = Math.nextAfter(Precision.EPSILON,
Double.POSITIVE_INFINITY);
@@ -495,7 +495,7 @@
}
@Test
- public void testMath1127() {
+ void testMath1127() {
Assertions.assertFalse(Precision.equals(2.0, -2.0, 1));
Assertions.assertTrue(Precision.equals(0.0, -0.0, 0));
Assertions.assertFalse(Precision.equals(2.0f, -2.0f, 1));
diff --git a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/complex/SinCosPerformance.java b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/complex/SinCosPerformance.java
index 165fdae..99750b3 100644
--- a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/complex/SinCosPerformance.java
+++ b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/complex/SinCosPerformance.java
@@ -82,7 +82,7 @@
/**
* Contains an array of numbers.
*/
- public static abstract class BaseNumbers extends NumberSize {
+ public abstract static class BaseNumbers extends NumberSize {
/** The numbers. */
protected double[] numbers;
@@ -130,6 +130,7 @@
@Param({"pi", "pi/2", "random", "edge"})
private String type;
+ /** {@inheritDoc} */
@Override
protected double[] createNumbers(SplittableRandom rng) {
DoubleSupplier generator;
@@ -162,6 +163,7 @@
@Param({"1.57079", "3.14159", "10", "100", "1e4", "1e8", "1e16", "1e32"})
private double range;
+ /** {@inheritDoc} */
@Override
protected double[] createNumbers(SplittableRandom rng) {
return rng.doubles(getSize(), -range, range).toArray();
diff --git a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/DoublePrecisionTest.java b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/DoublePrecisionTest.java
index deda670..5da8cbb 100644
--- a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/DoublePrecisionTest.java
+++ b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/DoublePrecisionTest.java
@@ -22,9 +22,9 @@
/**
* Tests for {@link DoublePrecision}.
*/
-public class DoublePrecisionTest {
+class DoublePrecisionTest {
@Test
- public void testSplitAssumptions() {
+ void testSplitAssumptions() {
// The multiplier used to split the double value into high and low parts.
final double scale = (1 << 27) + 1;
// The upper limit above which a number may overflow during the split into a high part.
@@ -40,7 +40,7 @@
}
@Test
- public void testHighPart() {
+ void testHighPart() {
Assertions.assertEquals(Double.NaN, DoublePrecision.highPart(Double.POSITIVE_INFINITY));
Assertions.assertEquals(Double.NaN, DoublePrecision.highPart(Double.NEGATIVE_INFINITY));
Assertions.assertEquals(Double.NaN, DoublePrecision.highPart(Double.NaN));
@@ -50,7 +50,7 @@
}
@Test
- public void testHighPartUnscaled() {
+ void testHighPartUnscaled() {
Assertions.assertEquals(Double.NaN, DoublePrecision.highPartUnscaled(Double.POSITIVE_INFINITY));
Assertions.assertEquals(Double.NaN, DoublePrecision.highPartUnscaled(Double.NEGATIVE_INFINITY));
Assertions.assertEquals(Double.NaN, DoublePrecision.highPartUnscaled(Double.NaN));
@@ -64,7 +64,7 @@
* result as JDK 9 Math.fma(x, y, -x * y) for edge cases.
*/
@Test
- public void testProductLow() {
+ void testProductLow() {
assertProductLow(0.0, 1.0, Math.nextDown(Double.MIN_NORMAL));
assertProductLow(0.0, -1.0, Math.nextDown(Double.MIN_NORMAL));
assertProductLow(Double.NaN, 1.0, Double.POSITIVE_INFINITY);
@@ -75,11 +75,12 @@
}
private static void assertProductLow(double expected, double x, double y) {
+ // Requires a delta of 0.0 to assert -0.0 == 0.0
Assertions.assertEquals(expected, DoublePrecision.productLow(x, y, x * y), 0.0);
}
@Test
- public void testIsNotNormal() {
+ void testIsNotNormal() {
for (double a : new double[] {Double.MAX_VALUE, 1.0, Double.MIN_NORMAL}) {
Assertions.assertFalse(DoublePrecision.isNotNormal(a));
Assertions.assertFalse(DoublePrecision.isNotNormal(-a));
diff --git a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/LinearCombinationAccuracyTest.java b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/LinearCombinationAccuracyTest.java
index befef80..35f45b7 100644
--- a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/LinearCombinationAccuracyTest.java
+++ b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/LinearCombinationAccuracyTest.java
@@ -39,7 +39,7 @@
/**
* Test the accuracy of each implementation of {@link LinearCombination}.
*/
-public class LinearCombinationAccuracyTest {
+class LinearCombinationAccuracyTest {
/**
* The dot product length.
* This must be the same for the accuracy report as the assertions.
@@ -84,7 +84,7 @@
*/
@ParameterizedTest
@MethodSource("provideLinearCombination")
- public void testDotProduct(ND fun, double passC, double failC) {
+ void testDotProduct(ND fun, double passC, double failC) {
final double[] x = new double[LENGTH];
final double[] y = new double[LENGTH];
// Fixed seed to consistency
@@ -125,7 +125,7 @@
*/
@Test
@Disabled("This method is used to output a report of the accuracy of implementations.")
- public void reportRelativeError() throws IOException {
+ void reportRelativeError() throws IOException {
// Ogita et al (2005) Figure 6.2 used length=100, samples=1000 with c in 1 to 1e120.
// Ogita et al (2005) Figure 6.4 used length=1000, samples=2000 with c in 1 to 1e120.
// Here the condition number is in 1e10 to 1e120 as low condition numbers are
diff --git a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/LinearCombinationsTest.java b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/LinearCombinationsTest.java
index f2c99d1..c77490d 100644
--- a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/LinearCombinationsTest.java
+++ b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/arrays/LinearCombinationsTest.java
@@ -38,7 +38,7 @@
/**
* Test each implementation of the LinearCombination interface.
*/
-public class LinearCombinationsTest {
+class LinearCombinationsTest {
/** Double.MIN_VALUE as a BigDecimal. Use string constructor to truncate precision to 4.9e-324. */
private static final BigDecimal MIN = BigDecimal.valueOf(Double.MIN_VALUE);
@@ -66,7 +66,7 @@
@ParameterizedTest
@MethodSource("provideLinearCombination")
- public void testSingleElementArray(ND fun) {
+ void testSingleElementArray(ND fun) {
final double[] a = {1.23456789};
final double[] b = {98765432.1};
@@ -75,7 +75,7 @@
@ParameterizedTest
@MethodSource("provideLinearCombination")
- public void testTwoSums(ND fun) {
+ void testTwoSums(ND fun) {
final BigFraction[] aF = new BigFraction[] {
BigFraction.of(-1321008684645961L, 268435456L),
BigFraction.of(-5774608829631843L, 268435456L),
@@ -117,7 +117,7 @@
@ParameterizedTest
@MethodSource("provideLinearCombination")
- public void testHuge(ND fun) {
+ void testHuge(ND fun) {
final int scale = 971;
final double[] a = new double[] {
-1321008684645961.0 / 268435456.0,
@@ -152,7 +152,7 @@
@ParameterizedTest
@MethodSource("provideLinearCombination")
- public void testArrayVsInline(ND fun) {
+ void testArrayVsInline(ND fun) {
// Assume the instance implements the inline functions
final TwoD fun2 = (TwoD) fun;
final ThreeD fun3 = (ThreeD) fun;
@@ -195,7 +195,7 @@
@ParameterizedTest
@MethodSource("provideLinearCombination")
- public void testNonFinite(ND fun) {
+ void testNonFinite(ND fun) {
final double[][] a = new double[][] {
{1, 2, 3, 4},
{1, Double.POSITIVE_INFINITY, 3, 4},
@@ -359,7 +359,7 @@
* greater in magnitude than the the original number due to round-off in the split.
*/
@Test
- public void testOverflow() {
+ void testOverflow() {
// Create a simple dot product that is different in high precision and has
// values that create a high part above the original number. This can be done using
// a mantissa with almost all bits set to 1.
@@ -423,7 +423,7 @@
* This case is derived from computations on a complex cis number.
*/
@Test
- public void testCisNumber() {
+ void testCisNumber() {
final double theta = 5.992112452678286E-7;
final double x = Math.cos(theta);
final double y = Math.sin(theta);
@@ -439,7 +439,7 @@
* round-off sum in single or 2-fold precision.
*/
@Test
- public void testSumZero() {
+ void testSumZero() {
// Fixed seed for stability
final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP, 876543L);
final int size = 10;
@@ -569,7 +569,7 @@
* Test the clip method does what it specifies.
*/
@Test
- public void testClip() {
+ void testClip() {
// min value is not affected
Assertions.assertEquals(Double.MIN_VALUE, clip(MIN).doubleValue());
Assertions.assertEquals(-Double.MIN_VALUE, clip(MIN.negate()).doubleValue());
diff --git a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FP64Test.java b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FP64Test.java
index 260ecc7..4b47f86 100644
--- a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FP64Test.java
+++ b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FP64Test.java
@@ -22,15 +22,15 @@
/**
* Tests for {@link FP64}.
*/
-public class FP64Test {
+class FP64Test {
@Test
- public void testConsistencyWithDouble() {
+ void testConsistencyWithDouble() {
final double v = -5.67e89;
final Double a = Double.valueOf(v);
final FP64 b = FP64.of(v);
- Assertions.assertEquals(a.doubleValue(), b.doubleValue(), 0d);
- Assertions.assertEquals(a.floatValue(), b.floatValue(), 0f);
+ Assertions.assertEquals(a.doubleValue(), b.doubleValue());
+ Assertions.assertEquals(a.floatValue(), b.floatValue());
Assertions.assertEquals(a.intValue(), b.intValue());
Assertions.assertEquals(a.longValue(), b.longValue());
Assertions.assertEquals(a.byteValue(), b.byteValue());
@@ -38,7 +38,7 @@
}
@Test
- public void testEquals() {
+ void testEquals() {
final FP64 a = FP64.of(1.23);
final FP64 b = FP64.of(4.56);
@@ -54,51 +54,51 @@
}
@Test
- public void testOne() {
- Assertions.assertEquals(1d, FP64.of(-3.4).one().doubleValue(), 0d);
+ void testOne() {
+ Assertions.assertEquals(1d, FP64.of(-3.4).one().doubleValue());
}
@Test
- public void testZero() {
- Assertions.assertEquals(0d, FP64.of(-3.4).zero().doubleValue(), 0d);
+ void testZero() {
+ Assertions.assertEquals(0d, FP64.of(-3.4).zero().doubleValue());
}
@Test
- public void testSubtract() {
+ void testSubtract() {
final double a = 123.4;
final double b = 5678.9;
- Assertions.assertEquals(a - b, FP64.of(a).subtract(FP64.of(b)).doubleValue(), 0d);
+ Assertions.assertEquals(a - b, FP64.of(a).subtract(FP64.of(b)).doubleValue());
}
@Test
- public void testDivide() {
+ void testDivide() {
final double a = 123.4;
final double b = 5678.9;
- Assertions.assertEquals(a / b, FP64.of(a).divide(FP64.of(b)).doubleValue(), 0d);
+ Assertions.assertEquals(a / b, FP64.of(a).divide(FP64.of(b)).doubleValue());
}
@Test
- public void testMultiplyInt() {
+ void testMultiplyInt() {
final double a = 123.4;
final int n = 3456789;
- Assertions.assertEquals(n * a, FP64.of(a).multiply(n).doubleValue(), 0d);
+ Assertions.assertEquals(n * a, FP64.of(a).multiply(n).doubleValue());
}
@Test
- public void testPowInt() {
+ void testPowInt() {
final double a = 123.4;
final int n = 5;
- Assertions.assertEquals(Math.pow(a, n), FP64.of(a).pow(n).doubleValue(), 0d);
+ Assertions.assertEquals(Math.pow(a, n), FP64.of(a).pow(n).doubleValue());
}
@Test
- public void testZeroPow() {
+ void testZeroPow() {
Assertions.assertSame(FP64.of(9876.5).one(), FP64.of(2.3456).pow(0));
}
@Test
- public void testCompare() {
+ void testCompare() {
Assertions.assertTrue(FP64.of(0).compareTo(FP64.of(-1)) > 0);
Assertions.assertTrue(FP64.of(1).compareTo(FP64.of(2)) < 0);
diff --git a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java
index fa46bbc..603a81f 100644
--- a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java
+++ b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java
@@ -28,7 +28,7 @@
/**
* Tests for fields.
*/
-public class FieldParametricTest {
+class FieldParametricTest {
private static Stream<FieldTestData<?>> getList() {
return FieldsList.list().stream();
@@ -36,7 +36,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T> void testAdditionAssociativity(FieldTestData<T> data) {
+ <T> void testAdditionAssociativity(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
T b = data.getB();
@@ -48,7 +48,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T> void testAdditionCommutativity(FieldTestData<T> data) {
+ <T> void testAdditionCommutativity(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
T b = data.getB();
@@ -59,7 +59,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T> void testAdditiveIdentity(FieldTestData<T> data) {
+ <T> void testAdditiveIdentity(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
final T r1 = field.add(a, field.zero());
@@ -69,7 +69,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T> void testAdditiveInverse(FieldTestData<T> data) {
+ <T> void testAdditiveInverse(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
final T r1 = field.add(a, field.negate(a));
@@ -79,7 +79,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T> void testMultiplicationAssociativity(FieldTestData<T> data) {
+ <T> void testMultiplicationAssociativity(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
T b = data.getB();
@@ -91,7 +91,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T> void testMultiplicationCommutativity(FieldTestData<T> data) {
+ <T> void testMultiplicationCommutativity(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
T b = data.getB();
@@ -102,7 +102,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T> void testMultiplicativeIdentity(FieldTestData<T> data) {
+ <T> void testMultiplicativeIdentity(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
final T r1 = field.multiply(a, field.one());
@@ -112,7 +112,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T> void testMultiplicativeInverse(FieldTestData<T> data) {
+ <T> void testMultiplicativeInverse(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
final T r1 = field.multiply(a, field.reciprocal(a));
@@ -122,7 +122,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T> void testDistributivity(FieldTestData<T> data) {
+ <T> void testDistributivity(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
T b = data.getB();
@@ -134,7 +134,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T extends Addition<T>> void testAdd(FieldTestData<T> data) {
+ <T extends Addition<T>> void testAdd(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
T b = data.getB();
@@ -146,7 +146,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T extends Addition<T>> void testSubtract(FieldTestData<T> data) {
+ <T extends Addition<T>> void testSubtract(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
T b = data.getB();
@@ -158,7 +158,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T extends Addition<T>> void testMultiplyInt(FieldTestData<T> data) {
+ <T extends Addition<T>> void testMultiplyInt(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
final int n = 5;
@@ -175,7 +175,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T extends Addition<T>> void testZero(FieldTestData<T> data) {
+ <T extends Addition<T>> void testZero(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
@@ -186,7 +186,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T extends Multiplication<T>> void testMultiply(FieldTestData<T> data) {
+ <T extends Multiplication<T>> void testMultiply(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
T b = data.getB();
@@ -198,7 +198,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T extends Multiplication<T>> void testDivide(FieldTestData<T> data) {
+ <T extends Multiplication<T>> void testDivide(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
T b = data.getB();
@@ -210,7 +210,7 @@
@ParameterizedTest
@MethodSource("getList")
- public <T extends Multiplication<T>> void testOne(FieldTestData<T> data) {
+ <T extends Multiplication<T>> void testOne(FieldTestData<T> data) {
Field<T> field = data.getField();
T a = data.getA();
diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java
index f0bcd27..5ded68e 100644
--- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java
+++ b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java
@@ -28,7 +28,7 @@
/**
* Tests for {@link BigFraction}.
*/
-public class BigFractionTest {
+class BigFractionTest {
/** The zero representation with positive denominator. */
private static final BigFraction ZERO_P = BigFraction.of(0, 1);
@@ -69,7 +69,7 @@
}
@Test
- public void testConstructor() {
+ void testConstructor() {
for (final CommonTestCases.UnaryOperatorTestCase testCase : CommonTestCases.numDenConstructorTestCases()) {
assertFraction(
testCase.expectedNumerator,
@@ -97,7 +97,7 @@
}
@Test
- public void testConstructorZero() {
+ void testConstructorZero() {
Assertions.assertSame(BigFraction.ZERO, BigFraction.from(0.0));
Assertions.assertSame(BigFraction.ZERO, BigFraction.from(0.0, 1e-10, 100));
Assertions.assertSame(BigFraction.ZERO, BigFraction.from(0.0, 100));
@@ -114,7 +114,7 @@
// MATH-179
@Test
- public void testDoubleConstructor() throws Exception {
+ void testDoubleConstructor() throws Exception {
for (final CommonTestCases.DoubleToFractionTestCase testCase : CommonTestCases.doubleConstructorTestCases()) {
assertFraction(
testCase.expectedNumerator,
@@ -148,7 +148,7 @@
// MATH-181
// NUMBERS-147
@Test
- public void testDoubleConstructorWithMaxDenominator() throws Exception {
+ void testDoubleConstructorWithMaxDenominator() throws Exception {
for (final CommonTestCases.DoubleToFractionTestCase testCase : CommonTestCases.doubleMaxDenomConstructorTestCases()) {
assertFraction(
testCase.expectedNumerator,
@@ -168,7 +168,7 @@
}
@Test
- public void testDoubleConstructorThrows() {
+ void testDoubleConstructorThrows() {
final double eps = 1e-5;
final int maxIterations = Integer.MAX_VALUE;
final int maxDenominator = Integer.MAX_VALUE;
@@ -185,7 +185,7 @@
}
@Test
- public void testDoubleConstructorGoldenRatioThrows() {
+ void testDoubleConstructorGoldenRatioThrows() {
// the golden ratio is notoriously a difficult number for continuous fraction
Assertions.assertThrows(FractionException.class,
() -> BigFraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
@@ -194,7 +194,7 @@
// MATH-1029
@Test
- public void testDoubleConstructorWithMaxDenominatorOverFlow() {
+ void testDoubleConstructorWithMaxDenominatorOverFlow() {
Assertions.assertThrows(ArithmeticException.class,
() -> BigFraction.from(1e10, 1000)
);
@@ -204,7 +204,7 @@
}
@Test
- public void testDoubleConstructorOverflow() {
+ void testDoubleConstructorOverflow() {
assertDoubleConstructorOverflow(0.75000000001455192);
assertDoubleConstructorOverflow(1.0e10);
assertDoubleConstructorOverflow(-1.0e10);
@@ -218,7 +218,7 @@
}
@Test
- public void testDoubleConstructorWithEpsilonLimit() throws Exception {
+ void testDoubleConstructorWithEpsilonLimit() throws Exception {
assertFraction(2, 5, BigFraction.from(0.4, 1.0e-5, 100));
assertFraction(3, 5, BigFraction.from(0.6152, 0.02, 100));
@@ -230,7 +230,7 @@
}
@Test
- public void testCompareTo() {
+ void testCompareTo() {
final BigFraction a = BigFraction.of(1, 2);
final BigFraction b = BigFraction.of(1, 3);
final BigFraction c = BigFraction.of(1, 2);
@@ -272,7 +272,7 @@
}
@Test
- public void testDoubleValue() {
+ void testDoubleValue() {
assertDoubleValue(0.5, 1, 2);
assertDoubleValue(-0.5, -1, 2);
assertDoubleValue(-0.5, 1, -2);
@@ -303,7 +303,7 @@
}
@Test
- public void testDoubleValueForSubnormalNumbers() {
+ void testDoubleValueForSubnormalNumbers() {
assertDoubleValue(
//Double.MIN_VALUE * 2/3
Double.MIN_VALUE,
@@ -347,7 +347,7 @@
}
@Test
- public void testDoubleValueForInfinities() {
+ void testDoubleValueForInfinities() {
//the smallest integer that rounds up to Double.POSITIVE_INFINITY
final BigInteger minInf = BigInteger.ONE
.shiftLeft(1024)
@@ -367,7 +367,7 @@
// MATH-744
@Test
- public void testDoubleValueForLargeNumeratorAndDenominator() {
+ void testDoubleValueForLargeNumeratorAndDenominator() {
final BigInteger pow400 = BigInteger.TEN.pow(400);
final BigInteger pow401 = BigInteger.TEN.pow(401);
final BigInteger two = new BigInteger("2");
@@ -379,7 +379,7 @@
// MATH-744
@Test
- public void testFloatValueForLargeNumeratorAndDenominator() {
+ void testFloatValueForLargeNumeratorAndDenominator() {
final BigInteger pow400 = BigInteger.TEN.pow(400);
final BigInteger pow401 = BigInteger.TEN.pow(401);
final BigInteger two = new BigInteger("2");
@@ -390,7 +390,7 @@
}
@Test
- public void testDoubleValueForLargeNumeratorAndSmallDenominator() {
+ void testDoubleValueForLargeNumeratorAndSmallDenominator() {
// NUMBERS-15
final BigInteger pow300 = BigInteger.TEN.pow(300);
final BigInteger pow330 = BigInteger.TEN.pow(330);
@@ -421,7 +421,7 @@
// NUMBERS-15
@Test
- public void testFloatValueForLargeNumeratorAndSmallDenominator() {
+ void testFloatValueForLargeNumeratorAndSmallDenominator() {
final BigInteger pow30 = BigInteger.TEN.pow(30);
final BigInteger pow40 = BigInteger.TEN.pow(40);
final BigFraction large = BigFraction.of(pow40.add(BigInteger.ONE),
@@ -431,7 +431,7 @@
}
@Test
- public void testFloatValue() {
+ void testFloatValue() {
Assertions.assertEquals(0.5f, BigFraction.of(1, 2).floatValue());
Assertions.assertEquals(0.5f, BigFraction.of(-1, -2).floatValue());
Assertions.assertEquals(-0.5f, BigFraction.of(-1, 2).floatValue());
@@ -448,7 +448,7 @@
}
@Test
- public void testIntValue() {
+ void testIntValue() {
Assertions.assertEquals(0, BigFraction.of(1, 2).intValue());
Assertions.assertEquals(0, BigFraction.of(-1, -2).intValue());
Assertions.assertEquals(0, BigFraction.of(-1, 2).intValue());
@@ -464,7 +464,7 @@
}
@Test
- public void testLongValue() {
+ void testLongValue() {
Assertions.assertEquals(0L, BigFraction.of(1, 2).longValue());
Assertions.assertEquals(0L, BigFraction.of(-1, -2).longValue());
Assertions.assertEquals(0L, BigFraction.of(-1, 2).longValue());
@@ -480,7 +480,7 @@
}
@Test
- public void testBigDecimalValue() {
+ void testBigDecimalValue() {
Assertions.assertEquals(new BigDecimal(0.5), BigFraction.of(1, 2).bigDecimalValue());
Assertions.assertEquals(new BigDecimal("0.0003"), BigFraction.of(3, 10000).bigDecimalValue());
Assertions.assertEquals(new BigDecimal("0"), BigFraction.of(1, 3).bigDecimalValue(RoundingMode.DOWN));
@@ -488,7 +488,7 @@
}
@Test
- public void testAbs() {
+ void testAbs() {
for (final CommonTestCases.UnaryOperatorTestCase testCase : CommonTestCases.absTestCases()) {
final BigFraction f = BigFraction.of(testCase.operandNumerator, testCase.operandDenominator);
assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f.abs());
@@ -496,7 +496,7 @@
}
@Test
- public void testReciprocal() {
+ void testReciprocal() {
for (final CommonTestCases.UnaryOperatorTestCase testCase : CommonTestCases.reciprocalTestCases()) {
final BigFraction f = BigFraction.of(testCase.operandNumerator, testCase.operandDenominator);
assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f.reciprocal());
@@ -507,7 +507,7 @@
}
@Test
- public void testNegate() {
+ void testNegate() {
for (final CommonTestCases.UnaryOperatorTestCase testCase : CommonTestCases.negateTestCases()) {
final BigFraction f = BigFraction.of(testCase.operandNumerator, testCase.operandDenominator);
assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f.negate());
@@ -515,7 +515,7 @@
}
@Test
- public void testAdd() {
+ void testAdd() {
for (final CommonTestCases.BinaryOperatorTestCase testCase : CommonTestCases.addFractionTestCases()) {
final BigFraction f1 = BigFraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
final BigFraction f2 = BigFraction.of(testCase.secondOperandNumerator, testCase.secondOperandDenominator);
@@ -539,7 +539,7 @@
}
@Test
- public void testDivide() {
+ void testDivide() {
for (final CommonTestCases.BinaryOperatorTestCase testCase : CommonTestCases.divideByFractionTestCases()) {
final BigFraction f1 = BigFraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
final BigFraction f2 = BigFraction.of(testCase.secondOperandNumerator, testCase.secondOperandDenominator);
@@ -569,7 +569,7 @@
}
@Test
- public void testMultiply() {
+ void testMultiply() {
for (final CommonTestCases.BinaryOperatorTestCase testCase : CommonTestCases.multiplyByFractionTestCases()) {
final BigFraction f1 = BigFraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
final BigFraction f2 = BigFraction.of(testCase.secondOperandNumerator, testCase.secondOperandDenominator);
@@ -588,7 +588,7 @@
}
@Test
- public void testPow() {
+ void testPow() {
for (final CommonTestCases.BinaryIntOperatorTestCase testCase : CommonTestCases.powTestCases()) {
final BigFraction f1 = BigFraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
final int exponent = testCase.secondOperand;
@@ -604,7 +604,7 @@
}
@Test
- public void testSubtract() {
+ void testSubtract() {
for (final CommonTestCases.BinaryOperatorTestCase testCase : CommonTestCases.subtractFractionTestCases()) {
final BigFraction f1 = BigFraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
final BigFraction f2 = BigFraction.of(testCase.secondOperandNumerator, testCase.secondOperandDenominator);
@@ -623,9 +623,9 @@
}
@Test
- public void testEqualsAndHashCode() {
+ void testEqualsAndHashCode() {
final BigFraction zero = BigFraction.of(0, 1);
- Assertions.assertEquals(zero, zero);
+ Assertions.assertTrue(zero.equals(zero));
Assertions.assertFalse(zero.equals(null));
Assertions.assertFalse(zero.equals(new Object()));
Assertions.assertFalse(zero.equals(Double.valueOf(0)));
@@ -685,17 +685,17 @@
}
@Test
- public void testAdditiveNeutral() {
+ void testAdditiveNeutral() {
Assertions.assertEquals(BigFraction.ZERO, BigFraction.ONE.zero());
}
@Test
- public void testMultiplicativeNeutral() {
+ void testMultiplicativeNeutral() {
Assertions.assertEquals(BigFraction.ONE, BigFraction.ZERO.one());
}
@Test
- public void testSerial() {
+ void testSerial() {
final BigFraction[] fractions = {
BigFraction.of(3, 4), BigFraction.ONE, BigFraction.ZERO,
BigFraction.of(17), BigFraction.from(Math.PI, 1000),
@@ -708,7 +708,7 @@
}
@Test
- public void testToString() {
+ void testToString() {
Assertions.assertEquals("0", BigFraction.of(0, 3).toString());
Assertions.assertEquals("0", BigFraction.of(0, -3).toString());
Assertions.assertEquals("3", BigFraction.of(6, 2).toString());
@@ -718,7 +718,7 @@
}
@Test
- public void testParse() {
+ void testParse() {
final String[] validExpressions = new String[] {
"1 / 2",
"-1 / 2",
@@ -770,7 +770,7 @@
}
@Test
- public void testMath340() {
+ void testMath340() {
final BigFraction fractionA = BigFraction.from(0.00131);
final BigFraction fractionB = BigFraction.from(.37).reciprocal();
final BigFraction errorResult = fractionA.multiply(fractionB);
diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/ContinuedFractionTest.java b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/ContinuedFractionTest.java
index 6760894..caa947c 100644
--- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/ContinuedFractionTest.java
+++ b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/ContinuedFractionTest.java
@@ -23,10 +23,10 @@
/**
* Tests for {@link ContinuedFraction}.
*/
-public class ContinuedFractionTest {
+class ContinuedFractionTest {
@Test
- public void testGoldenRatio() throws Exception {
+ void testGoldenRatio() throws Exception {
ContinuedFraction cf = new ContinuedFraction() {
@Override
public double getA(int n, double x) {
@@ -45,7 +45,7 @@
}
@Test
- public void test415Over93() throws Exception {
+ void test415Over93() throws Exception {
// https://en.wikipedia.org/wiki/Continued_fraction
// 415 1
// --- = 4 + ---------
@@ -80,7 +80,7 @@
}
@Test
- public void testMaxIterationsThrows() throws Exception {
+ void testMaxIterationsThrows() throws Exception {
ContinuedFraction cf = new ContinuedFraction() {
@Override
public double getA(int n, double x) {
@@ -101,7 +101,7 @@
}
@Test
- public void testNaNThrows() throws Exception {
+ void testNaNThrows() throws Exception {
// Create a NaN during the iteration
ContinuedFraction cf = new ContinuedFraction() {
@Override
@@ -122,7 +122,7 @@
}
@Test
- public void testInfThrows() throws Exception {
+ void testInfThrows() throws Exception {
// Create an infinity during the iteration:
// a / cPrev => a_1 / b_0 => Double.MAX_VALUE / 0.5
ContinuedFraction cf = new ContinuedFraction() {
@@ -150,7 +150,7 @@
// NUMBERS-46
@Test
- public void testOneIteration() {
+ void testOneIteration() {
ContinuedFraction cf = new ContinuedFraction() {
@Override
public double getA(int n, double x) {
@@ -170,7 +170,7 @@
// NUMBERS-46
@Test
- public void testTwoIterations() {
+ void testTwoIterations() {
ContinuedFraction cf = new ContinuedFraction() {
@Override
public double getA(int n, double x) {
@@ -185,6 +185,6 @@
final double eps = 0.5;
double gr = cf.evaluate(0, eps, 2);
- Assertions.assertEquals(1.5, gr, 0d);
+ Assertions.assertEquals(1.5, gr);
}
}
diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionTest.java b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionTest.java
index f26a616..1a2a1b6 100644
--- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionTest.java
+++ b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionTest.java
@@ -28,7 +28,7 @@
/**
* Tests for {@link Fraction}.
*/
-public class FractionTest {
+class FractionTest {
/** The zero representation with positive denominator. */
private static final Fraction ZERO_P = Fraction.of(0, 1);
@@ -49,7 +49,7 @@
}
@Test
- public void testConstructor() {
+ void testConstructor() {
for (final CommonTestCases.UnaryOperatorTestCase testCase : CommonTestCases.numDenConstructorTestCases()) {
assertFraction(
testCase.expectedNumerator,
@@ -69,7 +69,7 @@
}
@Test
- public void testConstructorZero() {
+ void testConstructorZero() {
Assertions.assertSame(Fraction.ZERO, Fraction.from(0.0));
Assertions.assertSame(Fraction.ZERO, Fraction.from(0.0, 1e-10, 100));
Assertions.assertSame(Fraction.ZERO, Fraction.from(0.0, 100));
@@ -80,7 +80,7 @@
// MATH-179
@Test
- public void testDoubleConstructor() throws Exception {
+ void testDoubleConstructor() throws Exception {
for (final CommonTestCases.DoubleToFractionTestCase testCase : CommonTestCases.doubleConstructorTestCases()) {
assertFraction(
testCase.expectedNumerator,
@@ -101,7 +101,7 @@
// MATH-181
// NUMBERS-147
@Test
- public void testDoubleConstructorWithMaxDenominator() throws Exception {
+ void testDoubleConstructorWithMaxDenominator() throws Exception {
for (final CommonTestCases.DoubleToFractionTestCase testCase : CommonTestCases.doubleMaxDenomConstructorTestCases()) {
assertFraction(
testCase.expectedNumerator,
@@ -120,7 +120,7 @@
}
@Test
- public void testDoubleConstructorThrows() {
+ void testDoubleConstructorThrows() {
final double eps = 1e-5;
final int maxIterations = Integer.MAX_VALUE;
final int maxDenominator = Integer.MAX_VALUE;
@@ -137,7 +137,7 @@
}
@Test
- public void testDoubleConstructorGoldenRatioThrows() {
+ void testDoubleConstructorGoldenRatioThrows() {
// the golden ratio is notoriously a difficult number for continuous fraction
Assertions.assertThrows(ArithmeticException.class,
() -> Fraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
@@ -146,7 +146,7 @@
// MATH-1029
@Test
- public void testDoubleConstructorWithMaxDenominatorOverFlow() {
+ void testDoubleConstructorWithMaxDenominatorOverFlow() {
Assertions.assertThrows(ArithmeticException.class,
() -> Fraction.from(1e10, 1000)
);
@@ -156,7 +156,7 @@
}
@Test
- public void testDoubleConstructorOverflow() {
+ void testDoubleConstructorOverflow() {
assertDoubleConstructorOverflow(0.75000000001455192);
assertDoubleConstructorOverflow(1.0e10);
assertDoubleConstructorOverflow(-1.0e10);
@@ -170,7 +170,7 @@
}
@Test
- public void testDoubleConstructorWithEpsilonLimit() throws Exception {
+ void testDoubleConstructorWithEpsilonLimit() throws Exception {
assertFraction(2, 5, Fraction.from(0.4, 1.0e-5, 100));
assertFraction(3, 5, Fraction.from(0.6152, 0.02, 100));
@@ -182,7 +182,7 @@
}
@Test
- public void testCompareTo() {
+ void testCompareTo() {
final Fraction a = Fraction.of(1, 2);
final Fraction b = Fraction.of(1, 3);
final Fraction c = Fraction.of(1, 2);
@@ -224,7 +224,7 @@
}
@Test
- public void testDoubleValue() {
+ void testDoubleValue() {
assertDoubleValue(0.5, 1, 2);
assertDoubleValue(-0.5, -1, 2);
assertDoubleValue(-0.5, 1, -2);
@@ -237,7 +237,7 @@
}
@Test
- public void testFloatValue() {
+ void testFloatValue() {
Assertions.assertEquals(0.5f, Fraction.of(1, 2).floatValue());
Assertions.assertEquals(0.5f, Fraction.of(-1, -2).floatValue());
Assertions.assertEquals(-0.5f, Fraction.of(-1, 2).floatValue());
@@ -254,7 +254,7 @@
}
@Test
- public void testIntValue() {
+ void testIntValue() {
Assertions.assertEquals(0, Fraction.of(1, 2).intValue());
Assertions.assertEquals(0, Fraction.of(-1, -2).intValue());
Assertions.assertEquals(0, Fraction.of(-1, 2).intValue());
@@ -275,7 +275,7 @@
}
@Test
- public void testLongValue() {
+ void testLongValue() {
Assertions.assertEquals(0L, Fraction.of(1, 2).longValue());
Assertions.assertEquals(0L, Fraction.of(-1, -2).longValue());
Assertions.assertEquals(0L, Fraction.of(-1, 2).longValue());
@@ -296,7 +296,7 @@
}
@Test
- public void testAbs() {
+ void testAbs() {
for (final CommonTestCases.UnaryOperatorTestCase testCase : CommonTestCases.absTestCases()) {
final Fraction f = Fraction.of(testCase.operandNumerator, testCase.operandDenominator);
assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f.abs());
@@ -304,7 +304,7 @@
}
@Test
- public void testReciprocal() {
+ void testReciprocal() {
for (final CommonTestCases.UnaryOperatorTestCase testCase : CommonTestCases.reciprocalTestCases()) {
final Fraction f = Fraction.of(testCase.operandNumerator, testCase.operandDenominator);
assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f.reciprocal());
@@ -315,7 +315,7 @@
}
@Test
- public void testNegate() {
+ void testNegate() {
for (final CommonTestCases.UnaryOperatorTestCase testCase : CommonTestCases.negateTestCases()) {
final Fraction f = Fraction.of(testCase.operandNumerator, testCase.operandDenominator);
assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f.negate());
@@ -330,7 +330,7 @@
}
@Test
- public void testAdd() {
+ void testAdd() {
for (final CommonTestCases.BinaryOperatorTestCase testCase : CommonTestCases.addFractionTestCases()) {
final Fraction f1 = Fraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
final Fraction f2 = Fraction.of(testCase.secondOperandNumerator, testCase.secondOperandDenominator);
@@ -361,7 +361,7 @@
}
@Test
- public void testDivide() {
+ void testDivide() {
for (final CommonTestCases.BinaryOperatorTestCase testCase : CommonTestCases.divideByFractionTestCases()) {
final Fraction f1 = Fraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
final Fraction f2 = Fraction.of(testCase.secondOperandNumerator, testCase.secondOperandDenominator);
@@ -390,7 +390,7 @@
}
@Test
- public void testMultiply() {
+ void testMultiply() {
for (final CommonTestCases.BinaryOperatorTestCase testCase : CommonTestCases.multiplyByFractionTestCases()) {
final Fraction f1 = Fraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
final Fraction f2 = Fraction.of(testCase.secondOperandNumerator, testCase.secondOperandDenominator);
@@ -416,7 +416,7 @@
}
@Test
- public void testPow() {
+ void testPow() {
for (final CommonTestCases.BinaryIntOperatorTestCase testCase : CommonTestCases.powTestCases()) {
final Fraction f1 = Fraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
final int exponent = testCase.secondOperand;
@@ -430,7 +430,7 @@
}
@Test
- public void testSubtract() {
+ void testSubtract() {
for (final CommonTestCases.BinaryOperatorTestCase testCase : CommonTestCases.subtractFractionTestCases()) {
final Fraction f1 = Fraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
final Fraction f2 = Fraction.of(testCase.secondOperandNumerator, testCase.secondOperandDenominator);
@@ -461,10 +461,10 @@
}
@Test
- public void testEqualsAndHashCode() {
+ void testEqualsAndHashCode() {
final Fraction zero = Fraction.of(0, 1);
- Assertions.assertEquals(zero, zero);
- Assertions.assertNotEquals(zero, null);
+ Assertions.assertTrue(zero.equals(zero));
+ Assertions.assertFalse(zero.equals(null));
Assertions.assertFalse(zero.equals(new Object()));
Assertions.assertFalse(zero.equals(Double.valueOf(0)));
@@ -534,17 +534,17 @@
}
@Test
- public void testAdditiveNeutral() {
+ void testAdditiveNeutral() {
Assertions.assertEquals(Fraction.ZERO, Fraction.ONE.zero());
}
@Test
- public void testMultiplicativeNeutral() {
+ void testMultiplicativeNeutral() {
Assertions.assertEquals(Fraction.ONE, Fraction.ZERO.one());
}
@Test
- public void testSerial() {
+ void testSerial() {
final Fraction[] fractions = {
Fraction.of(3, 4), Fraction.ONE, Fraction.ZERO,
Fraction.of(17), Fraction.from(Math.PI, 1000),
@@ -557,7 +557,7 @@
}
@Test
- public void testToString() {
+ void testToString() {
Assertions.assertEquals("0", Fraction.of(0, 3).toString());
Assertions.assertEquals("0", Fraction.of(0, -3).toString());
Assertions.assertEquals("3", Fraction.of(6, 2).toString());
@@ -567,7 +567,7 @@
}
@Test
- public void testParse() {
+ void testParse() {
final String[] validExpressions = new String[] {
"1 / 2",
"-1 / 2",
@@ -614,7 +614,7 @@
}
@Test
- public void testMath1261() {
+ void testMath1261() {
final Fraction a = Fraction.of(Integer.MAX_VALUE, 2);
assertFraction(Integer.MAX_VALUE, 1, a.multiply(2));
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java
index 02d285f..48ecd76 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java
@@ -22,9 +22,9 @@
/**
* Tests for {@link Digamma}.
*/
-public class DigammaTest {
+class DigammaTest {
@Test
- public void testDigammaLargeArgs() {
+ void testDigammaLargeArgs() {
double eps = 1e-8;
Assertions.assertEquals(4.6001618527380874002, Digamma.value(100), eps);
Assertions.assertEquals(3.9019896734278921970, Digamma.value(50), eps);
@@ -41,7 +41,7 @@
}
@Test
- public void testDigammaSmallArgs() {
+ void testDigammaSmallArgs() {
// values for negative powers of 10 from 1 to 30 as computed by webMathematica with 20 digits.
// For example, to compute trigamma($i) = Polygamma(1, $i), use
//
@@ -58,7 +58,7 @@
}
@Test
- public void testDigammaZero() {
+ void testDigammaZero() {
// webMathematica states Complexinfinity.
// The value computed is Double.NEGATIVE_INFINITY but we leave this as a test for infinity
// since the next value down -Double.MIN_VALUE is Double.POSITIVE_INFINITY indicating
@@ -67,7 +67,7 @@
}
@Test
- public void testDigammaNonRealArgs() {
+ void testDigammaNonRealArgs() {
Assertions.assertTrue(Double.isNaN(Digamma.value(Double.NaN)));
Assertions.assertTrue(Double.isInfinite(Digamma.value(Double.POSITIVE_INFINITY)));
Assertions.assertTrue(Double.isInfinite(Digamma.value(Double.NEGATIVE_INFINITY)));
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfDifferenceTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfDifferenceTest.java
index da9bf8a..322d6cf 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfDifferenceTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfDifferenceTest.java
@@ -22,13 +22,13 @@
/**
* Tests for {@link ErfDifference}.
*/
-public class ErfDifferenceTest {
+class ErfDifferenceTest {
/**
* Test the implementation of ErfDifference.value(double, double) for consistency
* with results obtained from Erf.value(double) and Erfc.value(double).
*/
@Test
- public void testTwoArgumentErf() {
+ void testTwoArgumentErf() {
final double[] xi = new double[] {-2, -1, -0.9, -0.1, 0, 0.1, 0.9, 1, 2};
for (double x1 : xi) {
for (double x2 : xi) {
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfTest.java
index c1a021d..049ca25 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfTest.java
@@ -22,9 +22,9 @@
/**
* Tests for {@link Erf}.
*/
-public class ErfTest {
+class ErfTest {
@Test
- public void testErf0() {
+ void testErf0() {
double actual = Erf.value(0);
double expected = 0;
Assertions.assertEquals(expected, actual, 1e-15);
@@ -32,7 +32,7 @@
}
@Test
- public void testErf1960() {
+ void testErf1960() {
double x = 1.960 / Math.sqrt(2);
double actual = Erf.value(x);
double expected = 0.95;
@@ -46,7 +46,7 @@
}
@Test
- public void testErf2576() {
+ void testErf2576() {
double x = 2.576 / Math.sqrt(2);
double actual = Erf.value(x);
double expected = 0.99;
@@ -60,7 +60,7 @@
}
@Test
- public void testErf2807() {
+ void testErf2807() {
double x = 2.807 / Math.sqrt(2);
double actual = Erf.value(x);
double expected = 0.995;
@@ -74,7 +74,7 @@
}
@Test
- public void testErf3291() {
+ void testErf3291() {
double x = 3.291 / Math.sqrt(2);
double actual = Erf.value(x);
double expected = 0.999;
@@ -91,7 +91,7 @@
* MATH-301, MATH-456
*/
@Test
- public void testLargeValues() {
+ void testLargeValues() {
for (int i = 1; i < 200; i *= 10) {
double result = Erf.value(i);
Assertions.assertFalse(Double.isNaN(result));
@@ -106,10 +106,10 @@
Assertions.assertFalse(Double.isNaN(result));
Assertions.assertTrue(result >= 1 && result <= 2);
}
- Assertions.assertEquals(-1, Erf.value(Double.NEGATIVE_INFINITY), 0);
- Assertions.assertEquals(1, Erf.value(Double.POSITIVE_INFINITY), 0);
- Assertions.assertEquals(2, Erfc.value(Double.NEGATIVE_INFINITY), 0);
- Assertions.assertEquals(0, Erfc.value(Double.POSITIVE_INFINITY), 0);
+ Assertions.assertEquals(-1, Erf.value(Double.NEGATIVE_INFINITY));
+ Assertions.assertEquals(1, Erf.value(Double.POSITIVE_INFINITY));
+ Assertions.assertEquals(2, Erfc.value(Double.NEGATIVE_INFINITY));
+ Assertions.assertEquals(0, Erfc.value(Double.POSITIVE_INFINITY));
}
/**
@@ -117,7 +117,7 @@
* (Apple OSX packaged version) erfl (extended precision erf).
*/
@Test
- public void testErfGnu() {
+ void testErfGnu() {
final double tol = 1E-15;
final double[] gnuValues = new double[] {
-1, -1, -1, -1, -1,
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfcTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfcTest.java
index 1257152..81be557 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfcTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfcTest.java
@@ -22,13 +22,13 @@
/**
* Tests for {@link Erfc}.
*/
-public class ErfcTest {
+class ErfcTest {
/**
* Compare erfc against reference values computed using GCC 4.2.1
* (Apple OSX packaged version) erfcl (extended precision erfc).
*/
@Test
- public void testErfcGnu() {
+ void testErfcGnu() {
final double tol = 1e-15;
final double[] gnuValues = new double[] {
2, 2, 2, 2, 2,
@@ -56,7 +56,7 @@
* http//www.jstatsoft.org/v11/a05/paper
*/
@Test
- public void testErfcMaple() {
+ void testErfcMaple() {
double[][] ref = new double[][] {
{0.1, 4.60172162722971e-01},
{1.2, 1.15069670221708e-01},
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/GammaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/GammaTest.java
index f14606b..3da8b6e 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/GammaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/GammaTest.java
@@ -22,7 +22,7 @@
/**
* Tests for {@link Gamma}.
*/
-public class GammaTest {
+class GammaTest {
/**
* Reference data for the {@link Gamma#value(double)} function. This
* data was generated with the following <a
@@ -507,7 +507,7 @@
};
@Test
- public void testGamma() {
+ void testGamma() {
for (int i = 0; i < GAMMA_REF.length; i++) {
final double[] ref = GAMMA_REF[i];
final double x = ref[0];
@@ -532,14 +532,14 @@
}
@Test
- public void testGammaNegativeInteger() {
+ void testGammaNegativeInteger() {
for (int i = -100; i <= 0; i++) {
Assertions.assertTrue(Double.isNaN(Gamma.value(i)), Integer.toString(i));
}
}
@Test
- public void testGammaNegativeDouble() {
+ void testGammaNegativeDouble() {
// check that the gamma function properly switches sign
// see: https://en.wikipedia.org/wiki/Gamma_function
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InvGamma1pm1Test.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InvGamma1pm1Test.java
index d99b316..868202c 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InvGamma1pm1Test.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InvGamma1pm1Test.java
@@ -22,7 +22,7 @@
/**
* Tests for {@link InvGamma1pm1}.
*/
-public class InvGamma1pm1Test {
+class InvGamma1pm1Test {
/**
* <p>
* Reference values for the {@link InvGamma1pm1#value(double)} method.
@@ -65,7 +65,7 @@
};
@Test
- public void testInvGamma1pm1() {
+ void testInvGamma1pm1() {
final int ulps = 3;
for (int i = 0; i < INV_GAMMA1P_M1_REF.length; i++) {
final double[] ref = INV_GAMMA1P_M1_REF[i];
@@ -78,14 +78,14 @@
}
@Test
- public void testInvGamma1pm1Precondition1() {
+ void testInvGamma1pm1Precondition1() {
Assertions.assertThrows(GammaException.class,
() -> InvGamma1pm1.value(-0.51)
);
}
@Test
- public void testInvGamma1pm1Precondition2() {
+ void testInvGamma1pm1Precondition2() {
Assertions.assertThrows(GammaException.class,
() -> InvGamma1pm1.value(1.51)
);
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfTest.java
index af2295d..33830e1 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfTest.java
@@ -22,16 +22,16 @@
/**
* Tests for {@link InverseErf}.
*/
-public class InverseErfTest {
+class InverseErfTest {
@Test
- public void testErfInvNaN() {
+ void testErfInvNaN() {
Assertions.assertTrue(Double.isNaN(InverseErf.value(-1.001)));
Assertions.assertTrue(Double.isNaN(InverseErf.value(+1.001)));
Assertions.assertTrue(Double.isNaN(InverseErf.value(Double.NaN)));
}
@Test
- public void testErfInvInfinite() {
+ void testErfInvInfinite() {
Assertions.assertTrue(Double.isInfinite(InverseErf.value(-1)));
Assertions.assertTrue(InverseErf.value(-1) < 0);
Assertions.assertTrue(Double.isInfinite(InverseErf.value(+1)));
@@ -39,7 +39,7 @@
}
@Test
- public void testErfInv() {
+ void testErfInv() {
for (double x = -5.9; x < 5.9; x += 0.01) {
final double y = Erf.value(x);
final double dydx = 2 * Math.exp(-x * x) / Math.sqrt(Math.PI);
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfcTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfcTest.java
index a902927..a2927e8 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfcTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfcTest.java
@@ -22,15 +22,15 @@
/**
* Tests for {@link InverseErfc}.
*/
-public class InverseErfcTest {
+class InverseErfcTest {
@Test
- public void testErfcInvNaN() {
+ void testErfcInvNaN() {
Assertions.assertTrue(Double.isNaN(InverseErfc.value(-0.001)));
Assertions.assertTrue(Double.isNaN(InverseErfc.value(+2.001)));
}
@Test
- public void testErfcInvInfinite() {
+ void testErfcInvInfinite() {
Assertions.assertTrue(Double.isInfinite(InverseErfc.value(-0)));
Assertions.assertTrue(InverseErfc.value(0) > 0);
Assertions.assertTrue(Double.isInfinite(InverseErfc.value(+2)));
@@ -38,7 +38,7 @@
}
@Test
- public void testErfcInv() {
+ void testErfcInv() {
for (double x = -5.85; x < 5.9; x += 0.01) {
final double y = Erfc.value(x);
final double dydxAbs = 2 * Math.exp(-x * x) / Math.sqrt(Math.PI);
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LanczosApproximationTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LanczosApproximationTest.java
index b9680fe..9f8d576 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LanczosApproximationTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LanczosApproximationTest.java
@@ -22,18 +22,18 @@
/**
* Tests for {@link LanczosApproximation}.
*/
-public class LanczosApproximationTest {
+class LanczosApproximationTest {
@Test
- public void testG() {
- Assertions.assertEquals(607d / 128d, LanczosApproximation.g(), 0d);
+ void testG() {
+ Assertions.assertEquals(607d / 128d, LanczosApproximation.g());
}
@Test
- public void testSomeValues() {
+ void testSomeValues() {
// Given that few values are checked, this test would only serve
// as early warning of unexpected changes to the current code.
- Assertions.assertEquals(29.020294557631818d, LanczosApproximation.value(0.1d), 0d);
- Assertions.assertEquals(13.14778027539684d, LanczosApproximation.value(1.0d), 0d);
- Assertions.assertEquals(7.897828855157814d, LanczosApproximation.value(2.0d), 0d);
+ Assertions.assertEquals(29.020294557631818d, LanczosApproximation.value(0.1d));
+ Assertions.assertEquals(13.14778027539684d, LanczosApproximation.value(1.0d));
+ Assertions.assertEquals(7.897828855157814d, LanczosApproximation.value(2.0d));
}
}
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogBetaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogBetaTest.java
index aebaeab..114d055 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogBetaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogBetaTest.java
@@ -25,7 +25,7 @@
/**
* Tests for {@link LogBeta}.
*/
-public class LogBetaTest {
+class LogBetaTest {
private static final double[][] LOG_BETA_REF = {
{0.125, 0.125, 2.750814190409515},
{0.125, 0.25, 2.444366899981226},
@@ -534,7 +534,7 @@
};
@Test
- public void testLogBeta() {
+ void testLogBeta() {
final int ulps = 3;
for (int i = 0; i < LOG_BETA_REF.length; i++) {
final double[] ref = LOG_BETA_REF[i];
@@ -550,37 +550,37 @@
}
@Test
- public void testLogBetaNanPositive() {
+ void testLogBetaNanPositive() {
testLogBeta(Double.NaN, Double.NaN, 2);
}
@Test
- public void testLogBetaPositiveNan() {
+ void testLogBetaPositiveNan() {
testLogBeta(Double.NaN, 1, Double.NaN);
}
@Test
- public void testLogBetaNegativePositive() {
+ void testLogBetaNegativePositive() {
testLogBeta(Double.NaN, -1, 2);
}
@Test
- public void testLogBetaPositiveNegative() {
+ void testLogBetaPositiveNegative() {
testLogBeta(Double.NaN, 1, -2);
}
@Test
- public void testLogBetaZeroPositive() {
+ void testLogBetaZeroPositive() {
testLogBeta(Double.NaN, 0, 2);
}
@Test
- public void testLogBetaPositiveZero() {
+ void testLogBetaPositiveZero() {
testLogBeta(Double.NaN, 1, 0);
}
@Test
- public void testLogBetaPositivePositive() {
+ void testLogBetaPositivePositive() {
testLogBeta(-0.693147180559945, 1, 2);
}
@@ -616,7 +616,7 @@
}
@Test
- public void testLogGammaMinusLogGammaSum() {
+ void testLogGammaMinusLogGammaSum() {
final int ulps = 4;
for (int i = 0; i < LOG_GAMMA_MINUS_LOG_GAMMA_SUM_REF.length; i++) {
final double[] ref = LOG_GAMMA_MINUS_LOG_GAMMA_SUM_REF[i];
@@ -632,14 +632,14 @@
}
@Test
- public void testLogGammaMinusLogGammaSumPrecondition1() {
+ void testLogGammaMinusLogGammaSumPrecondition1() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> logGammaMinusLogGammaSum(-1, 8)
);
}
@Test
- public void testLogGammaMinusLogGammaSumPrecondition2() {
+ void testLogGammaMinusLogGammaSumPrecondition2() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> logGammaMinusLogGammaSum(1, 7)
);
@@ -671,7 +671,7 @@
}
@Test
- public void testSumDeltaMinusDeltaSum() {
+ void testSumDeltaMinusDeltaSum() {
final int ulps = 3;
for (int i = 0; i < SUM_DELTA_MINUS_DELTA_SUM_REF.length; i++) {
final double[] ref = SUM_DELTA_MINUS_DELTA_SUM_REF[i];
@@ -687,14 +687,14 @@
}
@Test
- public void testSumDeltaMinusDeltaSumPrecondition1() {
+ void testSumDeltaMinusDeltaSumPrecondition1() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> sumDeltaMinusDeltaSum(9, 10)
);
}
@Test
- public void testSumDeltaMinusDeltaSumPrecondition2() {
+ void testSumDeltaMinusDeltaSumPrecondition2() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> sumDeltaMinusDeltaSum(10, 9)
);
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGamma1pTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGamma1pTest.java
index 33ac6ad..9cf1b29 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGamma1pTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGamma1pTest.java
@@ -22,7 +22,7 @@
/**
* Tests for {@link LogGamma1p}.
*/
-public class LogGamma1pTest {
+class LogGamma1pTest {
private static final double[][] LOG_GAMMA1P_REF = {
{-0.5, .5723649429247001},
{-0.375, .3608294954889402},
@@ -44,7 +44,7 @@
};
@Test
- public void testLogGamma1p() {
+ void testLogGamma1p() {
final int ulps = 3;
for (int i = 0; i < LOG_GAMMA1P_REF.length; i++) {
final double[] ref = LOG_GAMMA1P_REF[i];
@@ -57,14 +57,14 @@
}
@Test
- public void testLogGamma1pPrecondition1() {
+ void testLogGamma1pPrecondition1() {
Assertions.assertThrows(GammaException.class,
() -> LogGamma1p.value(-0.51)
);
}
@Test
- public void testLogGamma1pPrecondition2() {
+ void testLogGamma1pPrecondition2() {
Assertions.assertThrows(GammaException.class,
() -> LogGamma1p.value(1.51)
);
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaSumTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaSumTest.java
index 9bba2b0..e21a70d 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaSumTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaSumTest.java
@@ -22,7 +22,7 @@
/**
* Tests for {@link LogGammaSum}.
*/
-public class LogGammaSumTest {
+class LogGammaSumTest {
/**
* Reference data for the {@link LogGammaSum#value(double, double)}
* function. This data was generated with the following
@@ -129,7 +129,7 @@
};
@Test
- public void testLogGammaSum() {
+ void testLogGammaSum() {
final int ulps = 2;
for (int i = 0; i < LOG_GAMMA_SUM_REF.length; i++) {
final double[] ref = LOG_GAMMA_SUM_REF[i];
@@ -145,28 +145,28 @@
}
@Test
- public void testLogGammaSumPrecondition1() {
+ void testLogGammaSumPrecondition1() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> LogGammaSum.value(0, 1)
);
}
@Test
- public void testLogGammaSumPrecondition2() {
+ void testLogGammaSumPrecondition2() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> LogGammaSum.value(3, 1)
);
}
@Test
- public void testLogGammaSumPrecondition3() {
+ void testLogGammaSumPrecondition3() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> LogGammaSum.value(1, 0)
);
}
@Test
- public void testLogGammaSumPrecondition4() {
+ void testLogGammaSumPrecondition4() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> LogGammaSum.value(1, 3)
);
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaTest.java
index 698d8e8..3f18410 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaTest.java
@@ -22,7 +22,7 @@
/**
* Tests for {@link LogGamma}.
*/
-public class LogGammaTest {
+class LogGammaTest {
/**
* Reference data for the {@link Gamma#logGamma(double)} function. This data
* was generated with the following <a
@@ -176,27 +176,27 @@
};
@Test
- public void testLogGammaNan() {
+ void testLogGammaNan() {
testLogGamma(Double.NaN, Double.NaN);
}
@Test
- public void testLogGammaNegative() {
+ void testLogGammaNegative() {
testLogGamma(Double.NaN, -1.0);
}
@Test
- public void testLogGammaZero() {
+ void testLogGammaZero() {
testLogGamma(Double.NaN, 0.0);
}
@Test
- public void testLogGammaPositive() {
+ void testLogGammaPositive() {
testLogGamma(0.6931471805599457, 3.0);
}
@Test
- public void testLogGamma() {
+ void testLogGamma() {
final int ulps = 3;
for (int i = 0; i < LOG_GAMMA_REF.length; i++) {
final double[] data = LOG_GAMMA_REF[i];
@@ -214,12 +214,12 @@
}
@Test
- public void testLogGammaPrecondition1() {
+ void testLogGammaPrecondition1() {
Assertions.assertTrue(Double.isNaN(LogGamma.value(0.0)));
}
@Test
- public void testLogGammaPrecondition2() {
+ void testLogGammaPrecondition2() {
Assertions.assertTrue(Double.isNaN(LogGamma.value(-1.0)));
}
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/RegularizedBetaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/RegularizedBetaTest.java
index 7fdeaed..1fc6304 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/RegularizedBetaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/RegularizedBetaTest.java
@@ -22,72 +22,72 @@
/**
* Tests for {@link RegularizedBeta}.
*/
-public class RegularizedBetaTest {
+class RegularizedBetaTest {
@Test
- public void testRegularizedBetaNanPositivePositive() {
+ void testRegularizedBetaNanPositivePositive() {
testRegularizedBeta(Double.NaN, Double.NaN, 1.0, 1.0);
}
@Test
- public void testRegularizedBetaPositiveNanPositive() {
+ void testRegularizedBetaPositiveNanPositive() {
testRegularizedBeta(Double.NaN, 0.5, Double.NaN, 1.0);
}
@Test
- public void testRegularizedBetaPositivePositiveNan() {
+ void testRegularizedBetaPositivePositiveNan() {
testRegularizedBeta(Double.NaN, 0.5, 1.0, Double.NaN);
}
@Test
- public void testRegularizedBetaNegativePositivePositive() {
+ void testRegularizedBetaNegativePositivePositive() {
testRegularizedBeta(Double.NaN, -0.5, 1.0, 2.0);
}
@Test
- public void testRegularizedBetaPositiveNegativePositive() {
+ void testRegularizedBetaPositiveNegativePositive() {
testRegularizedBeta(Double.NaN, 0.5, -1.0, 2.0);
}
@Test
- public void testRegularizedBetaPositivePositiveNegative() {
+ void testRegularizedBetaPositivePositiveNegative() {
testRegularizedBeta(Double.NaN, 0.5, 1.0, -2.0);
}
@Test
- public void testRegularizedBetaZeroPositivePositive() {
+ void testRegularizedBetaZeroPositivePositive() {
testRegularizedBeta(0.0, 0.0, 1.0, 2.0);
}
@Test
- public void testRegularizedBetaPositiveZeroPositive() {
+ void testRegularizedBetaPositiveZeroPositive() {
testRegularizedBeta(Double.NaN, 0.5, 0.0, 2.0);
}
@Test
- public void testRegularizedBetaPositivePositiveZero() {
+ void testRegularizedBetaPositivePositiveZero() {
testRegularizedBeta(Double.NaN, 0.5, 1.0, 0.0);
}
@Test
- public void testRegularizedBetaAboveOnePositivePositive() {
+ void testRegularizedBetaAboveOnePositivePositive() {
testRegularizedBeta(Double.NaN, 1.5, 1.0, 2.0);
}
@Test
- public void testRegularizedBetaPositivePositivePositive() {
+ void testRegularizedBetaPositivePositivePositive() {
testRegularizedBeta(0.75, 0.5, 1.0, 2.0);
}
@Test
- public void testRegularizedBetaTinyArgument() {
+ void testRegularizedBetaTinyArgument() {
double actual = RegularizedBeta.value(1e-17, 1.0, 1e12);
// This value is from R: pbeta(1e-17,1,1e12)
Assertions.assertEquals(9.999950000166648e-6, actual, 1e-16);
}
@Test
- public void testMath1067() {
+ void testMath1067() {
final double x = 0.22580645161290325;
final double a = 64.33333333333334;
final double b = 223;
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/RegularizedGammaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/RegularizedGammaTest.java
index ca8e895..e461a1a 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/RegularizedGammaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/RegularizedGammaTest.java
@@ -22,44 +22,44 @@
/**
* Tests for {@link RegularizedGamma}.
*/
-public class RegularizedGammaTest {
+class RegularizedGammaTest {
@Test
- public void testRegularizedGammaNanPositive() {
+ void testRegularizedGammaNanPositive() {
testRegularizedGamma(Double.NaN, Double.NaN, 1.0);
}
@Test
- public void testRegularizedGammaPositiveNan() {
+ void testRegularizedGammaPositiveNan() {
testRegularizedGamma(Double.NaN, 1.0, Double.NaN);
}
@Test
- public void testRegularizedGammaNegativePositive() {
+ void testRegularizedGammaNegativePositive() {
testRegularizedGamma(Double.NaN, -1.5, 1.0);
}
@Test
- public void testRegularizedGammaPositiveNegative() {
+ void testRegularizedGammaPositiveNegative() {
testRegularizedGamma(Double.NaN, 1.0, -1.0);
}
@Test
- public void testRegularizedGammaZeroPositive() {
+ void testRegularizedGammaZeroPositive() {
testRegularizedGamma(Double.NaN, 0.0, 1.0);
}
@Test
- public void testRegularizedGammaPositiveZero() {
+ void testRegularizedGammaPositiveZero() {
testRegularizedGamma(0.0, 1.0, 0.0);
}
@Test
- public void testRegularizedGammaPositivePositive() {
+ void testRegularizedGammaPositivePositive() {
testRegularizedGamma(0.632120558828558, 1.0, 1.0);
}
@Test
- public void testRegularizedGammaPWithACloseToZero() {
+ void testRegularizedGammaPWithACloseToZero() {
// Creates a case where the regularized gamma P series is evaluated and the
// result is outside the expected bounds of [0, 1]. This should be clipped to 1.0.
final double a = 1e-18;
@@ -69,7 +69,7 @@
}
@Test
- public void testRegularizedGammaPWithAVeryCloseToZero() {
+ void testRegularizedGammaPWithAVeryCloseToZero() {
// Creates a case where the partial sum is infinite due to inclusion of 1 / a
final double a = Double.MIN_VALUE;
// x must force use of the series in regularized gamma P using x < a + 1
@@ -85,7 +85,7 @@
}
@Test
- public void testRegularizedGammaMaxIterationsExceededThrows() {
+ void testRegularizedGammaMaxIterationsExceededThrows() {
final double a = 1.0;
final double x = 1.0;
// OK without
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java
index 1a8012f..eb481a5 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java
@@ -22,9 +22,9 @@
/**
* Tests for {@link Trigamma}.
*/
-public class TrigammaTest {
+class TrigammaTest {
@Test
- public void testTrigamma() {
+ void testTrigamma() {
double eps = 1e-8;
// computed using webMathematica. For example, to compute trigamma($i) = Polygamma(1, $i), use
//
@@ -62,7 +62,7 @@
}
@Test
- public void testTrigammaNonRealArgs() {
+ void testTrigammaNonRealArgs() {
Assertions.assertTrue(Double.isNaN(Trigamma.value(Double.NaN)));
Assertions.assertTrue(Double.isInfinite(Trigamma.value(Double.POSITIVE_INFINITY)));
Assertions.assertTrue(Double.isInfinite(Trigamma.value(Double.NEGATIVE_INFINITY)));
diff --git a/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/Primes.java b/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/Primes.java
index 5c3ad73..860678d 100644
--- a/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/Primes.java
+++ b/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/Primes.java
@@ -70,13 +70,10 @@
if (n < 0) {
throw new IllegalArgumentException(MessageFormat.format(NUMBER_TOO_SMALL, n, 0));
}
- if (n == 2) {
+ if (n <= 2) {
return 2;
}
n |= 1; // make sure n is odd
- if (n == 1) {
- return 2;
- }
if (isPrime(n)) {
return n;
@@ -88,7 +85,6 @@
if (0 == rem) { // if n % 3 == 0
n += 2; // n % 3 == 2
} else if (1 == rem) { // if n % 3 == 1
- // if (isPrime(n)) return n;
n += 4; // n % 3 == 2
}
while (true) { // this loop skips all multiple of 3
diff --git a/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/PrimesTest.java b/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/PrimesTest.java
index 9667a16..9c2807f 100644
--- a/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/PrimesTest.java
+++ b/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/PrimesTest.java
@@ -24,7 +24,7 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class PrimesTest {
+class PrimesTest {
static final int[] PRIMES = {
//primes here have been verified one by one using Dario Alejandro Alpern's tool.
@@ -85,7 +85,7 @@
}
@Test
- public void testNextPrime() {
+ void testNextPrime() {
Assertions.assertEquals(2, Primes.nextPrime(0));
Assertions.assertEquals(2, Primes.nextPrime(1));
@@ -115,7 +115,7 @@
}
@Test
- public void testIsPrime() throws Exception {
+ void testIsPrime() throws Exception {
for (int i : BELOW_2) {
Assertions.assertFalse(Primes.isPrime(i));
}
@@ -152,7 +152,7 @@
}
@Test
- public void testPrimeFactors() throws Exception {
+ void testPrimeFactors() throws Exception {
for (int i : BELOW_2) {
assertPrimeFactorsException(i, MessageFormat.format(Primes.NUMBER_TOO_SMALL, i, 2));
}
diff --git a/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java b/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java
index 4305109..8ba4e7a 100644
--- a/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java
+++ b/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java
@@ -24,13 +24,13 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class SmallPrimesTest {
+class SmallPrimesTest {
// Primes larger than the small PRIMES array in SmallPrimes
private static final int[] LARGE_PRIME = {3673, 3677};
@Test
- public void smallTrialDivision_smallComposite() {
+ void smallTrialDivision_smallComposite() {
final List<Integer> factors = new ArrayList<Integer>();
final int result = SmallPrimes.smallTrialDivision(3 * 7 * 23, factors);
Assertions.assertEquals(1, result);
@@ -38,7 +38,7 @@
}
@Test
- public void smallTrialDivision_repeatedFactors() {
+ void smallTrialDivision_repeatedFactors() {
final List<Integer> factors = new ArrayList<Integer>();
final int result = SmallPrimes.smallTrialDivision(2 * 2 * 3 * 3 * 3, factors);
Assertions.assertEquals(1, result);
@@ -46,7 +46,7 @@
}
@Test
- public void smallTrialDivision_oneFactor() {
+ void smallTrialDivision_oneFactor() {
final List<Integer> factors = new ArrayList<Integer>();
final int result = SmallPrimes.smallTrialDivision(59, factors);
Assertions.assertEquals(1, result);
@@ -54,7 +54,7 @@
}
@Test
- public void smallTrialDivision_BoundaryPrimes() {
+ void smallTrialDivision_BoundaryPrimes() {
final List<Integer> factors = new ArrayList<Integer>();
final int penultimatePrime = SmallPrimes.PRIMES[SmallPrimes.PRIMES.length - 2];
final int result = SmallPrimes.smallTrialDivision(penultimatePrime * SmallPrimes.PRIMES_LAST, factors);
@@ -63,7 +63,7 @@
}
@Test
- public void smallTrialDivision_largeComposite() {
+ void smallTrialDivision_largeComposite() {
final List<Integer> factors = new ArrayList<Integer>();
final int result = SmallPrimes.smallTrialDivision(2 * 5 * LARGE_PRIME[0], factors);
Assertions.assertEquals(LARGE_PRIME[0], result);
@@ -71,7 +71,7 @@
}
@Test
- public void smallTrialDivision_noSmallPrimeFactors() {
+ void smallTrialDivision_noSmallPrimeFactors() {
final List<Integer> factors = new ArrayList<Integer>();
final int result = SmallPrimes.smallTrialDivision(LARGE_PRIME[0] * LARGE_PRIME[1], factors);
Assertions.assertEquals(LARGE_PRIME[0] * LARGE_PRIME[1], result);
@@ -79,7 +79,7 @@
}
@Test
- public void boundedTrialDivision_twoDifferentFactors() {
+ void boundedTrialDivision_twoDifferentFactors() {
final List<Integer> factors = new ArrayList<Integer>();
final int result = SmallPrimes.boundedTrialDivision(LARGE_PRIME[0] * LARGE_PRIME[1], Integer.MAX_VALUE,
factors);
@@ -88,7 +88,7 @@
}
@Test
- public void boundedTrialDivision_square() {
+ void boundedTrialDivision_square() {
final List<Integer> factors = new ArrayList<Integer>();
final int result = SmallPrimes.boundedTrialDivision(LARGE_PRIME[0] * LARGE_PRIME[0], Integer.MAX_VALUE,
factors);
@@ -97,37 +97,37 @@
}
@Test
- public void trialDivision_smallComposite() {
+ void trialDivision_smallComposite() {
final List<Integer> factors = SmallPrimes.trialDivision(5 * 11 * 29 * 103);
Assertions.assertEquals(Arrays.asList(5, 11, 29, 103), factors);
}
@Test
- public void trialDivision_repeatedFactors() {
+ void trialDivision_repeatedFactors() {
final List<Integer> factors = SmallPrimes.trialDivision(2 * 2 * 2 * 2 * 5 * 5);
Assertions.assertEquals(Arrays.asList(2, 2, 2, 2, 5, 5), factors);
}
@Test
- public void trialDivision_oneSmallFactor() {
+ void trialDivision_oneSmallFactor() {
final List<Integer> factors = SmallPrimes.trialDivision(101);
Assertions.assertEquals(Collections.singletonList(101), factors);
}
@Test
- public void trialDivision_largeComposite() {
+ void trialDivision_largeComposite() {
final List<Integer> factors = SmallPrimes.trialDivision(2 * 3 * LARGE_PRIME[0]);
Assertions.assertEquals(Arrays.asList(2, 3, LARGE_PRIME[0]), factors);
}
@Test
- public void trialDivision_veryLargeComposite() {
+ void trialDivision_veryLargeComposite() {
final List<Integer> factors = SmallPrimes.trialDivision(2 * LARGE_PRIME[0] * LARGE_PRIME[1]);
Assertions.assertEquals(Arrays.asList(2, LARGE_PRIME[0], LARGE_PRIME[1]), factors);
}
@Test
- public void millerRabinPrimeTest_primes() {
+ void millerRabinPrimeTest_primes() {
for (final int n : PrimesTest.PRIMES) {
if (n % 2 == 1) {
Assertions.assertTrue(SmallPrimes.millerRabinPrimeTest(n));
@@ -136,7 +136,7 @@
}
@Test
- public void millerRabinPrimeTest_composites() {
+ void millerRabinPrimeTest_composites() {
for (final int n : PrimesTest.NOT_PRIMES) {
if (n % 2 == 1) {
Assertions.assertFalse(SmallPrimes.millerRabinPrimeTest(n));
diff --git a/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/QuaternionTest.java b/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/QuaternionTest.java
index aede102..ac25205 100644
--- a/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/QuaternionTest.java
+++ b/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/QuaternionTest.java
@@ -21,48 +21,48 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class QuaternionTest {
+class QuaternionTest {
/** Epsilon for double comparison. */
private static final double EPS = Math.ulp(1d);
/** Epsilon for double comparison. */
private static final double COMPARISON_EPS = 1e-14;
@Test
- public void testZeroQuaternion() {
- Assertions.assertEquals(0, Quaternion.ZERO.norm(), 0d);
+ void testZeroQuaternion() {
+ Assertions.assertEquals(0, Quaternion.ZERO.norm());
}
@Test
- public void testUnitQuaternions() {
- Assertions.assertEquals(1, Quaternion.ONE.norm(), 0d);
+ void testUnitQuaternions() {
+ Assertions.assertEquals(1, Quaternion.ONE.norm());
Assertions.assertSame(Quaternion.ONE, Quaternion.ONE.normalize());
- Assertions.assertEquals(1, Quaternion.I.norm(), 0d);
+ Assertions.assertEquals(1, Quaternion.I.norm());
Assertions.assertSame(Quaternion.I, Quaternion.I.normalize());
- Assertions.assertEquals(1, Quaternion.J.norm(), 0d);
+ Assertions.assertEquals(1, Quaternion.J.norm());
Assertions.assertSame(Quaternion.J, Quaternion.J.normalize());
- Assertions.assertEquals(1, Quaternion.K.norm(), 0d);
+ Assertions.assertEquals(1, Quaternion.K.norm());
Assertions.assertSame(Quaternion.K, Quaternion.K.normalize());
}
@Test
- public final void testAccessors1() {
+ final void testAccessors1() {
final double q0 = 2;
final double q1 = 5.4;
final double q2 = 17;
final double q3 = 0.0005;
final Quaternion q = Quaternion.of(q0, q1, q2, q3);
- Assertions.assertEquals(q0, q.getW(), 0);
- Assertions.assertEquals(q1, q.getX(), 0);
- Assertions.assertEquals(q2, q.getY(), 0);
- Assertions.assertEquals(q3, q.getZ(), 0);
+ Assertions.assertEquals(q0, q.getW());
+ Assertions.assertEquals(q1, q.getX());
+ Assertions.assertEquals(q2, q.getY());
+ Assertions.assertEquals(q3, q.getZ());
}
@Test
- public final void testAccessors2() {
+ final void testAccessors2() {
final double q0 = 2;
final double q1 = 5.4;
final double q2 = 17;
@@ -72,14 +72,14 @@
final double sP = q.getScalarPart();
final double[] vP = q.getVectorPart();
- Assertions.assertEquals(q0, sP, 0);
- Assertions.assertEquals(q1, vP[0], 0);
- Assertions.assertEquals(q2, vP[1], 0);
- Assertions.assertEquals(q3, vP[2], 0);
+ Assertions.assertEquals(q0, sP);
+ Assertions.assertEquals(q1, vP[0]);
+ Assertions.assertEquals(q2, vP[1]);
+ Assertions.assertEquals(q3, vP[2]);
}
@Test
- public final void testAccessors3() {
+ final void testAccessors3() {
final double q0 = 2;
final double q1 = 5.4;
final double q2 = 17;
@@ -89,21 +89,21 @@
final double sP = q.getScalarPart();
final double[] vP = q.getVectorPart();
- Assertions.assertEquals(q0, sP, 0);
- Assertions.assertEquals(q1, vP[0], 0);
- Assertions.assertEquals(q2, vP[1], 0);
- Assertions.assertEquals(q3, vP[2], 0);
+ Assertions.assertEquals(q0, sP);
+ Assertions.assertEquals(q1, vP[0]);
+ Assertions.assertEquals(q2, vP[1]);
+ Assertions.assertEquals(q3, vP[2]);
}
@Test
- public void testWrongDimension() {
+ void testWrongDimension() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> Quaternion.of(new double[] {1, 2})
);
}
@Test
- public final void testConjugate() {
+ final void testConjugate() {
final double q0 = 2;
final double q1 = 5.4;
final double q2 = 17;
@@ -112,15 +112,15 @@
final Quaternion qConjugate = q.conjugate();
- Assertions.assertEquals(q0, qConjugate.getW(), 0);
- Assertions.assertEquals(-q1, qConjugate.getX(), 0);
- Assertions.assertEquals(-q2, qConjugate.getY(), 0);
- Assertions.assertEquals(-q3, qConjugate.getZ(), 0);
+ Assertions.assertEquals(q0, qConjugate.getW());
+ Assertions.assertEquals(-q1, qConjugate.getX());
+ Assertions.assertEquals(-q2, qConjugate.getY());
+ Assertions.assertEquals(-q3, qConjugate.getZ());
}
/* TODO remove dependency on Vector3D
@Test
- public final void testProductQuaternionQuaternion() {
+ final void testProductQuaternionQuaternion() {
// Case : analytic test case
@@ -165,7 +165,7 @@
*/
/* TODO remove dependency on Vector3D
@Test
- public final void testProductQuaternionVector() {
+ final void testProductQuaternionVector() {
// Case : Product between a vector and a quaternion : QxV
@@ -216,7 +216,7 @@
}
*/
@Test
- public final void testDotProductQuaternionQuaternion() {
+ final void testDotProductQuaternionQuaternion() {
// expected output
final double expected = -6.;
// inputs
@@ -231,7 +231,7 @@
}
@Test
- public final void testScalarMultiplyDouble() {
+ final void testScalarMultiplyDouble() {
// expected outputs
final double w = 1.6;
final double x = -4.8;
@@ -250,7 +250,7 @@
}
@Test
- public final void testAddQuaternionQuaternion() {
+ final void testAddQuaternionQuaternion() {
// expected outputs
final double w = 4;
final double x = -1;
@@ -275,7 +275,7 @@
}
@Test
- public final void testSubtractQuaternionQuaternion() {
+ final void testSubtractQuaternionQuaternion() {
// expected outputs
final double w = -2.;
final double x = 5.;
@@ -300,7 +300,7 @@
}
@Test
- public final void testNorm() {
+ final void testNorm() {
final double q0 = 2;
final double q1 = 1;
@@ -310,31 +310,31 @@
final double norm = q.norm();
- Assertions.assertEquals(Math.sqrt(30), norm, 0);
+ Assertions.assertEquals(Math.sqrt(30), norm);
final double normSquareRef = Quaternion.multiply(q, q.conjugate()).getScalarPart();
- Assertions.assertEquals(Math.sqrt(normSquareRef), norm, 0);
+ Assertions.assertEquals(Math.sqrt(normSquareRef), norm);
}
@Test
- public final void testNormalize() {
+ final void testNormalize() {
final Quaternion q = Quaternion.of(2, 1, -4, -2);
final Quaternion versor = q.normalize();
- Assertions.assertEquals(2.0 / 5.0, versor.getW(), 0);
- Assertions.assertEquals(1.0 / 5.0, versor.getX(), 0);
- Assertions.assertEquals(-4.0 / 5.0, versor.getY(), 0);
- Assertions.assertEquals(-2.0 / 5.0, versor.getZ(), 0);
+ Assertions.assertEquals(2.0 / 5.0, versor.getW());
+ Assertions.assertEquals(1.0 / 5.0, versor.getX());
+ Assertions.assertEquals(-4.0 / 5.0, versor.getY());
+ Assertions.assertEquals(-2.0 / 5.0, versor.getZ());
- Assertions.assertEquals(1, versor.norm(), 0);
+ Assertions.assertEquals(1, versor.norm());
Assertions.assertSame(versor.normalize(), versor);
}
@Test
- public final void testNormalizeFail_zero() {
+ final void testNormalizeFail_zero() {
final Quaternion q = Quaternion.of(0, 0, 0, 0);
Assertions.assertThrows(IllegalStateException.class,
q::normalize
@@ -342,7 +342,7 @@
}
@Test
- public final void testNormalizeFail_nan() {
+ final void testNormalizeFail_nan() {
final Quaternion q = Quaternion.of(0, 0, 0, Double.NaN);
Assertions.assertThrows(IllegalStateException.class,
q::normalize
@@ -351,7 +351,7 @@
}
@Test
- public final void testNormalizeFail_positiveInfinity() {
+ final void testNormalizeFail_positiveInfinity() {
final Quaternion q = Quaternion.of(0, 0, Double.POSITIVE_INFINITY, 0);
Assertions.assertThrows(IllegalStateException.class,
q::normalize
@@ -359,7 +359,7 @@
}
@Test
- public final void testNormalizeFail_negativeInfinity() {
+ final void testNormalizeFail_negativeInfinity() {
final Quaternion q = Quaternion.of(0, Double.NEGATIVE_INFINITY, 0, 0);
Assertions.assertThrows(IllegalStateException.class,
q::normalize
@@ -367,7 +367,7 @@
}
@Test
- public final void testObjectEquals() {
+ final void testObjectEquals() {
final double one = 1;
final Quaternion q1 = Quaternion.of(one, one, one, one);
Assertions.assertEquals(q1, q1);
@@ -382,7 +382,7 @@
}
@Test
- public void testHashCode() {
+ void testHashCode() {
Quaternion x = Quaternion.of(0.0, 0.0, 0.0, 0.0);
Quaternion y = Quaternion.of(0.0, 0.0 + Double.MIN_VALUE, 0.0, 0.0);
Assertions.assertNotEquals(x.hashCode(), y.hashCode());
@@ -395,27 +395,27 @@
x = Quaternion.of(0.0, 0.0, 0.0, 0.0);
y = Quaternion.of(-0.0, 0.0, 0.0, 0.0);
- Assertions.assertTrue(x.hashCode() != y.hashCode());
+ Assertions.assertNotEquals(x.hashCode(), y.hashCode());
Assertions.assertNotEquals(x, y, msg);
x = Quaternion.of(0.0, 0.0, 0.0, 0.0);
y = Quaternion.of(0.0, -0.0, 0.0, 0.0);
- Assertions.assertTrue(x.hashCode() != y.hashCode());
+ Assertions.assertNotEquals(x.hashCode(), y.hashCode());
Assertions.assertNotEquals(x, y, msg);
x = Quaternion.of(0.0, 0.0, 0.0, 0.0);
y = Quaternion.of(0.0, 0.0, -0.0, 0.0);
- Assertions.assertTrue(x.hashCode() != y.hashCode());
+ Assertions.assertNotEquals(x.hashCode(), y.hashCode());
Assertions.assertNotEquals(x, y, msg);
x = Quaternion.of(0.0, 0.0, 0.0, 0.0);
y = Quaternion.of(0.0, 0.0, 0.0, -0.0);
- Assertions.assertTrue(x.hashCode() != y.hashCode());
+ Assertions.assertNotEquals(x.hashCode(), y.hashCode());
Assertions.assertNotEquals(x, y, msg);
}
@Test
- public final void testQuaternionEquals() {
+ final void testQuaternionEquals() {
final double inc = 1e-5;
final Quaternion q1 = Quaternion.of(2, 1, -4, -2);
final Quaternion q2 = Quaternion.of(q1.getW() + inc, q1.getX(), q1.getY(), q1.getZ());
@@ -435,7 +435,7 @@
}
@Test
- public final void testQuaternionEquals2() {
+ final void testQuaternionEquals2() {
final Quaternion q1 = Quaternion.of(1, 4, 2, 3);
final double gap = 1e-5;
final Quaternion q2 = Quaternion.of(1 + gap, 4 + gap, 2 + gap, 3 + gap);
@@ -446,7 +446,7 @@
}
@Test
- public final void testIsUnit() {
+ final void testIsUnit() {
final Random r = new Random(48);
final int numberOfTrials = 1000;
for (int i = 0; i < numberOfTrials; i++) {
@@ -460,7 +460,7 @@
}
@Test
- public final void testIsPure() {
+ final void testIsPure() {
final Quaternion q1 = Quaternion.of(0, 5, 4, 8);
Assertions.assertTrue(q1.isPure(EPS));
@@ -480,7 +480,7 @@
}
@Test
- public final void testPositivePolarFormWhenScalarPositive() {
+ final void testPositivePolarFormWhenScalarPositive() {
Quaternion q = Quaternion.of(3, -3, -3, 3).positivePolarForm();
Quaternion expected = Quaternion.of(0.5, -0.5, -0.5, 0.5);
assertEquals(q, expected, EPS);
@@ -489,7 +489,7 @@
}
@Test
- public final void testPositivePolarFormWhenScalarNegative() {
+ final void testPositivePolarFormWhenScalarNegative() {
Quaternion q = Quaternion.of(-3, 3, -3, 3).positivePolarForm();
Quaternion expected = Quaternion.of(0.5, -0.5, 0.5, -0.5);
assertEquals(q, expected, EPS);
@@ -498,7 +498,7 @@
}
@Test
- public final void testPositivePolarFormWhenScalarPositiveAndNormalized() {
+ final void testPositivePolarFormWhenScalarPositiveAndNormalized() {
Quaternion q = Quaternion.of(123, 45, 67, 89).normalize().positivePolarForm();
Assertions.assertTrue(q.getW() >= 0);
@@ -506,7 +506,7 @@
}
@Test
- public final void testPositivePolarFormWhenScalarNegativeAndNormalized() {
+ final void testPositivePolarFormWhenScalarNegativeAndNormalized() {
Quaternion q = Quaternion.of(123, 45, 67, 89).normalize().negate().positivePolarForm();
Assertions.assertTrue(q.getW() >= 0);
@@ -514,23 +514,23 @@
}
@Test
- public void testNegate() {
+ void testNegate() {
final double a = -1;
final double b = 2;
final double c = -3;
final double d = 4;
final Quaternion q = Quaternion.of(a, b, c, d);
final Quaternion qNeg = q.negate();
- Assertions.assertEquals(-a, qNeg.getW(), 0d);
- Assertions.assertEquals(-b, qNeg.getX(), 0d);
- Assertions.assertEquals(-c, qNeg.getY(), 0d);
- Assertions.assertEquals(-d, qNeg.getZ(), 0d);
+ Assertions.assertEquals(-a, qNeg.getW());
+ Assertions.assertEquals(-b, qNeg.getX());
+ Assertions.assertEquals(-c, qNeg.getY());
+ Assertions.assertEquals(-d, qNeg.getZ());
Assertions.assertTrue(q.equals(qNeg.negate(), 0d));
}
@Test
- public void testNegateNormalized() {
+ void testNegateNormalized() {
final double a = -1;
final double b = 2;
final double c = -3;
@@ -541,7 +541,7 @@
}
@Test
- public void testNegatePositivePolarForm() {
+ void testNegatePositivePolarForm() {
final double a = -1;
final double b = 2;
final double c = -3;
@@ -553,7 +553,7 @@
/* TODO remove dependency on Rotation
@Test
- public final void testPolarForm() {
+ final void testPolarForm() {
final Random r = new Random(48);
final int numberOfTrials = 1000;
for (int i = 0; i < numberOfTrials; i++) {
@@ -581,14 +581,14 @@
}
*/
@Test
- public final void testInverse() {
+ final void testInverse() {
final Quaternion q = Quaternion.of(1.5, 4, 2, -2.5);
final Quaternion inverseQ = q.inverse();
- Assertions.assertEquals(1.5 / 28.5, inverseQ.getW(), 0);
- Assertions.assertEquals(-4.0 / 28.5, inverseQ.getX(), 0);
- Assertions.assertEquals(-2.0 / 28.5, inverseQ.getY(), 0);
- Assertions.assertEquals(2.5 / 28.5, inverseQ.getZ(), 0);
+ Assertions.assertEquals(1.5 / 28.5, inverseQ.getW());
+ Assertions.assertEquals(-4.0 / 28.5, inverseQ.getX());
+ Assertions.assertEquals(-2.0 / 28.5, inverseQ.getY());
+ Assertions.assertEquals(2.5 / 28.5, inverseQ.getZ());
final Quaternion product = Quaternion.multiply(inverseQ, q);
Assertions.assertEquals(1, product.getW(), EPS);
@@ -606,7 +606,7 @@
}
@Test
- public void testInverse_zeroNorm() {
+ void testInverse_zeroNorm() {
Quaternion q = Quaternion.of(0, 0, 0, 0);
Assertions.assertThrows(IllegalStateException.class,
q::inverse
@@ -614,7 +614,7 @@
}
@Test
- public void testInverse_nanNorm() {
+ void testInverse_nanNorm() {
Quaternion q = Quaternion.of(Double.NaN, 0, 0, 0);
Assertions.assertThrows(IllegalStateException.class,
q::inverse
@@ -622,7 +622,7 @@
}
@Test
- public void testInverse_positiveInfinityNorm() {
+ void testInverse_positiveInfinityNorm() {
Quaternion q = Quaternion.of(0, Double.POSITIVE_INFINITY, 0, 0);
Assertions.assertThrows(IllegalStateException.class,
q::inverse
@@ -630,7 +630,7 @@
}
@Test
- public void testInverse_negativeInfinityNorm() {
+ void testInverse_negativeInfinityNorm() {
Quaternion q = Quaternion.of(0, 0, Double.NEGATIVE_INFINITY, 0);
Assertions.assertThrows(IllegalStateException.class,
q::inverse
@@ -638,7 +638,7 @@
}
@Test
- public void testInverseNormalized() {
+ void testInverseNormalized() {
final Quaternion invQ = Quaternion.of(-1.2, 3.4, -5.6, -7.8).normalize().inverse();
final Quaternion q = invQ.inverse();
final Quaternion result = q.multiply(invQ);
@@ -646,7 +646,7 @@
}
@Test
- public void testInversePositivePolarForm() {
+ void testInversePositivePolarForm() {
final Quaternion invQ = Quaternion.of(1.2, -3.4, 5.6, -7.8).positivePolarForm().inverse();
final Quaternion q = invQ.inverse();
final Quaternion result = q.multiply(invQ);
@@ -654,7 +654,7 @@
}
@Test
- public final void testMultiply() {
+ final void testMultiply() {
final Quaternion q1 = Quaternion.of(1, 2, 3, 4);
final Quaternion q2 = Quaternion.of(4, 3, 2, 1);
final Quaternion actual = q1.multiply(q2);
@@ -667,14 +667,14 @@
}
@Test
- public final void testParseFromToString() {
+ final void testParseFromToString() {
final Quaternion q = Quaternion.of(1.1, 2.2, 3.3, 4.4);
Quaternion parsed = Quaternion.parse(q.toString());
assertEquals(parsed, q, EPS);
}
@Test
- public final void testParseSpecials() {
+ final void testParseSpecials() {
Quaternion parsed = Quaternion.parse("[1e-5 Infinity NaN -0xa.cp0]");
Assertions.assertEquals(1e-5, parsed.getW(), EPS);
Assertions.assertTrue(Double.isInfinite(parsed.getX()));
@@ -683,56 +683,56 @@
}
@Test
- public final void testParseMissingStart() {
+ final void testParseMissingStart() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> Quaternion.parse("1.0 2.0 3.0 4.0]")
);
}
@Test
- public final void testParseMissingEnd() {
+ final void testParseMissingEnd() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> Quaternion.parse("[1.0 2.0 3.0 4.0")
);
}
@Test
- public final void testParseMissingPart() {
+ final void testParseMissingPart() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> Quaternion.parse("[1.0 2.0 3.0 ]")
);
}
@Test
- public final void testParseInvalidScalar() {
+ final void testParseInvalidScalar() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> Quaternion.parse("[1.x 2.0 3.0 4.0]")
);
}
@Test
- public final void testParseInvalidI() {
+ final void testParseInvalidI() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> Quaternion.parse("[1.0 2.0x 3.0 4.0]")
);
}
@Test
- public final void testParseInvalidJ() {
+ final void testParseInvalidJ() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> Quaternion.parse("[1.0 2.0 3.0x 4.0]")
);
}
@Test
- public final void testParseInvalidK() {
+ final void testParseInvalidK() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> Quaternion.parse("[1.0 2.0 3.0 4.0x]")
);
}
@Test
- public final void testToString() {
+ final void testToString() {
final Quaternion q = Quaternion.of(1, 2, 3, 4);
Assertions.assertEquals("[1.0 2.0 3.0 4.0]", q.toString());
}
diff --git a/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/SlerpTest.java b/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/SlerpTest.java
index 71ebb5e..37f34c7 100644
--- a/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/SlerpTest.java
+++ b/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/SlerpTest.java
@@ -21,7 +21,7 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class SlerpTest {
+class SlerpTest {
private static final double EPS = 1e-7;
@@ -29,7 +29,7 @@
private static final double INV_SQRT_2 = 1.0 / SQRT_2;
@Test
- public void testSlerp_sphericalAlgorithm() {
+ void testSlerp_sphericalAlgorithm() {
// arrange
Quaternion q1 = createZRotation(0.75 * Math.PI);
Quaternion q2 = createZRotation(-0.75 * Math.PI);
@@ -47,7 +47,7 @@
}
@Test
- public void testSlerp_sphericalAlgorithm_allOutputsAreInPositivePolarForm() {
+ void testSlerp_sphericalAlgorithm_allOutputsAreInPositivePolarForm() {
// arrange
Quaternion q1 = createZRotation(0.75 * Math.PI);
Quaternion q2 = createZRotation(-0.75 * Math.PI);
@@ -69,7 +69,7 @@
}
@Test
- public void testSlerp_nonNormalizedInputs() {
+ void testSlerp_nonNormalizedInputs() {
// arrange
Quaternion q1 = createZRotation(0).multiply(10.0);
Quaternion q2 = createZRotation(Math.PI).multiply(0.2);
@@ -85,7 +85,7 @@
}
@Test
- public void testSlerp_linearAlgorithm() {
+ void testSlerp_linearAlgorithm() {
// arrange
Quaternion q1 = createZRotation(0.75 * Math.PI);
Quaternion q2 = createZRotation(0.76 * Math.PI);
@@ -101,7 +101,7 @@
}
@Test
- public void testSlerp_linearAlgorithm_allOutputsAreInPositivePolarForm() {
+ void testSlerp_linearAlgorithm_allOutputsAreInPositivePolarForm() {
// arrange
Quaternion q1 = createZRotation(0.75 * Math.PI);
Quaternion q2 = createZRotation(0.76 * Math.PI);
@@ -123,7 +123,7 @@
}
@Test
- public void testSlerp_identicalInputs() {
+ void testSlerp_identicalInputs() {
// arrange
Quaternion q1 = createZRotation(0);
Quaternion q2 = createZRotation(0);
@@ -139,7 +139,7 @@
}
@Test
- public void testSlerp_inputQuaternionsHaveMinusOneDotProduct() {
+ void testSlerp_inputQuaternionsHaveMinusOneDotProduct() {
// arrange
Quaternion q1 = createZRotation(0.5 * Math.PI);
Quaternion q2 = createZRotation(1.5 * Math.PI).conjugate(); // 3pi/2 around -z
@@ -157,7 +157,7 @@
}
@Test
- public void testSlerp_tOutsideOfZeroToOne() {
+ void testSlerp_tOutsideOfZeroToOne() {
// arrange
Quaternion q1 = createZRotation(0);
Quaternion q2 = createZRotation(0.25 * Math.PI);
@@ -175,7 +175,7 @@
}
@Test
- public void testVectorTransform_simple() {
+ void testVectorTransform_simple() {
// arrange
Quaternion q0 = Quaternion.of(1, 0, 0, 0); // rotation of zero
Quaternion q1 = Quaternion.of(0, 0, 0, 1); // pi rotation around +z
@@ -202,7 +202,7 @@
}
@Test
- public void testVectorTransform_multipleCombinations() {
+ void testVectorTransform_multipleCombinations() {
// arrange
Quaternion[] quaternions = {
// +x axis
@@ -280,7 +280,7 @@
}
@Test
- public void testVectorTransform_tOutsideOfZeroToOne_() {
+ void testVectorTransform_tOutsideOfZeroToOne_() {
// arrange
double angle1 = Math.PI * 0.25;
double angle2 = Math.PI * 0.75;
diff --git a/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java b/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java
index ab2afb6..abe6bb2 100644
--- a/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java
+++ b/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java
@@ -24,13 +24,13 @@
/**
* Test cases for the {@link BrentSolver} class.
*/
-public class BrentSolverTest {
+class BrentSolverTest {
private static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
private static final double DEFAULT_RELATIVE_ACCURACY = 1e-14;
private static final double DEFAULT_FUNCTION_ACCURACY = 1e-15;
@Test
- public void testSinZero() {
+ void testSinZero() {
// The sinus function is behaved well around the root at pi. The second
// order derivative is zero, which means linar approximating methods will
// still converge quadratically.
@@ -56,7 +56,7 @@
}
@Test
- public void testQuinticZero() {
+ void testQuinticZero() {
// The quintic function has zeros at 0, +-0.5 and +-1.
// Around the root of 0 the function is well behaved, with a second derivative
// of zero a 0.
@@ -140,34 +140,27 @@
}
@Test
- public void testTooManyCalls() {
+ void testTooManyCalls() {
final DoubleUnaryOperator func = new QuinticFunction();
final BrentSolver solver = new BrentSolver(DEFAULT_ABSOLUTE_ACCURACY,
DEFAULT_RELATIVE_ACCURACY,
DEFAULT_FUNCTION_ACCURACY);
- double result;
- MonitoredFunction f;
-
// Very large bracket around 1 for testing fast growth behavior.
- f = new MonitoredFunction(func);
- result = solver.findRoot(f, 0.85, 5);
+ final MonitoredFunction f = new MonitoredFunction(func);
+ final double result = solver.findRoot(f, 0.85, 5);
Assertions.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
Assertions.assertTrue(f.getCallsCount() <= 15);
- try {
- f = new MonitoredFunction(func, 10);
- result = solver.findRoot(f, 0.85, 5);
- Assertions.fail("Expected too many calls condition");
- } catch (IllegalStateException ex) {
- // Expected.
- // Ensure expected error condition.
- Assertions.assertNotEquals(-1, ex.getMessage().indexOf("too many calls"));
- }
+ final MonitoredFunction f2 = new MonitoredFunction(func, 10);
+ final IllegalStateException ex = Assertions.assertThrows(IllegalStateException.class,
+ () -> solver.findRoot(f2, 0.85, 5), "Expected too many calls condition");
+ // Ensure expected error condition.
+ Assertions.assertNotEquals(-1, ex.getMessage().indexOf("too many calls"));
}
@Test
- public void testRootEndpoints() {
+ void testRootEndpoints() {
final DoubleUnaryOperator f = new Sin();
final BrentSolver solver = new BrentSolver(DEFAULT_ABSOLUTE_ACCURACY,
DEFAULT_RELATIVE_ACCURACY,
@@ -188,7 +181,7 @@
}
@Test
- public void testBadEndpoints() {
+ void testBadEndpoints() {
final DoubleUnaryOperator f = new Sin();
final BrentSolver solver = new BrentSolver(DEFAULT_ABSOLUTE_ACCURACY,
DEFAULT_RELATIVE_ACCURACY,
@@ -217,7 +210,7 @@
}
@Test
- public void testBadInitialGuess() {
+ void testBadInitialGuess() {
final DoubleUnaryOperator func = new QuinticFunction();
final BrentSolver solver = new BrentSolver(DEFAULT_ABSOLUTE_ACCURACY,
DEFAULT_RELATIVE_ACCURACY,
@@ -234,7 +227,7 @@
}
@Test
- public void testInitialGuess() {
+ void testInitialGuess() {
final DoubleUnaryOperator func = new QuinticFunction();
final BrentSolver solver = new BrentSolver(DEFAULT_ABSOLUTE_ACCURACY,
DEFAULT_RELATIVE_ACCURACY,
diff --git a/pom.xml b/pom.xml
index 07e4735..aa77692 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,10 +21,9 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-parent</artifactId>
- <version>50</version>
+ <version>51</version>
</parent>
- <groupId>org.apache.commons</groupId>
<artifactId>commons-numbers-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
@@ -208,7 +207,6 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
- <!-- <arg>-verbose</arg> -->
<arg>-Xlint:all,-options,-path</arg>
</compilerArgs>
</configuration>
diff --git a/siteMods/pom.xml b/siteMods/pom.xml
deleted file mode 100644
index 696ebcb..0000000
--- a/siteMods/pom.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!--
- Stripped down maven pom used for generating commons math userguide by itself.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-math</artifactId>
- <version>2.1</version>
- <name>Commons Math User Guide</name>
- <inceptionYear>2003</inceptionYear>
- <description>User Guide</description>
- <url>http://commons.apache.org/math/</url>
- <issueManagement>
- <system>jira</system>
- <url>https://issues.apache.org/jira/browse/MATH</url>
- </issueManagement>
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/commons/proper/math/trunk</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/commons-math.git</developerConnection>
- <url>https://gitbox.apache.org/repos/asf?p=commons-math.git</url>
- </scm>
- <properties>
- <commons.componentid>math</commons.componentid>
- <commons.release.version>2.0</commons.release.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- </properties>
-
- <build>
- </build>
- <reporting>
- </reporting>
-</project>
-
diff --git a/siteMods/site.css b/siteMods/site.css
deleted file mode 100644
index ba9f845..0000000
--- a/siteMods/site.css
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-body {
- color: #000;
- background-color: #fff;
- font-size: 13px;
-}
-
-p {
- margin-left: 4px;
- margin-top: 8px;
- margin-bottom: 4px;
-}
-ul, ol {
- margin-top: 4px;
- margin-bottom: 4px;
-}
-
-h2 {
- color: #fff;
- border: none;
- margin-top: 8px;
- margin-bottom: 4px;
- padding: 4px 4px 4px 6px;
- background-color: #036;
- font-weight: 900;
- font-size: 13px;
- background-image: url(../images/nw_maj_rond.gif);
- background-repeat: no-repeat;
-}
-
-h3 {
- color: #fff;
- background-color: #888;
- margin-top: 12px;
- margin-bottom: 4px;
- padding: 4px 4px 4px 6px;
- border: none;
- font-weight: 900;
- font-size: 13px;
- background-image: url(../images/nw_maj_rond.gif);
- background-repeat: no-repeat;
-}
-
-div#bodyColumn {
- margin-top: 0px;
- margin-left: 158px;
-}
-
-div#bodyColumn a {
- text-decoration: underline;
-}
-div#bodyColumn a:link {
- color: #00f;
-}
-div#bodyColumn a:visited {
- color: #00f;
-}
-a:active, a:hover {
- color: #f30 !important;
-}
-
-div.source {
- background-color: #eee;
- color: #000;
- margin-right: 0px;
- margin-left: 4px;
- margin-top: 1em;
-}
-
-div#leftColumn {
- color: #000;
- background-color: #eee;
- margin-left: 0px;
- margin-top: 0px;
- border-right: 1px solid #aaa;
- border-bottom: 1px solid #aaa;
- border-top: none;
- border-left: none;
-}
-
-#navcolumn {
- margin-top: 0px;
-
- color: #000;
- border: none;
- padding: 6px 4px 0 8px;
-}
-
-#navcolumn li {
- padding-left: 8px;
-}
-
-#navcolumn h5 {
- padding-top: 3px;
-}
-
-#banner, #banner td {
- background-color: #fff;
- color: #000;
-}
-
-#banner td {
- height: 100%;
- vertical-align: middle;
-}
-
-#menuCommons a.externalLink, #menuCommons a.externalLink:link, #menuCommons a.externalLink:visited, #menuCommons a.externalLink:active, #menuCommons a.externalLink:hover {
- background-image: none;
- padding-right: 0px;
-}
diff --git a/siteMods/site.xml b/siteMods/site.xml
deleted file mode 100644
index 82ecd63..0000000
--- a/siteMods/site.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!--
- Stripped down nav for just the commons-math user guide.
- TODO: get this generated somehow from the "real" site.xml
- so it does not have to be maintained separately.
--->
-<project name="Math">
- <skin>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-skin</artifactId>
- <version>2</version>
- </skin>
- <publishDate position="none"/>
- <body>
- <menu name="User Guide">
- <item name="Contents" href="/userguide/index.html"/>
- <item name="Overview" href="/userguide/overview.html"/>
- <item name="Statistics" href="/userguide/stat.html"/>
- <item name="Data Generation" href="/userguide/random.html"/>
- <item name="Linear Algebra" href="/userguide/linear.html"/>
- <item name="Numerical Analysis" href="/userguide/analysis.html"/>
- <item name="Special Functions" href="/userguide/special.html"/>
- <item name="Utilities" href="/userguide/utilities.html"/>
- <item name="Complex Numbers" href="/userguide/complex.html"/>
- <item name="Distributions" href="/userguide/distribution.html"/>
- <item name="Fractions" href="/userguide/fraction.html"/>
- <item name="Transform Methods" href="/userguide/transform.html"/>
- <item name="3D Geometry" href="/userguide/geometry.html"/>
- <item name="Optimization" href="/userguide/optimization.html"/>
- <item name="Ordinary Differential Equations" href="/userguide/ode.html"/>
- <item name="Genetic Algorithms" href="/userguide/genetics.html"/>
- </menu>
-
- </body>
-</project>