This is an automated email from the ASF dual-hosted git repository. erans pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
commit 296dd8df443c8aca8118203b4acad8b9f384fd46 Author: Schamschi <[email protected]> AuthorDate: Sun Jun 9 17:51:37 2019 +0200 Migrate commons-numbers-complex to JUnit 5 Migrate the following classes: ComplexTest CStandardTest TestUtils --- .../commons/numbers/complex/CStandardTest.java | 10 +- .../commons/numbers/complex/ComplexTest.java | 363 ++++++++++----------- .../apache/commons/numbers/complex/TestUtils.java | 46 +-- 3 files changed, 209 insertions(+), 210 deletions(-) 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 2264052..92da022 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 @@ -17,7 +17,7 @@ package org.apache.commons.numbers.complex; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class CStandardTest { @@ -64,13 +64,13 @@ public class CStandardTest { private static final Complex NAN = Complex.ofCartesian(nan, nan); public void assertComplex(Complex c1, Complex c2, double realTol, double imagTol) { - Assert.assertEquals(c1.getReal(), c2.getReal(), realTol); - Assert.assertEquals(c1.getImaginary(), c2.getImaginary(), imagTol); + Assertions.assertEquals(c1.getReal(), c2.getReal(), realTol); + Assertions.assertEquals(c1.getImaginary(), c2.getImaginary(), imagTol); } public void assertComplex(Complex c1, Complex c2) { - Assert.assertEquals(c1.getReal(), c2.getReal(),0.0); - Assert.assertEquals(c1.getImaginary(), c2.getImaginary(), 0.0); + Assertions.assertEquals(c1.getReal(), c2.getReal(),0.0); + Assertions.assertEquals(c1.getImaginary(), c2.getImaginary(), 0.0); } 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 ed48434..65bc505 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 @@ -17,7 +17,6 @@ package org.apache.commons.numbers.complex; -import org.junit.Assert; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -54,33 +53,33 @@ public class ComplexTest { @Test public void testConstructor() { Complex z = Complex.ofCartesian(3.0, 4.0); - Assert.assertEquals(3.0, z.getReal(), 1.0e-5); - Assert.assertEquals(4.0, z.getImaginary(), 1.0e-5); + Assertions.assertEquals(3.0, z.getReal(), 1.0e-5); + Assertions.assertEquals(4.0, z.getImaginary(), 1.0e-5); } @Test public void testConstructorNaN() { Complex z = Complex.ofCartesian(3.0, Double.NaN); - Assert.assertTrue(z.isNaN()); + Assertions.assertTrue(z.isNaN()); z = Complex.ofCartesian(nan, 4.0); - Assert.assertTrue(z.isNaN()); + Assertions.assertTrue(z.isNaN()); z = Complex.ofCartesian(3.0, 4.0); - Assert.assertFalse(z.isNaN()); + Assertions.assertFalse(z.isNaN()); } @Test public void testAbs() { Complex z = Complex.ofCartesian(3.0, 4.0); - Assert.assertEquals(5.0, z.abs(), 1.0e-5); + Assertions.assertEquals(5.0, z.abs(), 1.0e-5); } @Test public void testAbsNaN() { - Assert.assertTrue(Double.isNaN(NAN.abs())); + Assertions.assertTrue(Double.isNaN(NAN.abs())); Complex z = Complex.ofCartesian(inf, nan); - Assert.assertTrue(Double.isNaN(z.abs())); + Assertions.assertTrue(Double.isNaN(z.abs())); } @Test @@ -88,8 +87,8 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); Complex y = Complex.ofCartesian(5.0, 6.0); Complex z = x.add(y); - Assert.assertEquals(8.0, z.getReal(), 1.0e-5); - Assert.assertEquals(10.0, z.getImaginary(), 1.0e-5); + Assertions.assertEquals(8.0, z.getReal(), 1.0e-5); + Assertions.assertEquals(10.0, z.getImaginary(), 1.0e-5); } @Test @@ -97,11 +96,11 @@ public class ComplexTest { Complex x = Complex.ofCartesian(1, 1); Complex z = Complex.ofCartesian(inf, 0); Complex w = x.add(z); - Assert.assertEquals(w.getImaginary(), 1, 0); - Assert.assertEquals(inf, w.getReal(), 0); + Assertions.assertEquals(w.getImaginary(), 1, 0); + Assertions.assertEquals(inf, w.getReal(), 0); x = Complex.ofCartesian(neginf, 0); - Assert.assertTrue(Double.isNaN(x.add(z).getReal())); + Assertions.assertTrue(Double.isNaN(x.add(z).getReal())); } @@ -110,7 +109,7 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = 2.0; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.add(yComplex), x.add(yDouble)); + Assertions.assertEquals(x.add(yComplex), x.add(yDouble)); } @Test @@ -118,7 +117,7 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = Double.NaN; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.add(yComplex), x.add(yDouble)); + Assertions.assertEquals(x.add(yComplex), x.add(yDouble)); } @Test @@ -127,32 +126,32 @@ public class ComplexTest { double yDouble = Double.POSITIVE_INFINITY; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.add(yComplex), x.add(yDouble)); + Assertions.assertEquals(x.add(yComplex), x.add(yDouble)); x = Complex.ofCartesian(neginf, 0); - Assert.assertEquals(x.add(yComplex), x.add(yDouble)); + Assertions.assertEquals(x.add(yComplex), x.add(yDouble)); } @Test public void testConjugate() { Complex x = Complex.ofCartesian(3.0, 4.0); Complex z = x.conjugate(); - Assert.assertEquals(3.0, z.getReal(), 1.0e-5); - Assert.assertEquals(-4.0, z.getImaginary(), 1.0e-5); + Assertions.assertEquals(3.0, z.getReal(), 1.0e-5); + Assertions.assertEquals(-4.0, z.getImaginary(), 1.0e-5); } @Test public void testConjugateNaN() { Complex z = NAN.conjugate(); - Assert.assertTrue(z.isNaN()); + Assertions.assertTrue(z.isNaN()); } @Test public void testConjugateInfiinite() { Complex z = Complex.ofCartesian(0, inf); - Assert.assertEquals(neginf, z.conjugate().getImaginary(), 0); + Assertions.assertEquals(neginf, z.conjugate().getImaginary(), 0); z = Complex.ofCartesian(0, neginf); - Assert.assertEquals(inf, z.conjugate().getImaginary(), 0); + Assertions.assertEquals(inf, z.conjugate().getImaginary(), 0); } @Test @@ -160,15 +159,15 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); Complex y = Complex.ofCartesian(5.0, 6.0); Complex z = x.divide(y); - Assert.assertEquals(39.0 / 61.0, z.getReal(), 1.0e-5); - Assert.assertEquals(2.0 / 61.0, z.getImaginary(), 1.0e-5); + Assertions.assertEquals(39.0 / 61.0, z.getReal(), 1.0e-5); + Assertions.assertEquals(2.0 / 61.0, z.getImaginary(), 1.0e-5); } @Test public void testDivideReal() { Complex x = Complex.ofCartesian(2d, 3d); Complex y = Complex.ofCartesian(2d, 0d); - Assert.assertEquals(Complex.ofCartesian(1d, 1.5), x.divide(y)); + Assertions.assertEquals(Complex.ofCartesian(1d, 1.5), x.divide(y)); } @@ -176,43 +175,43 @@ public class ComplexTest { public void testDivideImaginary() { Complex x = Complex.ofCartesian(2d, 3d); Complex y = Complex.ofCartesian(0d, 2d); - Assert.assertEquals(Complex.ofCartesian(1.5d, -1d), x.divide(y)); + Assertions.assertEquals(Complex.ofCartesian(1.5d, -1d), x.divide(y)); } @Test public void testDivideZero() { Complex x = Complex.ofCartesian(3.0, 4.0); Complex z = x.divide(Complex.ZERO); - Assert.assertEquals(z, Complex.INF); + Assertions.assertEquals(z, Complex.INF); } @Test public void testDivideZeroZero() { Complex x = Complex.ofCartesian(0.0, 0.0); Complex z = x.divide(Complex.ZERO); - Assert.assertEquals(z, NAN); + Assertions.assertEquals(z, NAN); } @Test public void testDivideNaN() { Complex x = Complex.ofCartesian(3.0, 4.0); Complex z = x.divide(NAN); - Assert.assertTrue(z.isNaN()); + Assertions.assertTrue(z.isNaN()); } @Test public void testDivideNaNInf() { Complex z = oneInf.divide(Complex.ONE); - Assert.assertTrue(Double.isNaN(z.getReal())); - Assert.assertEquals(inf, z.getImaginary(), 0); + Assertions.assertTrue(Double.isNaN(z.getReal())); + Assertions.assertEquals(inf, z.getImaginary(), 0); z = negInfNegInf.divide(oneNaN); - Assert.assertTrue(Double.isNaN(z.getReal())); - Assert.assertTrue(Double.isNaN(z.getImaginary())); + Assertions.assertTrue(Double.isNaN(z.getReal())); + Assertions.assertTrue(Double.isNaN(z.getImaginary())); z = negInfInf.divide(Complex.ONE); - Assert.assertTrue(Double.isInfinite(z.getReal())); - Assert.assertTrue(Double.isInfinite(z.getImaginary())); + Assertions.assertTrue(Double.isInfinite(z.getReal())); + Assertions.assertTrue(Double.isInfinite(z.getImaginary())); } @Test @@ -220,7 +219,7 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = 2.0; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.divide(yComplex), x.divide(yDouble)); + Assertions.assertEquals(x.divide(yComplex), x.divide(yDouble)); } @Test @@ -228,7 +227,7 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = Double.NaN; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.divide(yComplex), x.divide(yDouble)); + Assertions.assertEquals(x.divide(yComplex), x.divide(yDouble)); } @Test @@ -243,8 +242,8 @@ public class ComplexTest { Complex act = z.reciprocal(); double expRe = 5.0 / 61.0; double expIm = -6.0 / 61.0; - Assert.assertEquals(expRe, act.getReal(), Math.ulp(expRe)); - Assert.assertEquals(expIm, act.getImaginary(), Math.ulp(expIm)); + Assertions.assertEquals(expRe, act.getReal(), Math.ulp(expRe)); + Assertions.assertEquals(expIm, act.getImaginary(), Math.ulp(expIm)); } @Test @@ -252,25 +251,25 @@ public class ComplexTest { Complex z = Complex.ofCartesian(5.0, 6.0); Complex zRR = z.reciprocal().reciprocal(); final double tol = 1e-14; - Assert.assertEquals(zRR.getReal(), z.getReal(), tol); - Assert.assertEquals(zRR.getImaginary(), z.getImaginary(), tol); + Assertions.assertEquals(zRR.getReal(), z.getReal(), tol); + Assertions.assertEquals(zRR.getImaginary(), z.getImaginary(), tol); } @Test public void testReciprocalReal() { Complex z = Complex.ofCartesian(-2.0, 0.0); - Assert.assertTrue(Complex.equals(Complex.ofCartesian(-0.5, 0.0), z.reciprocal())); + Assertions.assertTrue(Complex.equals(Complex.ofCartesian(-0.5, 0.0), z.reciprocal())); } @Test public void testReciprocalImaginary() { Complex z = Complex.ofCartesian(0.0, -2.0); - Assert.assertEquals(Complex.ofCartesian(0.0, 0.5), z.reciprocal()); + Assertions.assertEquals(Complex.ofCartesian(0.0, 0.5), z.reciprocal()); } @Test public void testReciprocalNaN() { - Assert.assertTrue(NAN.reciprocal().isNaN()); + Assertions.assertTrue(NAN.reciprocal().isNaN()); } @Test @@ -278,14 +277,14 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); Complex y = Complex.ofCartesian(5.0, 6.0); Complex z = x.multiply(y); - Assert.assertEquals(-9.0, z.getReal(), 1.0e-5); - Assert.assertEquals(38.0, z.getImaginary(), 1.0e-5); + Assertions.assertEquals(-9.0, z.getReal(), 1.0e-5); + Assertions.assertEquals(38.0, z.getImaginary(), 1.0e-5); } @Test public void testMultiplyInfInf() { // Assert.assertTrue(infInf.multiply(infInf).isNaN()); // MATH-620 - Assert.assertTrue(infInf.multiply(infInf).isInfinite()); + Assertions.assertTrue(infInf.multiply(infInf).isInfinite()); } @Test @@ -293,10 +292,10 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = 2.0; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); + Assertions.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); int zInt = -5; Complex zComplex = Complex.ofReal(zInt); - Assert.assertEquals(x.multiply(zComplex), x.multiply(zInt)); + Assertions.assertEquals(x.multiply(zComplex), x.multiply(zInt)); } @Test @@ -304,7 +303,7 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = Double.NaN; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); + Assertions.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); } @Test @@ -312,25 +311,25 @@ public class ComplexTest { Complex x = Complex.ofCartesian(1, 1); double yDouble = Double.POSITIVE_INFINITY; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); + Assertions.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); yDouble = Double.NEGATIVE_INFINITY; yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); + Assertions.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); } @Test public void testNegate() { Complex x = Complex.ofCartesian(3.0, 4.0); Complex z = x.negate(); - Assert.assertEquals(-3.0, z.getReal(), 1.0e-5); - Assert.assertEquals(-4.0, z.getImaginary(), 1.0e-5); + Assertions.assertEquals(-3.0, z.getReal(), 1.0e-5); + Assertions.assertEquals(-4.0, z.getImaginary(), 1.0e-5); } @Test public void testNegateNaN() { Complex z = NAN.negate(); - Assert.assertTrue(z.isNaN()); + Assertions.assertTrue(z.isNaN()); } @Test @@ -338,8 +337,8 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); Complex y = Complex.ofCartesian(5.0, 6.0); Complex z = x.subtract(y); - Assert.assertEquals(-2.0, z.getReal(), 1.0e-5); - Assert.assertEquals(-2.0, z.getImaginary(), 1.0e-5); + Assertions.assertEquals(-2.0, z.getReal(), 1.0e-5); + Assertions.assertEquals(-2.0, z.getImaginary(), 1.0e-5); } @Test @@ -347,11 +346,11 @@ public class ComplexTest { Complex x = Complex.ofCartesian(1, 1); Complex z = Complex.ofCartesian(neginf, 0); Complex w = x.subtract(z); - Assert.assertEquals(w.getImaginary(), 1, 0); - Assert.assertEquals(inf, w.getReal(), 0); + Assertions.assertEquals(w.getImaginary(), 1, 0); + Assertions.assertEquals(inf, w.getReal(), 0); x = Complex.ofCartesian(neginf, 0); - Assert.assertTrue(Double.isNaN(x.subtract(z).getReal())); + Assertions.assertTrue(Double.isNaN(x.subtract(z).getReal())); } @Test @@ -359,7 +358,7 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = 2.0; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.subtract(yComplex), x.subtract(yDouble)); + Assertions.assertEquals(x.subtract(yComplex), x.subtract(yDouble)); } @Test @@ -367,7 +366,7 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = Double.NaN; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.subtract(yComplex), x.subtract(yDouble)); + Assertions.assertEquals(x.subtract(yComplex), x.subtract(yDouble)); } @Test @@ -375,27 +374,27 @@ public class ComplexTest { Complex x = Complex.ofCartesian(1, 1); double yDouble = Double.POSITIVE_INFINITY; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.subtract(yComplex), x.subtract(yDouble)); + Assertions.assertEquals(x.subtract(yComplex), x.subtract(yDouble)); x = Complex.ofCartesian(neginf, 0); - Assert.assertEquals(x.subtract(yComplex), x.subtract(yDouble)); + Assertions.assertEquals(x.subtract(yComplex), x.subtract(yDouble)); } @Test public void testEqualsNull() { Complex x = Complex.ofCartesian(3.0, 4.0); - Assert.assertFalse(x.equals(null)); + Assertions.assertFalse(x.equals(null)); } - @Test() + @Test public void testFloatingPointEqualsPrecondition1() { Assertions.assertThrows(NullPointerException.class, () -> Complex.equals(Complex.ofCartesian(3.0, 4.0), null, 3) ); } - @Test() + @Test public void testFloatingPointEqualsPrecondition2() { Assertions.assertThrows(NullPointerException.class, () -> Complex.equals(null, Complex.ofCartesian(3.0, 4.0), 3) @@ -405,13 +404,13 @@ public class ComplexTest { @Test public void testEqualsClass() { Complex x = Complex.ofCartesian(3.0, 4.0); - Assert.assertFalse(x.equals(this)); + Assertions.assertFalse(x.equals(this)); } @Test public void testEqualsSame() { Complex x = Complex.ofCartesian(3.0, 4.0); - Assert.assertTrue(x.equals(x)); + Assertions.assertTrue(x.equals(x)); } @Test @@ -422,8 +421,8 @@ public class ComplexTest { final Complex x = Complex.ofCartesian(re, im); Complex y = Complex.ofCartesian(re, im); - Assert.assertTrue(x.equals(y)); - Assert.assertTrue(Complex.equals(x, y)); + Assertions.assertTrue(x.equals(y)); + Assertions.assertTrue(Complex.equals(x, y)); final int maxUlps = 5; for (int i = 0; i < maxUlps; i++) { @@ -431,21 +430,21 @@ public class ComplexTest { im = Math.nextUp(im); } y = Complex.ofCartesian(re, im); - Assert.assertTrue(Complex.equals(x, y, maxUlps)); + Assertions.assertTrue(Complex.equals(x, y, maxUlps)); re = Math.nextUp(re); im = Math.nextUp(im); y = Complex.ofCartesian(re, im); - Assert.assertFalse(Complex.equals(x, y, maxUlps)); + Assertions.assertFalse(Complex.equals(x, y, maxUlps)); } @Test public void testFloatingPointEqualsNaN() { Complex c = Complex.ofCartesian(Double.NaN, 1); - Assert.assertFalse(Complex.equals(c, c)); + Assertions.assertFalse(Complex.equals(c, c)); c = Complex.ofCartesian(1, Double.NaN); - Assert.assertFalse(Complex.equals(c, c)); + Assertions.assertFalse(Complex.equals(c, c)); } @Test @@ -455,19 +454,19 @@ public class ComplexTest { final double tol1 = 0.0625; final Complex x = Complex.ofCartesian(re, im); final Complex y = Complex.ofCartesian(re + tol1, im + tol1); - Assert.assertTrue(Complex.equals(x, y, tol1)); + Assertions.assertTrue(Complex.equals(x, y, tol1)); final double tol2 = 0.0624; - Assert.assertFalse(Complex.equals(x, y, tol2)); + Assertions.assertFalse(Complex.equals(x, y, tol2)); } @Test public void testFloatingPointEqualsWithAllowedDeltaNaN() { final Complex x = Complex.ofCartesian(0, Double.NaN); final Complex y = Complex.ofCartesian(Double.NaN, 0); - Assert.assertFalse(Complex.equals(x, Complex.ZERO, 0.1)); - Assert.assertFalse(Complex.equals(x, x, 0.1)); - Assert.assertFalse(Complex.equals(x, y, 0.1)); + Assertions.assertFalse(Complex.equals(x, Complex.ZERO, 0.1)); + Assertions.assertFalse(Complex.equals(x, x, 0.1)); + Assertions.assertFalse(Complex.equals(x, y, 0.1)); } @Test @@ -479,50 +478,50 @@ public class ComplexTest { final double f = 1 + tol; final Complex x = Complex.ofCartesian(re, im); final Complex y = Complex.ofCartesian(re * f, im * f); - Assert.assertTrue(Complex.equalsWithRelativeTolerance(x, y, tol)); + Assertions.assertTrue(Complex.equalsWithRelativeTolerance(x, y, tol)); } @Test public void testFloatingPointEqualsWithRelativeToleranceNaN() { final Complex x = Complex.ofCartesian(0, Double.NaN); final Complex y = Complex.ofCartesian(Double.NaN, 0); - Assert.assertFalse(Complex.equalsWithRelativeTolerance(x, Complex.ZERO, 0.1)); - Assert.assertFalse(Complex.equalsWithRelativeTolerance(x, x, 0.1)); - Assert.assertFalse(Complex.equalsWithRelativeTolerance(x, y, 0.1)); + Assertions.assertFalse(Complex.equalsWithRelativeTolerance(x, Complex.ZERO, 0.1)); + Assertions.assertFalse(Complex.equalsWithRelativeTolerance(x, x, 0.1)); + Assertions.assertFalse(Complex.equalsWithRelativeTolerance(x, y, 0.1)); } @Test public void testEqualsTrue() { Complex x = Complex.ofCartesian(3.0, 4.0); Complex y = Complex.ofCartesian(3.0, 4.0); - Assert.assertTrue(x.equals(y)); + Assertions.assertTrue(x.equals(y)); } @Test public void testEqualsRealDifference() { Complex x = Complex.ofCartesian(0.0, 0.0); Complex y = Complex.ofCartesian(0.0 + Double.MIN_VALUE, 0.0); - Assert.assertFalse(x.equals(y)); + Assertions.assertFalse(x.equals(y)); } @Test public void testEqualsImaginaryDifference() { Complex x = Complex.ofCartesian(0.0, 0.0); Complex y = Complex.ofCartesian(0.0, 0.0 + Double.MIN_VALUE); - Assert.assertFalse(x.equals(y)); + Assertions.assertFalse(x.equals(y)); } @Test public void testHashCode() { Complex x = Complex.ofCartesian(0.0, 0.0); Complex y = Complex.ofCartesian(0.0, 0.0 + Double.MIN_VALUE); - Assert.assertFalse(x.hashCode()==y.hashCode()); + Assertions.assertFalse(x.hashCode()==y.hashCode()); y = Complex.ofCartesian(0.0 + Double.MIN_VALUE, 0.0); - Assert.assertFalse(x.hashCode()==y.hashCode()); + Assertions.assertFalse(x.hashCode()==y.hashCode()); Complex realNaN = Complex.ofCartesian(Double.NaN, 0.0); Complex imaginaryNaN = Complex.ofCartesian(0.0, Double.NaN); - Assert.assertEquals(realNaN.hashCode(), imaginaryNaN.hashCode()); - Assert.assertEquals(imaginaryNaN.hashCode(), NAN.hashCode()); + Assertions.assertEquals(realNaN.hashCode(), imaginaryNaN.hashCode()); + Assertions.assertEquals(imaginaryNaN.hashCode(), NAN.hashCode()); // MATH-1118 // "equals" and "hashCode" must be compatible: if two objects have @@ -531,13 +530,13 @@ public class ComplexTest { x = Complex.ofCartesian(0.0, 0.0); y = Complex.ofCartesian(0.0, -0.0); - Assert.assertTrue(x.hashCode() != y.hashCode()); - Assert.assertFalse(msg, x.equals(y)); + Assertions.assertTrue(x.hashCode() != y.hashCode()); + Assertions.assertFalse(x.equals(y), msg); x = Complex.ofCartesian(0.0, 0.0); y = Complex.ofCartesian(-0.0, 0.0); - Assert.assertTrue(x.hashCode() != y.hashCode()); - Assert.assertFalse(msg, x.equals(y)); + Assertions.assertTrue(x.hashCode() != y.hashCode()); + Assertions.assertFalse(x.equals(y), msg); } @Test @@ -574,7 +573,7 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3, 4); double yDouble = 5.0; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.pow(yComplex), x.pow(yDouble)); + Assertions.assertEquals(x.pow(yComplex), x.pow(yDouble)); } @Test @@ -582,7 +581,7 @@ public class ComplexTest { Complex x = NAN; double yDouble = 5.0; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.pow(yComplex), x.pow(yDouble)); + Assertions.assertEquals(x.pow(yComplex), x.pow(yDouble)); } @Test @@ -590,7 +589,7 @@ public class ComplexTest { Complex x = Complex.ofCartesian(3, 4); double yDouble = Double.NaN; Complex yComplex = Complex.ofReal(yDouble); - Assert.assertEquals(x.pow(yComplex), x.pow(yDouble)); + Assertions.assertEquals(x.pow(yComplex), x.pow(yDouble)); } @Test public void testSqrtPolar() { @@ -626,16 +625,16 @@ public class ComplexTest { // The List holding all third roots Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]); // Returned Collection must not be empty! - Assert.assertEquals(3, thirdRootsOfZ.length); + Assertions.assertEquals(3, thirdRootsOfZ.length); // test z_0 - Assert.assertEquals(1.0, thirdRootsOfZ[0].getReal(), 1.0e-5); - Assert.assertEquals(1.0, thirdRootsOfZ[0].getImaginary(), 1.0e-5); + Assertions.assertEquals(1.0, thirdRootsOfZ[0].getReal(), 1.0e-5); + Assertions.assertEquals(1.0, thirdRootsOfZ[0].getImaginary(), 1.0e-5); // test z_1 - Assert.assertEquals(-1.3660254037844386, thirdRootsOfZ[1].getReal(), 1.0e-5); - Assert.assertEquals(0.36602540378443843, thirdRootsOfZ[1].getImaginary(), 1.0e-5); + Assertions.assertEquals(-1.3660254037844386, thirdRootsOfZ[1].getReal(), 1.0e-5); + Assertions.assertEquals(0.36602540378443843, thirdRootsOfZ[1].getImaginary(), 1.0e-5); // test z_2 - Assert.assertEquals(0.366025403784439, thirdRootsOfZ[2].getReal(), 1.0e-5); - Assert.assertEquals(-1.3660254037844384, thirdRootsOfZ[2].getImaginary(), 1.0e-5); + Assertions.assertEquals(0.366025403784439, thirdRootsOfZ[2].getReal(), 1.0e-5); + Assertions.assertEquals(-1.3660254037844384, thirdRootsOfZ[2].getImaginary(), 1.0e-5); } @@ -658,19 +657,19 @@ public class ComplexTest { // The List holding all fourth roots Complex[] fourthRootsOfZ = z.nthRoot(4).toArray(new Complex[0]); // Returned Collection must not be empty! - Assert.assertEquals(4, fourthRootsOfZ.length); + Assertions.assertEquals(4, fourthRootsOfZ.length); // test z_0 - Assert.assertEquals(1.5164629308487783, fourthRootsOfZ[0].getReal(), 1.0e-5); - Assert.assertEquals(-0.14469266210702247, fourthRootsOfZ[0].getImaginary(), 1.0e-5); + Assertions.assertEquals(1.5164629308487783, fourthRootsOfZ[0].getReal(), 1.0e-5); + Assertions.assertEquals(-0.14469266210702247, fourthRootsOfZ[0].getImaginary(), 1.0e-5); // test z_1 - Assert.assertEquals(0.14469266210702256, fourthRootsOfZ[1].getReal(), 1.0e-5); - Assert.assertEquals(1.5164629308487783, fourthRootsOfZ[1].getImaginary(), 1.0e-5); + Assertions.assertEquals(0.14469266210702256, fourthRootsOfZ[1].getReal(), 1.0e-5); + Assertions.assertEquals(1.5164629308487783, fourthRootsOfZ[1].getImaginary(), 1.0e-5); // test z_2 - Assert.assertEquals(-1.5164629308487783, fourthRootsOfZ[2].getReal(), 1.0e-5); - Assert.assertEquals(0.14469266210702267, fourthRootsOfZ[2].getImaginary(), 1.0e-5); + Assertions.assertEquals(-1.5164629308487783, fourthRootsOfZ[2].getReal(), 1.0e-5); + Assertions.assertEquals(0.14469266210702267, fourthRootsOfZ[2].getImaginary(), 1.0e-5); // test z_3 - Assert.assertEquals(-0.14469266210702275, fourthRootsOfZ[3].getReal(), 1.0e-5); - Assert.assertEquals(-1.5164629308487783, fourthRootsOfZ[3].getImaginary(), 1.0e-5); + Assertions.assertEquals(-0.14469266210702275, fourthRootsOfZ[3].getReal(), 1.0e-5); + Assertions.assertEquals(-1.5164629308487783, fourthRootsOfZ[3].getImaginary(), 1.0e-5); } /** @@ -692,16 +691,16 @@ public class ComplexTest { // The List holding all third roots Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]); // Returned Collection must not be empty! - Assert.assertEquals(3, thirdRootsOfZ.length); + Assertions.assertEquals(3, thirdRootsOfZ.length); // test z_0 - Assert.assertEquals(2.0, thirdRootsOfZ[0].getReal(), 1.0e-5); - Assert.assertEquals(0.0, thirdRootsOfZ[0].getImaginary(), 1.0e-5); + Assertions.assertEquals(2.0, thirdRootsOfZ[0].getReal(), 1.0e-5); + Assertions.assertEquals(0.0, thirdRootsOfZ[0].getImaginary(), 1.0e-5); // test z_1 - Assert.assertEquals(-1.0, thirdRootsOfZ[1].getReal(), 1.0e-5); - Assert.assertEquals(1.7320508075688774, thirdRootsOfZ[1].getImaginary(), 1.0e-5); + Assertions.assertEquals(-1.0, thirdRootsOfZ[1].getReal(), 1.0e-5); + Assertions.assertEquals(1.7320508075688774, thirdRootsOfZ[1].getImaginary(), 1.0e-5); // test z_2 - Assert.assertEquals(-1.0, thirdRootsOfZ[2].getReal(), 1.0e-5); - Assert.assertEquals(-1.732050807568877, thirdRootsOfZ[2].getImaginary(), 1.0e-5); + Assertions.assertEquals(-1.0, thirdRootsOfZ[2].getReal(), 1.0e-5); + Assertions.assertEquals(-1.732050807568877, thirdRootsOfZ[2].getImaginary(), 1.0e-5); } @@ -723,16 +722,16 @@ public class ComplexTest { // The List holding all third roots Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]); // Returned Collection must not be empty! - Assert.assertEquals(3, thirdRootsOfZ.length); + Assertions.assertEquals(3, thirdRootsOfZ.length); // test z_0 - Assert.assertEquals(1.0911236359717216, thirdRootsOfZ[0].getReal(), 1.0e-5); - Assert.assertEquals(0.6299605249474365, thirdRootsOfZ[0].getImaginary(), 1.0e-5); + Assertions.assertEquals(1.0911236359717216, thirdRootsOfZ[0].getReal(), 1.0e-5); + Assertions.assertEquals(0.6299605249474365, thirdRootsOfZ[0].getImaginary(), 1.0e-5); // test z_1 - Assert.assertEquals(-1.0911236359717216, thirdRootsOfZ[1].getReal(), 1.0e-5); - Assert.assertEquals(0.6299605249474365, thirdRootsOfZ[1].getImaginary(), 1.0e-5); + Assertions.assertEquals(-1.0911236359717216, thirdRootsOfZ[1].getReal(), 1.0e-5); + Assertions.assertEquals(0.6299605249474365, thirdRootsOfZ[1].getImaginary(), 1.0e-5); // test z_2 - Assert.assertEquals(-2.3144374213981936E-16, thirdRootsOfZ[2].getReal(), 1.0e-5); - Assert.assertEquals(-1.2599210498948732, thirdRootsOfZ[2].getImaginary(), 1.0e-5); + Assertions.assertEquals(-2.3144374213981936E-16, thirdRootsOfZ[2].getReal(), 1.0e-5); + Assertions.assertEquals(-1.2599210498948732, thirdRootsOfZ[2].getImaginary(), 1.0e-5); } /** @@ -757,31 +756,31 @@ public class ComplexTest { // The List holding all fourth roots Complex[] fourthRootsOfZ = z.nthRoot(4).toArray(new Complex[0]); // test z_0 - Assert.assertEquals(1, fourthRootsOfZ[0].getReal(), 1.0e-5); - Assert.assertEquals(0, fourthRootsOfZ[0].getImaginary(), 1.0e-5); + Assertions.assertEquals(1, fourthRootsOfZ[0].getReal(), 1.0e-5); + Assertions.assertEquals(0, fourthRootsOfZ[0].getImaginary(), 1.0e-5); // test z_1 - Assert.assertEquals(0, fourthRootsOfZ[1].getReal(), 1.0e-5); - Assert.assertEquals(1, fourthRootsOfZ[1].getImaginary(), 1.0e-5); + Assertions.assertEquals(0, fourthRootsOfZ[1].getReal(), 1.0e-5); + Assertions.assertEquals(1, fourthRootsOfZ[1].getImaginary(), 1.0e-5); // test z_2 - Assert.assertEquals(-1, fourthRootsOfZ[2].getReal(), 1.0e-5); - Assert.assertEquals(0, fourthRootsOfZ[2].getImaginary(), 1.0e-5); + Assertions.assertEquals(-1, fourthRootsOfZ[2].getReal(), 1.0e-5); + Assertions.assertEquals(0, fourthRootsOfZ[2].getImaginary(), 1.0e-5); // test z_3 - Assert.assertEquals(0, fourthRootsOfZ[3].getReal(), 1.0e-5); - Assert.assertEquals(-1, fourthRootsOfZ[3].getImaginary(), 1.0e-5); + Assertions.assertEquals(0, fourthRootsOfZ[3].getReal(), 1.0e-5); + Assertions.assertEquals(-1, fourthRootsOfZ[3].getImaginary(), 1.0e-5); // go clockwise around the unit circle using negative argument fourthRootsOfZ = z.nthRoot(-4).toArray(new Complex[0]); // test z_0 - Assert.assertEquals(1, fourthRootsOfZ[0].getReal(), 1.0e-5); - Assert.assertEquals(0, fourthRootsOfZ[0].getImaginary(), 1.0e-5); + Assertions.assertEquals(1, fourthRootsOfZ[0].getReal(), 1.0e-5); + Assertions.assertEquals(0, fourthRootsOfZ[0].getImaginary(), 1.0e-5); // test z_1 - Assert.assertEquals(0, fourthRootsOfZ[1].getReal(), 1.0e-5); - Assert.assertEquals(-1, fourthRootsOfZ[1].getImaginary(), 1.0e-5); + Assertions.assertEquals(0, fourthRootsOfZ[1].getReal(), 1.0e-5); + Assertions.assertEquals(-1, fourthRootsOfZ[1].getImaginary(), 1.0e-5); // test z_2 - Assert.assertEquals(-1, fourthRootsOfZ[2].getReal(), 1.0e-5); - Assert.assertEquals(0, fourthRootsOfZ[2].getImaginary(), 1.0e-5); + Assertions.assertEquals(-1, fourthRootsOfZ[2].getReal(), 1.0e-5); + Assertions.assertEquals(0, fourthRootsOfZ[2].getImaginary(), 1.0e-5); // test z_3 - Assert.assertEquals(0, fourthRootsOfZ[3].getReal(), 1.0e-5); - Assert.assertEquals(1, fourthRootsOfZ[3].getImaginary(), 1.0e-5); + Assertions.assertEquals(0, fourthRootsOfZ[3].getReal(), 1.0e-5); + Assertions.assertEquals(1, fourthRootsOfZ[3].getImaginary(), 1.0e-5); } /** * Test standard values @@ -789,28 +788,28 @@ public class ComplexTest { @Test public void testGetArgument() { Complex z = Complex.ofCartesian(1, 0); - Assert.assertEquals(0.0, z.getArgument(), 1.0e-12); + Assertions.assertEquals(0.0, z.getArgument(), 1.0e-12); z = Complex.ofCartesian(1, 1); - Assert.assertEquals(Math.PI/4, z.getArgument(), 1.0e-12); + Assertions.assertEquals(Math.PI/4, z.getArgument(), 1.0e-12); z = Complex.ofCartesian(0, 1); - Assert.assertEquals(Math.PI/2, z.getArgument(), 1.0e-12); + Assertions.assertEquals(Math.PI/2, z.getArgument(), 1.0e-12); z = Complex.ofCartesian(-1, 1); - Assert.assertEquals(3 * Math.PI/4, z.getArgument(), 1.0e-12); + Assertions.assertEquals(3 * Math.PI/4, z.getArgument(), 1.0e-12); z = Complex.ofCartesian(-1, 0); - Assert.assertEquals(Math.PI, z.getArgument(), 1.0e-12); + Assertions.assertEquals(Math.PI, z.getArgument(), 1.0e-12); z = Complex.ofCartesian(-1, -1); - Assert.assertEquals(-3 * Math.PI/4, z.getArgument(), 1.0e-12); + Assertions.assertEquals(-3 * Math.PI/4, z.getArgument(), 1.0e-12); z = Complex.ofCartesian(0, -1); - Assert.assertEquals(-Math.PI/2, z.getArgument(), 1.0e-12); + Assertions.assertEquals(-Math.PI/2, z.getArgument(), 1.0e-12); z = Complex.ofCartesian(1, -1); - Assert.assertEquals(-Math.PI/4, z.getArgument(), 1.0e-12); + Assertions.assertEquals(-Math.PI/4, z.getArgument(), 1.0e-12); } @@ -819,14 +818,14 @@ public class ComplexTest { */ @Test public void testGetArgumentInf() { - Assert.assertEquals(Math.PI/4, infInf.getArgument(), 1.0e-12); - Assert.assertEquals(Math.PI/2, oneInf.getArgument(), 1.0e-12); - Assert.assertEquals(0.0, infOne.getArgument(), 1.0e-12); - Assert.assertEquals(Math.PI/2, zeroInf.getArgument(), 1.0e-12); - Assert.assertEquals(0.0, infZero.getArgument(), 1.0e-12); - Assert.assertEquals(Math.PI, negInfOne.getArgument(), 1.0e-12); - Assert.assertEquals(-3.0*Math.PI/4, negInfNegInf.getArgument(), 1.0e-12); - Assert.assertEquals(-Math.PI/2, oneNegInf.getArgument(), 1.0e-12); + Assertions.assertEquals(Math.PI/4, infInf.getArgument(), 1.0e-12); + Assertions.assertEquals(Math.PI/2, oneInf.getArgument(), 1.0e-12); + Assertions.assertEquals(0.0, infOne.getArgument(), 1.0e-12); + Assertions.assertEquals(Math.PI/2, zeroInf.getArgument(), 1.0e-12); + Assertions.assertEquals(0.0, infZero.getArgument(), 1.0e-12); + Assertions.assertEquals(Math.PI, negInfOne.getArgument(), 1.0e-12); + Assertions.assertEquals(-3.0*Math.PI/4, negInfNegInf.getArgument(), 1.0e-12); + Assertions.assertEquals(-Math.PI/2, oneNegInf.getArgument(), 1.0e-12); } /** @@ -834,26 +833,26 @@ public class ComplexTest { */ @Test public void testGetArgumentNaN() { - Assert.assertTrue(Double.isNaN(nanZero.getArgument())); - Assert.assertTrue(Double.isNaN(zeroNaN.getArgument())); - Assert.assertTrue(Double.isNaN(NAN.getArgument())); + Assertions.assertTrue(Double.isNaN(nanZero.getArgument())); + Assertions.assertTrue(Double.isNaN(zeroNaN.getArgument())); + Assertions.assertTrue(Double.isNaN(NAN.getArgument())); } @Test public void testParse() { - Assert.assertTrue(Complex.ZERO.equals(Complex.parse(Complex.ZERO.toString()))); - Assert.assertTrue(Complex.ONE.equals(Complex.parse(Complex.ONE.toString()))); - Assert.assertTrue(Complex.I.equals(Complex.parse(Complex.I.toString()))); - Assert.assertTrue(Complex.INF.equals(Complex.parse(Complex.INF.toString()))); - Assert.assertTrue(NAN.equals(Complex.parse(NAN.toString()))); - Assert.assertTrue(oneInf.equals(Complex.parse(oneInf.toString()))); - Assert.assertTrue(negInfZero.equals(Complex.parse(negInfZero.toString()))); - Assert.assertTrue(Complex.ofReal(pi).equals(Complex.parse(Complex.ofReal(pi).toString()))); - Assert.assertTrue(Complex.ofPolar(2, pi).equals(Complex.parse(Complex.ofPolar(2, pi).toString()))); - Assert.assertTrue(Complex.ofCis(pi).equals(Complex.parse(Complex.ofCis(pi).toString()))); - } - - @Test() + Assertions.assertTrue(Complex.ZERO.equals(Complex.parse(Complex.ZERO.toString()))); + Assertions.assertTrue(Complex.ONE.equals(Complex.parse(Complex.ONE.toString()))); + Assertions.assertTrue(Complex.I.equals(Complex.parse(Complex.I.toString()))); + Assertions.assertTrue(Complex.INF.equals(Complex.parse(Complex.INF.toString()))); + Assertions.assertTrue(NAN.equals(Complex.parse(NAN.toString()))); + Assertions.assertTrue(oneInf.equals(Complex.parse(oneInf.toString()))); + Assertions.assertTrue(negInfZero.equals(Complex.parse(negInfZero.toString()))); + Assertions.assertTrue(Complex.ofReal(pi).equals(Complex.parse(Complex.ofReal(pi).toString()))); + Assertions.assertTrue(Complex.ofPolar(2, pi).equals(Complex.parse(Complex.ofPolar(2, pi).toString()))); + Assertions.assertTrue(Complex.ofCis(pi).equals(Complex.parse(Complex.ofCis(pi).toString()))); + } + + @Test public void testParseWrongStart() { final String re = "1.234"; final String im = "5.678"; @@ -862,7 +861,7 @@ public class ComplexTest { ); } - @Test() + @Test public void testParseWrongEnd() { final String re = "1.234"; final String im = "5.678"; @@ -871,7 +870,7 @@ public class ComplexTest { ); } - @Test() + @Test public void testParseMissingSeparator() { final String re = "1.234"; final String im = "5.678"; @@ -879,7 +878,7 @@ public class ComplexTest { () -> Complex.parse("(" + re + " " + im + ")") ); } - @Test() + @Test public void testParseInvalidRe() { final String re = "I.234"; final String im = "5.678"; @@ -887,7 +886,7 @@ public class ComplexTest { () -> Complex.parse("(" + re + "," + im + ")") ); } - @Test() + @Test public void testParseInvalidIm() { final String re = "1.234"; final String im = "5.G78"; @@ -901,6 +900,6 @@ public class ComplexTest { final double re = 1.234; final double im = 5.678; final String str = "( " + re + " , " + im + " )"; - Assert.assertTrue(Complex.ofCartesian(re, im).equals(Complex.parse(str))); + Assertions.assertTrue(Complex.ofCartesian(re, im).equals(Complex.parse(str))); } } diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java index 5515597..484dc07 100644 --- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java +++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java @@ -26,7 +26,7 @@ import java.io.ObjectOutputStream; import org.apache.commons.numbers.complex.Complex; import org.apache.commons.numbers.core.Precision; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; /** * Test utilities. @@ -45,7 +45,7 @@ public class TestUtils { * infinities of the same sign. */ public static void assertEquals(double expected, double actual, double delta) { - Assert.assertEquals(null, expected, actual, delta); + Assertions.assertEquals(expected, actual, delta, (String) null); } /** @@ -55,10 +55,10 @@ public class TestUtils { public static void assertEquals(String msg, double expected, double actual, double delta) { // check for NaN if(Double.isNaN(expected)){ - Assert.assertTrue("" + actual + " is not NaN.", - Double.isNaN(actual)); + Assertions.assertTrue(Double.isNaN(actual), + "" + actual + " is not NaN."); } else { - Assert.assertEquals(msg, expected, actual, delta); + Assertions.assertEquals(expected, actual, delta, msg); } } @@ -67,7 +67,7 @@ public class TestUtils { * both NaN or infinities of same sign, or identical floating point values. */ public static void assertSame(double expected, double actual) { - Assert.assertEquals(expected, actual, 0); + Assertions.assertEquals(expected, actual, 0); } /** @@ -84,8 +84,8 @@ public class TestUtils { * differ by at most delta. Also ensures that NaN / infinite components match. */ public static void assertEquals(Complex expected, Complex actual, double delta) { - Assert.assertEquals(expected.getReal(), actual.getReal(), delta); - Assert.assertEquals(expected.getImaginary(), actual.getImaginary(), delta); + Assertions.assertEquals(expected.getReal(), actual.getReal(), delta); + Assertions.assertEquals(expected.getImaginary(), actual.getImaginary(), delta); } /** @@ -128,8 +128,8 @@ public class TestUtils { */ public static void checkSerializedEquality(Object object) { Object object2 = serializeAndRecover(object); - Assert.assertEquals("Equals check", object, object2); - Assert.assertEquals("HashCode check", object.hashCode(), object2.hashCode()); + Assertions.assertEquals(object, object2, "Equals check"); + Assertions.assertEquals(object.hashCode(), object2.hashCode(), "HashCode check"); } /** @@ -159,16 +159,16 @@ public class TestUtils { public static void assertRelativelyEquals(String msg, double expected, double actual, double relativeError) { if (Double.isNaN(expected)) { - Assert.assertTrue(msg, Double.isNaN(actual)); + Assertions.assertTrue(Double.isNaN(actual), msg); } else if (Double.isNaN(actual)) { - Assert.assertTrue(msg, Double.isNaN(expected)); + Assertions.assertTrue(Double.isNaN(expected), msg); } else if (Double.isInfinite(actual) || Double.isInfinite(expected)) { - Assert.assertEquals(expected, actual, relativeError); + Assertions.assertEquals(expected, actual, relativeError); } else if (expected == 0.0) { - Assert.assertEquals(msg, actual, expected, relativeError); + Assertions.assertEquals(actual, expected, relativeError, msg); } else { double absError = Math.abs(expected) * relativeError; - Assert.assertEquals(msg, expected, actual, absError); + Assertions.assertEquals(expected, actual, absError, msg); } } @@ -188,7 +188,7 @@ public class TestUtils { return; } } - Assert.fail(msg + " Unable to find " + z); + Assertions.fail(msg + " Unable to find " + z); } /** @@ -218,7 +218,7 @@ public class TestUtils { return; } } - Assert.fail(msg + " Unable to find " + x); + Assertions.fail(msg + " Unable to find " + x); } /** @@ -242,7 +242,7 @@ public class TestUtils { out.append(expected.length); out.append(" observed length = "); out.append(observed.length); - Assert.fail(out.toString()); + Assertions.fail(out.toString()); } boolean failure = false; for (int i=0; i < expected.length; i++) { @@ -258,7 +258,7 @@ public class TestUtils { } } if (failure) { - Assert.fail(out.toString()); + Assertions.fail(out.toString()); } } @@ -271,7 +271,7 @@ public class TestUtils { out.append(expected.length); out.append(" observed length = "); out.append(observed.length); - Assert.fail(out.toString()); + Assertions.fail(out.toString()); } boolean failure = false; for (int i=0; i < expected.length; i++) { @@ -287,7 +287,7 @@ public class TestUtils { } } if (failure) { - Assert.fail(out.toString()); + Assertions.fail(out.toString()); } } @@ -300,7 +300,7 @@ public class TestUtils { out.append(expected.length); out.append(" observed length = "); out.append(observed.length); - Assert.fail(out.toString()); + Assertions.fail(out.toString()); } boolean failure = false; for (int i=0; i < expected.length; i++) { @@ -326,7 +326,7 @@ public class TestUtils { } } if (failure) { - Assert.fail(out.toString()); + Assertions.fail(out.toString()); } }
