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 280563c00a118ceb6d7dcea87f6de6141d838a68 Author: Schamschi <heinrich.bo...@gmx.at> AuthorDate: Sun Jun 9 01:03:39 2019 +0200 Migrate commons-numbers-core to JUnit 5: class TestUtils (previously overlooked) --- .../org/apache/commons/numbers/core/TestUtils.java | 37 +++++++++++----------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/TestUtils.java b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/TestUtils.java index b1feca0..bf9c333 100644 --- a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/TestUtils.java +++ b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/TestUtils.java @@ -23,8 +23,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; /** * Test utilities. @@ -43,7 +42,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); } /** @@ -53,10 +52,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); } } @@ -65,7 +64,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); } /** @@ -108,8 +107,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"); } /** @@ -139,16 +138,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); } } @@ -167,7 +166,7 @@ public class TestUtils { return; } } - Assert.fail(msg + " Unable to find " + x); + Assertions.fail(msg + " Unable to find " + x); } /** @@ -191,7 +190,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++) { @@ -207,7 +206,7 @@ public class TestUtils { } } if (failure) { - Assert.fail(out.toString()); + Assertions.fail(out.toString()); } } @@ -220,7 +219,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++) { @@ -236,7 +235,7 @@ public class TestUtils { } } if (failure) { - Assert.fail(out.toString()); + Assertions.fail(out.toString()); } }