You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/06/18 13:16:45 UTC
[commons-numbers] branch master updated (934be57 -> c3586cf)
This is an automated email from the ASF dual-hosted git repository.
erans pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git.
from 934be57 Merge branch 'NUMBERS-100__heinrich'
add 7ed19c0 Migrate to JUnit 5
add a309a08 Migrate commons-numbers-primes to JUnit 5: class SmallPrimesTest
add 5692848 Migrate commons-numbers-primes to JUnit 5: class PrimesTest
add 32ab41b Migrate commons-numbers-quaternion to JUnit 5: class QuaternionTest
add 6d64caf Migrate commons-numbers-quaternion to JUnit 5: class SlerpTest
add 205fa8f Migrate commons-numbers-gamma to JUnit 5: class DigammaTest
add af6e7a3 Migrate commons-numbers-gamma to JUnit 5: class ErfcTest
add a28928f Migrate commons-numbers-gamma to JUnit 5: class ErfDifferenceTest
add 8508164 Merge branch 'master' of http://gitbox.apache.org/repos/asf/commons-numbers into eax/simple-migrate-map
new fd3fd3c Merge branch 'master' into eax/simple-migrate-map
new 560f15c Migrate commons-numbers-gamma to JUnit 5: all remaining classes
new 5f7f230 Restore relevant changes overwritten in the merge of the master branch
new 3d5fab4 BigFraction: use factory method
new 888e00e Revert "BigFraction: use factory method"
new 62e6c9d Merge remote-tracking branch 'origin/master' into eax/simple-migrate-map
new ad2d928 re-add one and zero
new ab5d960 Merge branch 'master' of http://gitbox.apache.org/repos/asf/commons-numbers into eax/simple-migrate-map
new 526d93f fix FieldParametricTest
new a26ba7a re-add one and zero
new d952ad5 Migrate commons-numbers-core to JUnit 5
new 280563c Migrate commons-numbers-core to JUnit 5: class TestUtils (previously overlooked)
new a11713e Merge branch 'eax/simple-migrate-map' of github.com:grimreaper/commons-numbers into eax/simple-migrate-map
new fe4d700 Add the dep
new 773f4d7 Migrate commons-numbers-complex-streams to JUnit 5
new 4718fc2 Remove unneeded parentheses in class ComplexUtilsTest
new 296dd8d Migrate commons-numbers-complex to JUnit 5
new f5837b7 Migrate commons-numbers-combinatorics to JUnit 5: 3 classes
new 6ee8578 BrentSolverTest: do JUnit 5
new e8a071e Order of arguments
new de949a1 Simplify junit
new d6b008c use JUnit 5 assertions
new bf6de4f Fix stragglers
new 74c8a9c One more step
new b888cbc Assert does not throw
new c76f3e7 Replace assertNotEquals with assertFalse where necessary
new e12bf62 Correct parameter order in assertEquals
new 9aa77a9 Merge branch 'master' into eax/simple-migrate-map
new 44461dd Migrate commons-numbers-fraction to JUnit 5: class FractionTest
new 4fd2f59 Remove unused JUnit 4 imports
new af0d00f Remove unnecessary parentheses in Test annotations
new fe63782 Revert inappropriate replacement of assertFalse with assertNotEquals
new b1a114f Add Generics in test classes of commons-numbers-field
new c3586cf Merge branch 'NUMBERS-115__heinrich'
The 34 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../numbers/angle/PlaneAngleRadiansTest.java | 34 +-
.../commons/numbers/angle/PlaneAngleTest.java | 74 ++--
.../commons/numbers/arrays/CosAngleTest.java | 24 +-
.../numbers/arrays/LinearCombinationTest.java | 88 ++--
.../commons/numbers/arrays/SafeNormTest.java | 18 +-
.../BinomialCoefficientDoubleTest.java | 48 ++-
.../combinatorics/BinomialCoefficientTest.java | 89 ++--
.../numbers/combinatorics/CombinationsTest.java | 84 ++--
.../numbers/combinatorics/FactorialDoubleTest.java | 47 ++-
.../numbers/combinatorics/FactorialTest.java | 20 +-
.../combinatorics/LogBinomialCoefficientTest.java | 36 +-
.../numbers/combinatorics/LogFactorialTest.java | 30 +-
.../numbers/complex/streams/ComplexUtilsTest.java | 174 +++++---
.../commons/numbers/complex/streams/TestUtils.java | 22 +-
.../commons/numbers/complex/CStandardTest.java | 13 +-
.../commons/numbers/complex/ComplexTest.java | 404 +++++++++---------
.../apache/commons/numbers/complex/TestUtils.java | 46 +--
.../commons/numbers/core/ArithmeticUtilsTest.java | 412 +++++++++----------
.../apache/commons/numbers/core/PrecisionTest.java | 449 ++++++++++-----------
.../org/apache/commons/numbers/core/TestUtils.java | 37 +-
.../commons/numbers/field/FieldParametricTest.java | 155 +++----
.../commons/numbers/field/FieldTestData.java | 28 +-
.../apache/commons/numbers/field/FieldsList.java | 13 +-
.../commons/numbers/fraction/BigFraction.java | 10 +-
.../apache/commons/numbers/fraction/Fraction.java | 14 +-
.../commons/numbers/fraction/BigFractionTest.java | 286 ++++++-------
.../numbers/fraction/ContinuedFractionTest.java | 10 +-
.../commons/numbers/fraction/FractionTest.java | 129 +++---
.../apache/commons/numbers/gamma/DigammaTest.java | 36 +-
.../commons/numbers/gamma/ErfDifferenceTest.java | 8 +-
.../org/apache/commons/numbers/gamma/ErfTest.java | 66 +--
.../org/apache/commons/numbers/gamma/ErfcTest.java | 10 +-
.../apache/commons/numbers/gamma/GammaTest.java | 10 +-
.../commons/numbers/gamma/InvGamma1pm1Test.java | 24 +-
.../commons/numbers/gamma/InverseErfTest.java | 18 +-
.../commons/numbers/gamma/InverseErfcTest.java | 18 +-
.../numbers/gamma/LanczosApproximationTest.java | 12 +-
.../apache/commons/numbers/gamma/LogBetaTest.java | 55 ++-
.../commons/numbers/gamma/LogGamma1pTest.java | 18 +-
.../commons/numbers/gamma/LogGammaSumTest.java | 30 +-
.../apache/commons/numbers/gamma/LogGammaTest.java | 12 +-
.../commons/numbers/gamma/RegularizedBetaTest.java | 10 +-
.../numbers/gamma/RegularizedGammaTest.java | 8 +-
.../apache/commons/numbers/gamma/TrigammaTest.java | 12 +-
.../apache/commons/numbers/primes/PrimesTest.java | 50 +--
.../commons/numbers/primes/SmallPrimesTest.java | 51 +--
.../commons/numbers/quaternion/QuaternionTest.java | 335 ++++++++-------
.../commons/numbers/quaternion/SlerpTest.java | 61 +--
.../numbers/rootfinder/BrentSolverTest.java | 101 ++---
pom.xml | 5 +
50 files changed, 1981 insertions(+), 1763 deletions(-)
[commons-numbers] 32/34: Revert inappropriate replacement of
assertFalse with assertNotEquals
Posted by er...@apache.org.
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 fe63782a789e31f2ffb5f93c5696a009f138a85a
Author: Schamschi <he...@gmx.at>
AuthorDate: Sun Jun 16 15:57:20 2019 +0200
Revert inappropriate replacement of assertFalse with assertNotEquals
---
.../src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 dd0cfb7..a424414 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
@@ -167,7 +167,7 @@ public class PlaneAngleTest {
public void testEquals2() {
final PlaneAngle a = PlaneAngle.ofRadians(153768.373486587);
final PlaneAngle b = null;
- Assertions.assertNotEquals(b, a);
+ Assertions.assertFalse(a.equals(b));
}
@Test
public void testEquals3() {
[commons-numbers] 01/34: Merge branch 'master' into
eax/simple-migrate-map
Posted by er...@apache.org.
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 fd3fd3caf395e6cf09800c58197fe1ac9462329c
Merge: 8508164 6bcc6d9
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Thu Jun 6 21:18:06 2019 -0700
Merge branch 'master' into eax/simple-migrate-map
pom.xml | 39 ++++++++++++++++-----------------------
1 file changed, 16 insertions(+), 23 deletions(-)
[commons-numbers] 33/34: Add Generics in test classes of
commons-numbers-field
Posted by er...@apache.org.
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 b1a114f406e90b2432b6e925cfcc2497477ce339
Author: Schamschi <he...@gmx.at>
AuthorDate: Sun Jun 16 17:44:28 2019 +0200
Add Generics in test classes of commons-numbers-field
Improve type safety by imposing equality constraints with type parameters
---
.../commons/numbers/field/FieldParametricTest.java | 118 ++++++++++-----------
.../commons/numbers/field/FieldTestData.java | 28 ++---
.../apache/commons/numbers/field/FieldsList.java | 6 +-
3 files changed, 71 insertions(+), 81 deletions(-)
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 319edf2..4658a01 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
@@ -27,115 +27,105 @@ import java.util.stream.Stream;
*/
public class FieldParametricTest {
- private static Stream<FieldTestData> getList() {
+ private static Stream<FieldTestData<?>> getList() {
return FieldsList.list().stream();
}
@ParameterizedTest
@MethodSource("getList")
- public void testAdditionAssociativity(FieldTestData data) {
- Field field = data.getField();
- Object a = data.getA();
- Object b = data.getB();
- Object c = data.getC();
- final Object r1 = field.add(field.add(a, b), c);
- final Object r2 = field.add(a, field.add(b, c));
+ public <T> void testAdditionAssociativity(FieldTestData<T> data) {
+ Field<T> field = data.getField();
+ T a = data.getA();
+ T b = data.getB();
+ T c = data.getC();
+ final T r1 = field.add(field.add(a, b), c);
+ final T r2 = field.add(a, field.add(b, c));
assertEquals(r1, r2);
}
@ParameterizedTest
@MethodSource("getList")
- public void testAdditionCommutativity(FieldTestData data) {
- Field field = data.getField();
- Object a = data.getA();
- Object b = data.getB();
- Object c = data.getC();
- final Object r1 = field.add(a, b);
- final Object r2 = field.add(b, a);
+ public <T> void testAdditionCommutativity(FieldTestData<T> data) {
+ Field<T> field = data.getField();
+ T a = data.getA();
+ T b = data.getB();
+ final T r1 = field.add(a, b);
+ final T r2 = field.add(b, a);
assertEquals(r1, r2);
}
@ParameterizedTest
@MethodSource("getList")
- public void testAdditiveIdentity(FieldTestData data) {
- Field field = data.getField();
- Object a = data.getA();
- Object b = data.getB();
- Object c = data.getC();
- final Object r1 = field.add(a, field.zero());
- final Object r2 = a;
+ public <T> void testAdditiveIdentity(FieldTestData<T> data) {
+ Field<T> field = data.getField();
+ T a = data.getA();
+ final T r1 = field.add(a, field.zero());
+ final T r2 = a;
assertEquals(r1, r2);
}
@ParameterizedTest
@MethodSource("getList")
- public void testAdditiveInverse(FieldTestData data) {
- Field field = data.getField();
- Object a = data.getA();
- Object b = data.getB();
- Object c = data.getC();
- final Object r1 = field.add(a, field.negate(a));
- final Object r2 = field.zero();
+ public <T> void testAdditiveInverse(FieldTestData<T> data) {
+ Field<T> field = data.getField();
+ T a = data.getA();
+ final T r1 = field.add(a, field.negate(a));
+ final T r2 = field.zero();
assertEquals(r1, r2);
}
@ParameterizedTest
@MethodSource("getList")
- public void testMultiplicationAssociativity(FieldTestData data) {
- Field field = data.getField();
- Object a = data.getA();
- Object b = data.getB();
- Object c = data.getC();
- final Object r1 = field.multiply(field.multiply(a, b), c);
- final Object r2 = field.multiply(a, field.multiply(b, c));
+ public <T> void testMultiplicationAssociativity(FieldTestData<T> data) {
+ Field<T> field = data.getField();
+ T a = data.getA();
+ T b = data.getB();
+ T c = data.getC();
+ final T r1 = field.multiply(field.multiply(a, b), c);
+ final T r2 = field.multiply(a, field.multiply(b, c));
assertEquals(r1, r2);
}
@ParameterizedTest
@MethodSource("getList")
- public void testMultiplicationCommutativity(FieldTestData data) {
- Field field = data.getField();
- Object a = data.getA();
- Object b = data.getB();
- Object c = data.getC();
- final Object r1 = field.multiply(a, b);
- final Object r2 = field.multiply(b, a);
+ public <T> void testMultiplicationCommutativity(FieldTestData<T> data) {
+ Field<T> field = data.getField();
+ T a = data.getA();
+ T b = data.getB();
+ final T r1 = field.multiply(a, b);
+ final T r2 = field.multiply(b, a);
assertEquals(r1, r2);
}
@ParameterizedTest
@MethodSource("getList")
- public void testMultiplicativeIdentity(FieldTestData data) {
- Field field = data.getField();
- Object a = data.getA();
- Object b = data.getB();
- Object c = data.getC();
- final Object r1 = field.multiply(a, field.one());
- final Object r2 = a;
+ public <T> void testMultiplicativeIdentity(FieldTestData<T> data) {
+ Field<T> field = data.getField();
+ T a = data.getA();
+ final T r1 = field.multiply(a, field.one());
+ final T r2 = a;
assertEquals(r1, r2);
}
@ParameterizedTest
@MethodSource("getList")
- public void testMultiplicativeInverse(FieldTestData data) {
- Field field = data.getField();
- Object a = data.getA();
- Object b = data.getB();
- Object c = data.getC();
- final Object r1 = field.multiply(a, field.reciprocal(a));
- final Object r2 = field.one();
+ public <T> void testMultiplicativeInverse(FieldTestData<T> data) {
+ Field<T> field = data.getField();
+ T a = data.getA();
+ final T r1 = field.multiply(a, field.reciprocal(a));
+ final T r2 = field.one();
assertEquals(r1, r2);
}
@ParameterizedTest
@MethodSource("getList")
- public void testDistributivity(FieldTestData data) {
- Field field = data.getField();
- Object a = data.getA();
- Object b = data.getB();
- Object c = data.getC();
- final Object r1 = field.multiply(a, field.add(b, c));
- final Object r2 = field.add(field.multiply(a, b), field.multiply(a, c));
+ public <T> void testDistributivity(FieldTestData<T> data) {
+ Field<T> field = data.getField();
+ T a = data.getA();
+ T b = data.getB();
+ T c = data.getC();
+ final T r1 = field.multiply(a, field.add(b, c));
+ final T r2 = field.add(field.multiply(a, b), field.multiply(a, c));
assertEquals(r1, r2);
}
diff --git a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldTestData.java b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldTestData.java
index 82dc1a0..0a2b1cd 100644
--- a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldTestData.java
+++ b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldTestData.java
@@ -21,35 +21,35 @@ import java.util.Arrays;
/**
* Data store for {@link FieldParametricTest}.
*/
-class FieldTestData {
- private final Field<?> field;
- private final Object a;
- private final Object b;
- private final Object c;
-
- public FieldTestData(Field<?> field,
- Object a,
- Object b,
- Object c) {
+class FieldTestData<T> {
+ private final Field<T> field;
+ private final T a;
+ private final T b;
+ private final T c;
+
+ public FieldTestData(Field<T> field,
+ T a,
+ T b,
+ T c) {
this.field = field;
this.a = a;
this.b = b;
this.c = c;
}
- public Field<?> getField() {
+ public Field<T> getField() {
return field;
}
- public Object getA() {
+ public T getA() {
return a;
}
- public Object getB() {
+ public T getB() {
return b;
}
- public Object getC() {
+ public T getC() {
return c;
}
diff --git a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
index 396c83f..76a15cd 100644
--- a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
+++ b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
@@ -28,7 +28,7 @@ import org.apache.commons.numbers.fraction.Fraction;
*/
final class FieldsList {
/** List of all fields implemented in the library. */
- private static final List<FieldTestData> LIST =
+ private static final List<FieldTestData<?>> LIST =
new ArrayList<>();
static {
@@ -62,7 +62,7 @@ final class FieldsList {
T a,
T b,
T c) {
- LIST.add(new FieldTestData(field, a, b, c));
+ LIST.add(new FieldTestData<>(field, a, b, c));
}
/**
@@ -71,7 +71,7 @@ final class FieldsList {
*
* @return the list of all fields.
*/
- static List<FieldTestData> list() {
+ static List<FieldTestData<?>> list() {
return Collections.unmodifiableList(LIST);
}
}
[commons-numbers] 07/34: re-add one and zero
Posted by er...@apache.org.
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 a26ba7a61d13ac1ccbf6e19d912f2c1793d26dbe
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Fri Jun 7 19:12:21 2019 -0700
re-add one and zero
---
.../java/org/apache/commons/numbers/fraction/Fraction.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
index 3fbf96f..74beb3b 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
@@ -625,6 +625,18 @@ public class Fraction
return str;
}
+ /** {@inheritDoc} */
+ @Override
+ public Fraction zero() {
+ return ZERO;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Fraction one() {
+ return ONE;
+ }
+
/**
* Parses a string that would be produced by {@link #toString()}
* and instantiates the corresponding object.
[commons-numbers] 06/34: Merge remote-tracking branch
'origin/master' into eax/simple-migrate-map
Posted by er...@apache.org.
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 62e6c9d6c371a7fdf4a8658187974b91a5d7f7f1
Merge: 888e00e b4356bd
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Fri Jun 7 19:05:43 2019 -0700
Merge remote-tracking branch 'origin/master' into eax/simple-migrate-map
.../apache/commons/numbers/arrays/LinearCombinationTest.java | 12 ++++++------
.../src/main/java/org/apache/commons/numbers/field/FP64.java | 12 +++++++++++-
.../java/org/apache/commons/numbers/field/FP64Field.java | 4 ++--
.../java/org/apache/commons/numbers/field/FieldsList.java | 12 ++++++------
.../java/org/apache/commons/numbers/fraction/Fraction.java | 5 ++++-
5 files changed, 29 insertions(+), 16 deletions(-)
[commons-numbers] 29/34: Migrate commons-numbers-fraction to JUnit
5: class FractionTest
Posted by er...@apache.org.
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 44461dd6b4c0fbf7c38d80b40399b8b5b2ac1c4c
Author: Schamschi <he...@gmx.at>
AuthorDate: Fri Jun 14 15:08:57 2019 +0200
Migrate commons-numbers-fraction to JUnit 5: class FractionTest
---
.../commons/numbers/fraction/FractionTest.java | 129 +++++++++++----------
1 file changed, 66 insertions(+), 63 deletions(-)
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 f2bcc0a..e43462b 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
@@ -17,8 +17,9 @@
package org.apache.commons.numbers.fraction;
import org.apache.commons.numbers.core.TestUtils;
-import org.junit.Assert;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
@@ -26,8 +27,8 @@ import org.junit.Test;
public class FractionTest {
private void assertFraction(int expectedNumerator, int expectedDenominator, Fraction actual) {
- Assert.assertEquals(expectedNumerator, actual.getNumerator());
- Assert.assertEquals(expectedDenominator, actual.getDenominator());
+ Assertions.assertEquals(expectedNumerator, actual.getNumerator());
+ Assertions.assertEquals(expectedDenominator, actual.getDenominator());
}
@Test
@@ -45,13 +46,13 @@ public class FractionTest {
// overflow
try {
Fraction.of(Integer.MIN_VALUE, -1);
- Assert.fail();
+ Assertions.fail();
} catch (ArithmeticException ex) {
// success
}
try {
Fraction.of(1, Integer.MIN_VALUE);
- Assert.fail();
+ Assertions.fail();
} catch (ArithmeticException ex) {
// success
}
@@ -61,10 +62,12 @@ public class FractionTest {
assertFraction(15, 1, Fraction.from(15.0000000000001));
}
- @Test(expected=ArithmeticException.class)
+ @Test
public void testGoldenRatio() {
// the golden ratio is notoriously a difficult number for continuous fraction
- Fraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25);
+ Assertions.assertThrows(ArithmeticException.class,
+ () -> Fraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
+ );
}
// MATH-179
@@ -142,7 +145,7 @@ public class FractionTest {
@SuppressWarnings("unused")
Fraction f = Fraction.from(a, 1.0e-12, 1000);
//System.out.println(f.getNumerator() + "/" + f.getDenominator());
- Assert.fail("an exception should have been thrown");
+ Assertions.fail("an exception should have been thrown");
} catch (ArithmeticException ignored) {
// expected behavior
}
@@ -167,10 +170,10 @@ public class FractionTest {
Fraction second = Fraction.of(1, 3);
Fraction third = Fraction.of(1, 2);
- Assert.assertEquals(0, first.compareTo(first));
- Assert.assertEquals(0, first.compareTo(third));
- Assert.assertEquals(1, first.compareTo(second));
- Assert.assertEquals(-1, second.compareTo(first));
+ Assertions.assertEquals(0, first.compareTo(first));
+ Assertions.assertEquals(0, first.compareTo(third));
+ Assertions.assertEquals(1, first.compareTo(second));
+ Assertions.assertEquals(-1, second.compareTo(first));
}
{
@@ -179,9 +182,9 @@ public class FractionTest {
// the second one is approximately PI + 1.936e-17
Fraction pi1 = Fraction.of(1068966896, 340262731);
Fraction pi2 = Fraction.of( 411557987, 131002976);
- Assert.assertEquals(-1, pi1.compareTo(pi2));
- Assert.assertEquals( 1, pi2.compareTo(pi1));
- Assert.assertEquals(0.0, pi1.doubleValue() - pi2.doubleValue(), 1.0e-20);
+ Assertions.assertEquals(-1, pi1.compareTo(pi2));
+ Assertions.assertEquals( 1, pi2.compareTo(pi1));
+ Assertions.assertEquals(0.0, pi1.doubleValue() - pi2.doubleValue(), 1.0e-20);
}
}
@@ -190,8 +193,8 @@ public class FractionTest {
Fraction first = Fraction.of(1, 2);
Fraction second = Fraction.of(1, 3);
- Assert.assertEquals(0.5, first.doubleValue(), 0.0);
- Assert.assertEquals(1.0 / 3.0, second.doubleValue(), 0.0);
+ Assertions.assertEquals(0.5, first.doubleValue(), 0.0);
+ Assertions.assertEquals(1.0 / 3.0, second.doubleValue(), 0.0);
}
@Test
@@ -199,8 +202,8 @@ public class FractionTest {
Fraction first = Fraction.of(1, 2);
Fraction second = Fraction.of(1, 3);
- Assert.assertEquals(0.5f, first.floatValue(), 0.0f);
- Assert.assertEquals((float)(1.0 / 3.0), second.floatValue(), 0.0f);
+ Assertions.assertEquals(0.5f, first.floatValue(), 0.0f);
+ Assertions.assertEquals((float)(1.0 / 3.0), second.floatValue(), 0.0f);
}
@Test
@@ -208,8 +211,8 @@ public class FractionTest {
Fraction first = Fraction.of(1, 2);
Fraction second = Fraction.of(3, 2);
- Assert.assertEquals(0, first.intValue());
- Assert.assertEquals(1, second.intValue());
+ Assertions.assertEquals(0, first.intValue());
+ Assertions.assertEquals(1, second.intValue());
}
@Test
@@ -217,8 +220,8 @@ public class FractionTest {
Fraction first = Fraction.of(1, 2);
Fraction second = Fraction.of(3, 2);
- Assert.assertEquals(0L, first.longValue());
- Assert.assertEquals(1L, second.longValue());
+ Assertions.assertEquals(0L, first.longValue());
+ Assertions.assertEquals(1L, second.longValue());
}
@Test
@@ -249,13 +252,13 @@ public class FractionTest {
{
final Fraction a = Fraction.of(Integer.MAX_VALUE, 2);
final Fraction b = a.multiply(2);
- Assert.assertTrue(b.equals(Fraction.of(Integer.MAX_VALUE)));
+ Assertions.assertTrue(b.equals(Fraction.of(Integer.MAX_VALUE)));
}
{
final Fraction c = Fraction.of(2, Integer.MAX_VALUE);
final Fraction d = c.divide(2);
- Assert.assertTrue(d.equals(Fraction.of(1, Integer.MAX_VALUE)));
+ Assertions.assertTrue(d.equals(Fraction.of(1, Integer.MAX_VALUE)));
}
}
@@ -283,7 +286,7 @@ public class FractionTest {
Fraction f = Fraction.of(0, 3);
try {
f = f.reciprocal();
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ignored) {}
}
@@ -320,7 +323,7 @@ public class FractionTest {
Fraction f = Fraction.of(Integer.MIN_VALUE, 1);
try {
f = f.negate();
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
}
}
@@ -358,7 +361,7 @@ public class FractionTest {
try {
f.add(null);
- Assert.fail("expecting NullArgumentException");
+ Assertions.fail("expecting NullArgumentException");
} catch (NullPointerException ex) {}
}
@@ -386,7 +389,7 @@ public class FractionTest {
try {
f = f.add(Fraction.ONE); // should overflow
- Assert.fail("expecting ArithmeticException but got: " + f.toString());
+ Assertions.fail("expecting ArithmeticException but got: " + f.toString());
} catch (ArithmeticException ex) {}
}
@@ -396,7 +399,7 @@ public class FractionTest {
Fraction f2 = Fraction.of(-1, 5);
try {
Fraction f = f1.add(f2); // should overflow
- Assert.fail("expecting ArithmeticException but got: " + f.toString());
+ Assertions.fail("expecting ArithmeticException but got: " + f.toString());
} catch (ArithmeticException ex) {}
}
@@ -404,7 +407,7 @@ public class FractionTest {
Fraction f = Fraction.of(-Integer.MAX_VALUE, 1);
try {
f.add(f);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
}
@@ -413,7 +416,7 @@ public class FractionTest {
Fraction f2 = Fraction.of(2, 59049);
try {
Fraction f = f1.add(f2); // should overflow
- Assert.fail("expecting ArithmeticException but got: " + f.toString());
+ Assertions.fail("expecting ArithmeticException but got: " + f.toString());
} catch (ArithmeticException ex) {}
}
}
@@ -435,7 +438,7 @@ public class FractionTest {
Fraction f2 = Fraction.ZERO;
try {
f1.divide(f2);
- Assert.fail("expecting FractionException");
+ Assertions.fail("expecting FractionException");
} catch (FractionException ex) {}
}
@@ -443,7 +446,7 @@ public class FractionTest {
Fraction f1 = Fraction.of(0, 5);
Fraction f2 = Fraction.of(2, 7);
Fraction f = f1.divide(f2);
- Assert.assertSame(Fraction.ZERO, f);
+ Assertions.assertSame(Fraction.ZERO, f);
}
{
@@ -467,7 +470,7 @@ public class FractionTest {
try {
f.divide(null);
- Assert.fail("NullArgumentException");
+ Assertions.fail("NullArgumentException");
} catch (NullPointerException ex) {}
}
@@ -475,7 +478,7 @@ public class FractionTest {
Fraction f1 = Fraction.of(1, Integer.MAX_VALUE);
try {
f1.divide(f1.reciprocal()); // should overflow
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
}
@@ -483,7 +486,7 @@ public class FractionTest {
Fraction f1 = Fraction.of(1, -Integer.MAX_VALUE);
try {
f1.divide(f1.reciprocal()); // should overflow
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
}
@@ -514,7 +517,7 @@ public class FractionTest {
try {
f.multiply(null);
- Assert.fail("expecting NullArgumentException");
+ Assertions.fail("expecting NullArgumentException");
} catch (NullPointerException ex) {}
}
@@ -567,7 +570,7 @@ public class FractionTest {
Fraction f = Fraction.of(1, 1);
try {
f.subtract(null);
- Assert.fail("expecting NullArgumentException");
+ Assertions.fail("expecting NullArgumentException");
} catch (NullPointerException ex) {}
}
@@ -605,7 +608,7 @@ public class FractionTest {
Fraction f2 = Fraction.of(1, Integer.MAX_VALUE - 1);
try {
f1.subtract(f2);
- Assert.fail("expecting ArithmeticException"); //should overflow
+ Assertions.fail("expecting ArithmeticException"); //should overflow
} catch (ArithmeticException ex) {}
}
@@ -615,7 +618,7 @@ public class FractionTest {
Fraction f2 = Fraction.of(1, 5);
try {
Fraction f = f1.subtract(f2); // should overflow
- Assert.fail("expecting ArithmeticException but got: " + f.toString());
+ Assertions.fail("expecting ArithmeticException but got: " + f.toString());
} catch (ArithmeticException ex) {}
}
@@ -623,7 +626,7 @@ public class FractionTest {
Fraction f = Fraction.of(Integer.MIN_VALUE, 1);
try {
f.subtract(Fraction.ONE);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
}
@@ -631,7 +634,7 @@ public class FractionTest {
Fraction f = Fraction.of(Integer.MAX_VALUE, 1);
try {
f.subtract(Fraction.ONE.negate());
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
}
@@ -640,7 +643,7 @@ public class FractionTest {
Fraction f2 = Fraction.of(2, 59049);
try {
Fraction f = f1.subtract(f2); // should overflow
- Assert.fail("expecting ArithmeticException but got: " + f.toString());
+ Assertions.fail("expecting ArithmeticException but got: " + f.toString());
} catch (ArithmeticException ex) {}
}
}
@@ -649,32 +652,32 @@ public class FractionTest {
public void testEqualsAndHashCode() {
Fraction zero = Fraction.of(0,1);
Fraction nullFraction = null;
- Assert.assertTrue( zero.equals(zero));
- Assert.assertFalse(zero.equals(nullFraction));
- Assert.assertFalse(zero.equals(Double.valueOf(0)));
+ Assertions.assertTrue( zero.equals(zero));
+ Assertions.assertFalse(zero.equals(nullFraction));
+ Assertions.assertFalse(zero.equals(Double.valueOf(0)));
Fraction zero2 = Fraction.of(0,2);
- Assert.assertTrue(zero.equals(zero2));
- Assert.assertEquals(zero.hashCode(), zero2.hashCode());
+ Assertions.assertTrue(zero.equals(zero2));
+ Assertions.assertEquals(zero.hashCode(), zero2.hashCode());
Fraction one = Fraction.of(1,1);
- Assert.assertFalse((one.equals(zero) ||zero.equals(one)));
+ Assertions.assertFalse((one.equals(zero) ||zero.equals(one)));
}
@Test
public void testGetReducedFraction() {
Fraction threeFourths = Fraction.of(3, 4);
- Assert.assertTrue(threeFourths.equals(Fraction.getReducedFraction(6, 8)));
- Assert.assertTrue(Fraction.ZERO.equals(Fraction.getReducedFraction(0, -1)));
+ Assertions.assertTrue(threeFourths.equals(Fraction.getReducedFraction(6, 8)));
+ Assertions.assertTrue(Fraction.ZERO.equals(Fraction.getReducedFraction(0, -1)));
try {
Fraction.getReducedFraction(1, 0);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ignored) {
// expected
}
- Assert.assertEquals(
+ Assertions.assertEquals(
-1,
Fraction.getReducedFraction(2, Integer.MIN_VALUE).getNumerator()
);
- Assert.assertEquals(
+ Assertions.assertEquals(
-1,
Fraction.getReducedFraction(1, -1).getNumerator()
);
@@ -682,11 +685,11 @@ public class FractionTest {
@Test
public void testToString() {
- Assert.assertEquals("0", Fraction.of(0, 3).toString());
- Assert.assertEquals("3", Fraction.of(6, 2).toString());
- Assert.assertEquals("2 / 3", Fraction.of(18, 27).toString());
- Assert.assertEquals("-10 / 11", Fraction.of(-10, 11).toString());
- Assert.assertEquals("-10 / 11", Fraction.of(10, -11).toString());
+ Assertions.assertEquals("0", Fraction.of(0, 3).toString());
+ Assertions.assertEquals("3", Fraction.of(6, 2).toString());
+ Assertions.assertEquals("2 / 3", Fraction.of(18, 27).toString());
+ Assertions.assertEquals("-10 / 11", Fraction.of(-10, 11).toString());
+ Assertions.assertEquals("-10 / 11", Fraction.of(10, -11).toString());
}
@Test
@@ -697,7 +700,7 @@ public class FractionTest {
Fraction.of(-5, 2)
};
for (Fraction fraction : fractions) {
- Assert.assertEquals(fraction, TestUtils.serializeAndRecover(fraction));
+ Assertions.assertEquals(fraction, TestUtils.serializeAndRecover(fraction));
}
}
@@ -714,7 +717,7 @@ public class FractionTest {
};
int inc = 0;
for (Fraction fraction: fractions) {
- Assert.assertEquals(fraction,
+ Assertions.assertEquals(fraction,
Fraction.parse(validExpressions[inc]));
inc++;
}
[commons-numbers] 02/34: Migrate commons-numbers-gamma to JUnit 5:
all remaining classes
Posted by er...@apache.org.
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 560f15cfac37a22ee5a0ed7af1bb9c48c552427b
Author: Schamschi <he...@gmx.at>
AuthorDate: Fri Jun 7 10:45:44 2019 +0200
Migrate commons-numbers-gamma to JUnit 5: all remaining classes
Migrate the following classes:
ErfTest
GammaTest
InverseErfcTest
InverseErfTest
InvGamma1pm1Test
LanczosApproximationTest
LogBetaTest
LogGamma1pTest
LogGammaSumTest
LogGammaTest
RegularizedBetaTest
RegularizedGammaTest
TrigammaTest
---
.../org/apache/commons/numbers/gamma/ErfTest.java | 64 +++++++++++-----------
.../apache/commons/numbers/gamma/GammaTest.java | 8 +--
.../commons/numbers/gamma/InvGamma1pm1Test.java | 7 +--
.../commons/numbers/gamma/InverseErfTest.java | 16 +++---
.../commons/numbers/gamma/InverseErfcTest.java | 16 +++---
.../numbers/gamma/LanczosApproximationTest.java | 10 ++--
.../apache/commons/numbers/gamma/LogBetaTest.java | 30 +++++-----
.../commons/numbers/gamma/LogGamma1pTest.java | 7 +--
.../commons/numbers/gamma/LogGammaSumTest.java | 11 ++--
.../apache/commons/numbers/gamma/LogGammaTest.java | 10 ++--
.../commons/numbers/gamma/RegularizedBetaTest.java | 8 +--
.../numbers/gamma/RegularizedGammaTest.java | 6 +-
.../apache/commons/numbers/gamma/TrigammaTest.java | 10 ++--
13 files changed, 100 insertions(+), 103 deletions(-)
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 ddddbf0..461d128 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
@@ -16,7 +16,7 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -27,8 +27,8 @@ public class ErfTest {
public void testErf0() {
double actual = Erf.value(0);
double expected = 0;
- Assert.assertEquals(expected, actual, 1e-15);
- Assert.assertEquals(1 - expected, Erfc.value(0), 1e-15);
+ Assertions.assertEquals(expected, actual, 1e-15);
+ Assertions.assertEquals(1 - expected, Erfc.value(0), 1e-15);
}
@Test
@@ -36,13 +36,13 @@ public class ErfTest {
double x = 1.960 / Math.sqrt(2);
double actual = Erf.value(x);
double expected = 0.95;
- Assert.assertEquals(expected, actual, 1e-5);
- Assert.assertEquals(1 - actual, Erfc.value(x), 1e-15);
+ Assertions.assertEquals(expected, actual, 1e-5);
+ Assertions.assertEquals(1 - actual, Erfc.value(x), 1e-15);
actual = Erf.value(-x);
expected = -expected;
- Assert.assertEquals(expected, actual, 1e-5);
- Assert.assertEquals(1 - actual, Erfc.value(-x), 1e-15);
+ Assertions.assertEquals(expected, actual, 1e-5);
+ Assertions.assertEquals(1 - actual, Erfc.value(-x), 1e-15);
}
@Test
@@ -50,13 +50,13 @@ public class ErfTest {
double x = 2.576 / Math.sqrt(2);
double actual = Erf.value(x);
double expected = 0.99;
- Assert.assertEquals(expected, actual, 1e-5);
- Assert.assertEquals(1 - actual, Erfc.value(x), 1e-15);
+ Assertions.assertEquals(expected, actual, 1e-5);
+ Assertions.assertEquals(1 - actual, Erfc.value(x), 1e-15);
actual = Erf.value(-x);
expected = -expected;
- Assert.assertEquals(expected, actual, 1e-5);
- Assert.assertEquals(1 - actual, Erfc.value(-x), 1e-15);
+ Assertions.assertEquals(expected, actual, 1e-5);
+ Assertions.assertEquals(1 - actual, Erfc.value(-x), 1e-15);
}
@Test
@@ -64,13 +64,13 @@ public class ErfTest {
double x = 2.807 / Math.sqrt(2);
double actual = Erf.value(x);
double expected = 0.995;
- Assert.assertEquals(expected, actual, 1e-5);
- Assert.assertEquals(1 - actual, Erfc.value(x), 1e-15);
+ Assertions.assertEquals(expected, actual, 1e-5);
+ Assertions.assertEquals(1 - actual, Erfc.value(x), 1e-15);
actual = Erf.value(-x);
expected = -expected;
- Assert.assertEquals(expected, actual, 1e-5);
- Assert.assertEquals(1 - actual, Erfc.value(-x), 1e-15);
+ Assertions.assertEquals(expected, actual, 1e-5);
+ Assertions.assertEquals(1 - actual, Erfc.value(-x), 1e-15);
}
@Test
@@ -78,13 +78,13 @@ public class ErfTest {
double x = 3.291 / Math.sqrt(2);
double actual = Erf.value(x);
double expected = 0.999;
- Assert.assertEquals(expected, actual, 1e-5);
- Assert.assertEquals(1 - expected, Erfc.value(x), 1e-5);
+ Assertions.assertEquals(expected, actual, 1e-5);
+ Assertions.assertEquals(1 - expected, Erfc.value(x), 1e-5);
actual = Erf.value(-x);
expected = -expected;
- Assert.assertEquals(expected, actual, 1e-5);
- Assert.assertEquals(1 - expected, Erfc.value(-x), 1e-5);
+ Assertions.assertEquals(expected, actual, 1e-5);
+ Assertions.assertEquals(1 - expected, Erfc.value(-x), 1e-5);
}
/**
@@ -94,22 +94,22 @@ public class ErfTest {
public void testLargeValues() {
for (int i = 1; i < 200; i *= 10) {
double result = Erf.value(i);
- Assert.assertFalse(Double.isNaN(result));
- Assert.assertTrue(result > 0 && result <= 1);
+ Assertions.assertFalse(Double.isNaN(result));
+ Assertions.assertTrue(result > 0 && result <= 1);
result = Erf.value(-i);
- Assert.assertFalse(Double.isNaN(result));
- Assert.assertTrue(result >= -1 && result < 0);
+ Assertions.assertFalse(Double.isNaN(result));
+ Assertions.assertTrue(result >= -1 && result < 0);
result = Erfc.value(i);
- Assert.assertFalse(Double.isNaN(result));
- Assert.assertTrue(result >= 0 && result < 1);
+ Assertions.assertFalse(Double.isNaN(result));
+ Assertions.assertTrue(result >= 0 && result < 1);
result = Erfc.value(-i);
- Assert.assertFalse(Double.isNaN(result));
- Assert.assertTrue(result >= 1 && result <= 2);
+ Assertions.assertFalse(Double.isNaN(result));
+ Assertions.assertTrue(result >= 1 && result <= 2);
}
- Assert.assertEquals(-1, Erf.value(Double.NEGATIVE_INFINITY), 0);
- Assert.assertEquals(1, Erf.value(Double.POSITIVE_INFINITY), 0);
- Assert.assertEquals(2, Erfc.value(Double.NEGATIVE_INFINITY), 0);
- Assert.assertEquals(0, Erfc.value(Double.POSITIVE_INFINITY), 0);
+ 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);
}
/**
@@ -133,7 +133,7 @@ public class ErfTest {
double x = -10;
for (int i = 0; i < 41; i++) {
- Assert.assertEquals(gnuValues[i], Erf.value(x), tol);
+ Assertions.assertEquals(gnuValues[i], Erf.value(x), tol);
x += 0.5d;
}
}
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 4fe03fd..832caf9 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
@@ -16,7 +16,7 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -527,14 +527,14 @@ public class GammaTest {
ulps = 500;
}
final double tol = ulps * Math.ulp(expected);
- Assert.assertEquals(Double.toString(x), expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol, Double.toString(x));
}
}
@Test
public void testGammaNegativeInteger() {
for (int i = -100; i <= 0; i++) {
- Assert.assertTrue(Integer.toString(i), Double.isNaN(Gamma.value(i)));
+ Assertions.assertTrue(Double.isNaN(Gamma.value(i)), Integer.toString(i));
}
}
@@ -546,7 +546,7 @@ public class GammaTest {
double previousGamma = Gamma.value(-18.5);
for (double x = -19.5; x > -25; x -= 1.0) {
double gamma = Gamma.value(x);
- Assert.assertEquals( (int) Math.signum(previousGamma),
+ Assertions.assertEquals( (int) Math.signum(previousGamma),
- (int) Math.signum(gamma));
previousGamma = gamma;
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 99e955c..328c30b 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
@@ -16,7 +16,6 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -74,11 +73,11 @@ public class InvGamma1pm1Test {
final double expected = ref[1];
final double actual = InvGamma1pm1.value(x);
final double tol = ulps * Math.ulp(expected);
- Assert.assertEquals(Double.toString(x), expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol, Double.toString(x));
}
}
- @Test()
+ @Test
public void testInvGamma1pm1Precondition1()
{
Assertions.assertThrows(GammaException.class,
@@ -86,7 +85,7 @@ public class InvGamma1pm1Test {
);
}
- @Test()
+ @Test
public void testInvGamma1pm1Precondition2()
{
Assertions.assertThrows(GammaException.class,
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 8b313ef..e988972 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
@@ -16,7 +16,7 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -25,16 +25,16 @@ import org.junit.jupiter.api.Test;
public class InverseErfTest {
@Test
public void testErfInvNaN() {
- Assert.assertTrue(Double.isNaN(InverseErf.value(-1.001)));
- Assert.assertTrue(Double.isNaN(InverseErf.value(+1.001)));
+ Assertions.assertTrue(Double.isNaN(InverseErf.value(-1.001)));
+ Assertions.assertTrue(Double.isNaN(InverseErf.value(+1.001)));
}
@Test
public void testErfInvInfinite() {
- Assert.assertTrue(Double.isInfinite(InverseErf.value(-1)));
- Assert.assertTrue(InverseErf.value(-1) < 0);
- Assert.assertTrue(Double.isInfinite(InverseErf.value(+1)));
- Assert.assertTrue(InverseErf.value(+1) > 0);
+ Assertions.assertTrue(Double.isInfinite(InverseErf.value(-1)));
+ Assertions.assertTrue(InverseErf.value(-1) < 0);
+ Assertions.assertTrue(Double.isInfinite(InverseErf.value(+1)));
+ Assertions.assertTrue(InverseErf.value(+1) > 0);
}
@Test
@@ -42,7 +42,7 @@ public class InverseErfTest {
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);
- Assert.assertEquals(x, InverseErf.value(y), 1.0e-15 / dydx);
+ Assertions.assertEquals(x, InverseErf.value(y), 1.0e-15 / dydx);
}
}
}
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 6fa87b1..991869a 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
@@ -16,7 +16,7 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -25,16 +25,16 @@ import org.junit.jupiter.api.Test;
public class InverseErfcTest {
@Test
public void testErfcInvNaN() {
- Assert.assertTrue(Double.isNaN(InverseErfc.value(-0.001)));
- Assert.assertTrue(Double.isNaN(InverseErfc.value(+2.001)));
+ Assertions.assertTrue(Double.isNaN(InverseErfc.value(-0.001)));
+ Assertions.assertTrue(Double.isNaN(InverseErfc.value(+2.001)));
}
@Test
public void testErfcInvInfinite() {
- Assert.assertTrue(Double.isInfinite(InverseErfc.value(-0)));
- Assert.assertTrue(InverseErfc.value( 0) > 0);
- Assert.assertTrue(Double.isInfinite(InverseErfc.value(+2)));
- Assert.assertTrue(InverseErfc.value(+2) < 0);
+ Assertions.assertTrue(Double.isInfinite(InverseErfc.value(-0)));
+ Assertions.assertTrue(InverseErfc.value( 0) > 0);
+ Assertions.assertTrue(Double.isInfinite(InverseErfc.value(+2)));
+ Assertions.assertTrue(InverseErfc.value(+2) < 0);
}
@Test
@@ -42,7 +42,7 @@ public class InverseErfcTest {
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);
- Assert.assertEquals(x, InverseErfc.value(y), 1.0e-15 / dydxAbs);
+ Assertions.assertEquals(x, InverseErfc.value(y), 1.0e-15 / dydxAbs);
}
}
}
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 ba5b22a..b9680fe 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
@@ -16,7 +16,7 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -25,15 +25,15 @@ import org.junit.jupiter.api.Test;
public class LanczosApproximationTest {
@Test
public void testG() {
- Assert.assertEquals(607d / 128d, LanczosApproximation.g(), 0d);
+ Assertions.assertEquals(607d / 128d, LanczosApproximation.g(), 0d);
}
@Test
public void testSomeValues() {
// Given that few values are checked, this test would only serve
// as early warning of unexpected changes to the current code.
- Assert.assertEquals(29.020294557631818d, LanczosApproximation.value(0.1d), 0d);
- Assert.assertEquals(13.14778027539684d, LanczosApproximation.value(1.0d), 0d);
- Assert.assertEquals(7.897828855157814d, LanczosApproximation.value(2.0d), 0d);
+ 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);
}
}
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 1633529..f6cc3bc 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
@@ -18,7 +18,7 @@ package org.apache.commons.numbers.gamma;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import org.junit.Assert;
+
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -297,7 +297,7 @@ public class LogBetaTest {
final double tol = ulps * Math.ulp(expected);
final StringBuilder builder = new StringBuilder();
builder.append(a).append(", ").append(b);
- Assert.assertEquals(builder.toString(), expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol, builder.toString());
}
}
@@ -340,7 +340,7 @@ public class LogBetaTest {
double a,
double b) {
double actual = LogBeta.value(a, b);
- Assert.assertEquals(expected, actual, 1e-15);
+ Assertions.assertEquals(expected, actual, 1e-15);
}
private static final double[][] LOG_GAMMA_MINUS_LOG_GAMMA_SUM_REF = {
@@ -478,14 +478,14 @@ public class LogBetaTest {
m.setAccessible(true);
return ((Double) m.invoke(null, a, b)).doubleValue();
} catch (NoSuchMethodException e) {
- Assert.fail(e.getMessage());
+ Assertions.fail(e.getMessage());
} catch (IllegalAccessException e) {
- Assert.fail(e.getMessage());
+ Assertions.fail(e.getMessage());
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof GammaException) {
throw (GammaException) e.getTargetException();
} else {
- Assert.fail(e.getTargetException().getMessage());
+ Assertions.fail(e.getTargetException().getMessage());
}
}
return Double.NaN;
@@ -503,11 +503,11 @@ public class LogBetaTest {
final double tol = ulps * Math.ulp(expected);
final StringBuilder builder = new StringBuilder();
builder.append(a).append(", ").append(b);
- Assert.assertEquals(builder.toString(), expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol, builder.toString());
}
}
- @Test()
+ @Test
public void testLogGammaMinusLogGammaSumPrecondition1()
{
Assertions.assertThrows(IllegalArgumentException.class,
@@ -515,7 +515,7 @@ public class LogBetaTest {
);
}
- @Test()
+ @Test
public void testLogGammaMinusLogGammaSumPrecondition2() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> logGammaMinusLogGammaSum(1, 7)
@@ -658,14 +658,14 @@ public class LogBetaTest {
m.setAccessible(true);
return ((Double) m.invoke(null, a, b)).doubleValue();
} catch (NoSuchMethodException e) {
- Assert.fail(e.getMessage());
+ Assertions.fail(e.getMessage());
} catch (final IllegalAccessException e) {
- Assert.fail(e.getMessage());
+ Assertions.fail(e.getMessage());
} catch (final InvocationTargetException e) {
if (e.getTargetException() instanceof GammaException) {
throw (GammaException) e.getTargetException();
} else {
- Assert.fail(e.getTargetException().getMessage());
+ Assertions.fail(e.getTargetException().getMessage());
}
}
@@ -684,18 +684,18 @@ public class LogBetaTest {
final double tol = ulps * Math.ulp(expected);
final StringBuilder builder = new StringBuilder();
builder.append(a).append(", ").append(b);
- Assert.assertEquals(builder.toString(), expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol, builder.toString());
}
}
- @Test()
+ @Test
public void testSumDeltaMinusDeltaSumPrecondition1() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> sumDeltaMinusDeltaSum(9, 10)
);
}
- @Test()
+ @Test
public void testSumDeltaMinusDeltaSumPrecondition2()
{
Assertions.assertThrows(IllegalArgumentException.class,
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 3b9f56b..5aead6d 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
@@ -16,7 +16,6 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -53,18 +52,18 @@ public class LogGamma1pTest {
final double expected = ref[1];
final double actual = LogGamma1p.value(x);
final double tol = ulps * Math.ulp(expected);
- Assert.assertEquals(Double.toString(x), expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol, Double.toString(x));
}
}
- @Test()
+ @Test
public void testLogGamma1pPrecondition1() {
Assertions.assertThrows(GammaException.class,
() -> LogGamma1p.value(-0.51)
);
}
- @Test()
+ @Test
public 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 9eed629..0e6eb9d 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
@@ -16,7 +16,6 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -141,32 +140,32 @@ public class LogGammaSumTest {
final double tol = ulps * Math.ulp(expected);
final StringBuilder builder = new StringBuilder();
builder.append(a).append(", ").append(b);
- Assert.assertEquals(builder.toString(), expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol, builder.toString());
}
}
- @Test()
+ @Test
public void testLogGammaSumPrecondition1() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> LogGammaSum.value(0, 1)
);
}
- @Test()
+ @Test
public void testLogGammaSumPrecondition2() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> LogGammaSum.value(3, 1)
);
}
- @Test()
+ @Test
public void testLogGammaSumPrecondition3() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> LogGammaSum.value(1, 0)
);
}
- @Test()
+ @Test
public 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 e36741d..be6496e 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
@@ -16,7 +16,7 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -209,22 +209,22 @@ public class LogGammaTest {
} else {
tol = ulps * Math.ulp(expected);
}
- Assert.assertEquals(Double.toString(x), expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol, Double.toString(x));
}
}
@Test
public void testLogGammaPrecondition1() {
- Assert.assertTrue(Double.isNaN(LogGamma.value(0.0)));
+ Assertions.assertTrue(Double.isNaN(LogGamma.value(0.0)));
}
@Test
public void testLogGammaPrecondition2() {
- Assert.assertTrue(Double.isNaN(LogGamma.value(-1.0)));
+ Assertions.assertTrue(Double.isNaN(LogGamma.value(-1.0)));
}
private void testLogGamma(double expected, double x) {
double actual = LogGamma.value(x);
- Assert.assertEquals(expected, actual, 1e-15);
+ Assertions.assertEquals(expected, actual, 1e-15);
}
}
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 7b49d97..96c0813 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
@@ -16,7 +16,7 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -77,7 +77,7 @@ public class RegularizedBetaTest {
public void testRegularizedBetaTinyArgument() {
double actual = RegularizedBeta.value(1e-17, 1.0, 1e12);
// This value is from R: pbeta(1e-17,1,1e12)
- Assert.assertEquals(9.999950000166648e-6, actual, 1e-16);
+ Assertions.assertEquals(9.999950000166648e-6, actual, 1e-16);
}
@Test
@@ -89,7 +89,7 @@ public class RegularizedBetaTest {
try {
RegularizedBeta.value(x, a, b, 1e-14, 10000);
} catch (StackOverflowError error) {
- Assert.fail("Infinite recursion");
+ Assertions.fail("Infinite recursion");
}
}
@@ -98,6 +98,6 @@ public class RegularizedBetaTest {
double a,
double b) {
final double actual = RegularizedBeta.value(x, a, b);
- Assert.assertEquals(expected, actual, 1e-15);
+ Assertions.assertEquals(expected, actual, 1e-15);
}
}
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 a6bf915..aef2da3 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
@@ -16,7 +16,7 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -61,7 +61,7 @@ public class RegularizedGammaTest {
private void testRegularizedGamma(double expected, double a, double x) {
double actualP = RegularizedGamma.P.value(a, x);
double actualQ = RegularizedGamma.Q.value(a, x);
- Assert.assertEquals(expected, actualP, 1e-15);
- Assert.assertEquals(actualP, 1 - actualQ, 1e-15);
+ Assertions.assertEquals(expected, actualP, 1e-15);
+ Assertions.assertEquals(actualP, 1 - actualQ, 1e-15);
}
}
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 6bb6b4f..bd7284f 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
@@ -16,7 +16,7 @@
*/
package org.apache.commons.numbers.gamma;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -45,15 +45,15 @@ public class TrigammaTest {
100, 0.010050166663333571395
};
for (int i = data.length - 2; i >= 0; i -= 2) {
- Assert.assertEquals(String.format("trigamma %.0f", data[i]), data[i + 1], Trigamma.value(data[i]), eps);
+ Assertions.assertEquals(data[i + 1], Trigamma.value(data[i]), eps, String.format("trigamma %.0f", data[i]));
}
}
@Test
public void testTrigammaNonRealArgs() {
- Assert.assertTrue(Double.isNaN(Trigamma.value(Double.NaN)));
- Assert.assertTrue(Double.isInfinite(Trigamma.value(Double.POSITIVE_INFINITY)));
- Assert.assertTrue(Double.isInfinite(Trigamma.value(Double.NEGATIVE_INFINITY)));
+ 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)));
}
}
[commons-numbers] 30/34: Remove unused JUnit 4 imports
Posted by er...@apache.org.
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 4fd2f595dcfa188e23ea52cdcee3f8b44a181bc5
Author: Schamschi <he...@gmx.at>
AuthorDate: Fri Jun 14 15:41:08 2019 +0200
Remove unused JUnit 4 imports
---
.../java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java | 1 -
.../src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java | 1 -
.../src/test/java/org/apache/commons/numbers/arrays/CosAngleTest.java | 1 -
.../java/org/apache/commons/numbers/arrays/LinearCombinationTest.java | 1 -
.../src/test/java/org/apache/commons/numbers/arrays/SafeNormTest.java | 1 -
.../org/apache/commons/numbers/combinatorics/FactorialDoubleTest.java | 1 -
.../java/org/apache/commons/numbers/combinatorics/FactorialTest.java | 1 -
.../apache/commons/numbers/combinatorics/LogBinomialCoefficientTest.java | 1 -
.../java/org/apache/commons/numbers/combinatorics/LogFactorialTest.java | 1 -
.../test/java/org/apache/commons/numbers/field/FieldParametricTest.java | 1 -
.../test/java/org/apache/commons/numbers/fraction/BigFractionTest.java | 1 -
.../java/org/apache/commons/numbers/fraction/ContinuedFractionTest.java | 1 -
12 files changed, 12 deletions(-)
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 0e1dbd9..c22d94b 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
@@ -13,7 +13,6 @@
*/
package org.apache.commons.numbers.angle;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
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 98e315a..dd0cfb7 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
@@ -13,7 +13,6 @@
*/
package org.apache.commons.numbers.angle;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
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 1b0fe86..7a7c730 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
@@ -13,7 +13,6 @@
*/
package org.apache.commons.numbers.arrays;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
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 2949772..5891fbb 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
@@ -13,7 +13,6 @@
*/
package org.apache.commons.numbers.arrays;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
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 e02c1df..4e3d324 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
@@ -13,7 +13,6 @@
*/
package org.apache.commons.numbers.arrays;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
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 4d8d96d..7bc8ce6 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
@@ -16,7 +16,6 @@
*/
package org.apache.commons.numbers.combinatorics;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
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 eb4ec58..ef75ab7 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
@@ -16,7 +16,6 @@
*/
package org.apache.commons.numbers.combinatorics;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
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 666d5c4..52c010d 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
@@ -16,7 +16,6 @@
*/
package org.apache.commons.numbers.combinatorics;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
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 3840626..7970869 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
@@ -18,7 +18,6 @@ package org.apache.commons.numbers.combinatorics;
import org.apache.commons.numbers.gamma.LogGamma;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
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 873642f..319edf2 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
@@ -16,7 +16,6 @@
*/
package org.apache.commons.numbers.field;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
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 a2e4020..039e8a6 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
@@ -21,7 +21,6 @@ import java.math.BigInteger;
import java.math.RoundingMode;
import org.apache.commons.numbers.core.TestUtils;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
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 42abd6d..5cef76d 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
@@ -16,7 +16,6 @@
*/
package org.apache.commons.numbers.fraction;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
[commons-numbers] 25/34: Assert does not throw
Posted by er...@apache.org.
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 b888cbc6e25a519f90bd8c2ef1de99bc06029bf9
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Sun Jun 9 22:47:15 2019 -0700
Assert does not throw
---
.../apache/commons/numbers/combinatorics/FactorialDoubleTest.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
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 7bda440..4d8d96d 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
@@ -105,9 +105,10 @@ public class FactorialDoubleTest {
@Test
public void testUselessCache() {
- // Ensure that no exception is thrown.
- LogFactorial.create().withCache(1);
- LogFactorial.create().withCache(2);
+ Assertions.assertDoesNotThrow(() -> {
+ LogFactorial.create().withCache(1);
+ LogFactorial.create().withCache(2);
+ });
}
@Test
[commons-numbers] 28/34: Merge branch 'master' into
eax/simple-migrate-map
Posted by er...@apache.org.
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 9aa77a9492d6acb1d655d4b73b2390b9290716db
Merge: e12bf62 934be57
Author: Schamschi <he...@gmx.at>
AuthorDate: Fri Jun 14 14:04:28 2019 +0200
Merge branch 'master' into eax/simple-migrate-map
# Conflicts:
# commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionTest.java
.../commons/numbers/fraction/FractionTest.java | 728 +++++++++++----------
1 file changed, 399 insertions(+), 329 deletions(-)
[commons-numbers] 26/34: Replace assertNotEquals with assertFalse
where necessary
Posted by er...@apache.org.
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 c76f3e73400d53b41f248c28219afd59717c9cbe
Author: Schamschi <he...@gmx.at>
AuthorDate: Tue Jun 11 17:11:50 2019 +0200
Replace assertNotEquals with assertFalse where necessary
Don't make assumptions about which parameter's equals(Object) method is called in assertNotEquals(Object, Object)
---
.../src/test/java/org/apache/commons/numbers/complex/ComplexTest.java | 2 +-
.../java/org/apache/commons/numbers/fraction/BigFractionTest.java | 4 ++--
.../java/org/apache/commons/numbers/quaternion/QuaternionTest.java | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
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 9dff601..a105dcc 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
@@ -404,7 +404,7 @@ public class ComplexTest {
@Test
public void testEqualsClass() {
Complex x = Complex.ofCartesian(3.0, 4.0);
- Assertions.assertNotEquals(x, this);
+ Assertions.assertFalse(x.equals(this));
}
@Test
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 539c624..a2e4020 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
@@ -597,8 +597,8 @@ public class BigFractionTest {
BigFraction zero = BigFraction.of(0, 1);
BigFraction nullFraction = null;
Assertions.assertEquals(zero, zero);
- Assertions.assertNotEquals(nullFraction, zero);
- Assertions.assertNotEquals(0.0d, zero);
+ Assertions.assertFalse(zero.equals(nullFraction));
+ Assertions.assertFalse(zero.equals(Double.valueOf(0)));
BigFraction zero2 = BigFraction.of(0, 2);
Assertions.assertEquals(zero, zero2);
Assertions.assertEquals(zero.hashCode(), zero2.hashCode());
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 b2f7a82..7a787dc 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
@@ -378,7 +378,7 @@ public class QuaternionTest {
final Quaternion q3 = Quaternion.of(one, Math.nextUp(one), one, one);
Assertions.assertNotEquals(q3, q1);
- Assertions.assertNotEquals("bar", q3);
+ Assertions.assertFalse(q3.equals("bar"));
}
@Test
[commons-numbers] 08/34: re-add one and zero
Posted by er...@apache.org.
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 ad2d9284f24fdb68ab7158cc2529fcab14719f57
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Fri Jun 7 19:12:21 2019 -0700
re-add one and zero
---
.../commons/numbers/field/FieldParametricTest.java | 29 +++++++---------------
.../apache/commons/numbers/fraction/Fraction.java | 12 +++++++++
2 files changed, 21 insertions(+), 20 deletions(-)
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 36d6ba2..d68af63 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
@@ -18,10 +18,8 @@ package org.apache.commons.numbers.field;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
/**
* Tests for fields.
@@ -29,29 +27,20 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(value=Parameterized.class)
public class FieldParametricTest {
/** Field under test. */
- private final Field field;
- private final Object a;
- private final Object b;
- private final Object c;
+ @Parameterized.Parameter(0)
+ private Field field;
+ @Parameterized.Parameter(1)
+ private Object a;
+ @Parameterized.Parameter(2)
+ private Object b;
+ @Parameterized.Parameter(3)
+ private Object c;
- /**
- * Initializes data instance.
- *
- * @param data Field data to be tested.
- */
- public FieldParametricTest(FieldTestData data) {
- this.field = data.getField();
- this.a = data.getA();
- this.b = data.getB();
- this.c = data.getC();
- }
-
- @Parameters(name = "{index}: data={0}")
+ @Parameterized.Parameters()
public static Iterable<FieldTestData[]> getList() {
return FieldsList.list();
}
- @ParameterizedTest
public void testAdditionAssociativity() {
final Object r1 = field.add(field.add(a, b), c);
final Object r2 = field.add(a, field.add(b, c));
diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
index 3fbf96f..74beb3b 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
@@ -625,6 +625,18 @@ public class Fraction
return str;
}
+ /** {@inheritDoc} */
+ @Override
+ public Fraction zero() {
+ return ZERO;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Fraction one() {
+ return ONE;
+ }
+
/**
* Parses a string that would be produced by {@link #toString()}
* and instantiates the corresponding object.
[commons-numbers] 22/34: use JUnit 5 assertions
Posted by er...@apache.org.
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 d6b008c96bc3e999cdbdfdde00389be47ef2fe87
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Sun Jun 9 22:28:39 2019 -0700
use JUnit 5 assertions
---
.../numbers/angle/PlaneAngleRadiansTest.java | 31 +--
.../commons/numbers/angle/PlaneAngleTest.java | 65 +++---
.../commons/numbers/arrays/CosAngleTest.java | 21 +-
.../numbers/arrays/LinearCombinationTest.java | 85 ++++----
.../commons/numbers/arrays/SafeNormTest.java | 15 +-
.../numbers/combinatorics/FactorialDoubleTest.java | 30 +--
.../numbers/combinatorics/FactorialTest.java | 4 +-
.../combinatorics/LogBinomialCoefficientTest.java | 20 +-
.../numbers/combinatorics/LogFactorialTest.java | 20 +-
.../commons/numbers/fraction/BigFractionTest.java | 240 ++++++++++-----------
.../numbers/fraction/ContinuedFractionTest.java | 7 +-
.../commons/numbers/fraction/FractionTest.java | 196 ++++++++---------
12 files changed, 370 insertions(+), 364 deletions(-)
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 7a560ed..0e1dbd9 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
@@ -14,6 +14,7 @@
package org.apache.commons.numbers.angle;
import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -27,10 +28,10 @@ public class PlaneAngleRadiansTest {
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);
- Assert.assertTrue((b - Math.PI) <= c);
- Assert.assertTrue(c <= (b + Math.PI));
+ Assertions.assertTrue((b - Math.PI) <= c);
+ Assertions.assertTrue(c <= (b + Math.PI));
double twoK = Math.rint((a - c) / Math.PI);
- Assert.assertEquals(c, a - twoK * Math.PI, 1e-14);
+ Assertions.assertEquals(c, a - twoK * Math.PI, 1e-14);
}
}
}
@@ -41,7 +42,7 @@ public class PlaneAngleRadiansTest {
final double expected = 0.25 * TWO_PI;
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
public void testNormalizeBetweenMinusPiAndPi2() {
@@ -49,7 +50,7 @@ public class PlaneAngleRadiansTest {
final double expected = -0.25 * TWO_PI;
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
public void testNormalizeBetweenMinusPiAndPi3() {
@@ -57,7 +58,7 @@ public class PlaneAngleRadiansTest {
final double expected = -0.5 * TWO_PI + 1e-10;
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
public void testNormalizeBetweenMinusPiAndPi4() {
@@ -65,7 +66,7 @@ public class PlaneAngleRadiansTest {
final double expected = Math.PI * (1d / 4 - 1);
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
@@ -74,7 +75,7 @@ public class PlaneAngleRadiansTest {
final double expected = -Math.PI;
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
public void testNormalizeBetweenMinusPiAndPi_upperBound() {
@@ -82,7 +83,7 @@ public class PlaneAngleRadiansTest {
final double expected = -Math.PI;
final double actual = PlaneAngleRadians.normalizeBetweenMinusPiAndPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
@@ -91,7 +92,7 @@ public class PlaneAngleRadiansTest {
final double expected = 0.25 * TWO_PI;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
public void testNormalizeBetweenZeroAndTwoPi2() {
@@ -99,7 +100,7 @@ public class PlaneAngleRadiansTest {
final double expected = 0.75 * TWO_PI;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
public void testNormalizeBetweenZeroAndTwoPi3() {
@@ -107,7 +108,7 @@ public class PlaneAngleRadiansTest {
final double expected = 0.5 * TWO_PI + 1e-10;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
public void testNormalizeBetweenZeroAndTwoPi4() {
@@ -115,7 +116,7 @@ public class PlaneAngleRadiansTest {
final double expected = Math.PI / 4;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
@@ -124,7 +125,7 @@ public class PlaneAngleRadiansTest {
final double expected = 0.0;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
public void testNormalizeBetweenZeroAndTwoPi_upperBound() {
@@ -132,6 +133,6 @@ public class PlaneAngleRadiansTest {
final double expected = 0.0;
final double actual = PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(value);
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
}
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 48e7f21..54ddddd 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
@@ -14,6 +14,7 @@
package org.apache.commons.numbers.angle;
import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -24,7 +25,7 @@ public class PlaneAngleTest {
public void testConversionTurns() {
final double value = 12.3456;
final PlaneAngle a = PlaneAngle.ofTurns(value);
- Assert.assertEquals(value, a.toTurns(), 0d);
+ Assertions.assertEquals(value, a.toTurns(), 0d);
}
@Test
@@ -32,7 +33,7 @@ public class PlaneAngleTest {
final double one = 2 * Math.PI;
final double value = 12.3456 * one;
final PlaneAngle a = PlaneAngle.ofRadians(value);
- Assert.assertEquals(value, a.toRadians(), 0d);
+ Assertions.assertEquals(value, a.toRadians(), 0d);
}
@Test
@@ -40,7 +41,7 @@ public class PlaneAngleTest {
final double one = 360;
final double value = 12.3456 * one;
final PlaneAngle a = PlaneAngle.ofDegrees(value);
- Assert.assertEquals(value, a.toDegrees(), 0d);
+ Assertions.assertEquals(value, a.toDegrees(), 0d);
}
@Test
@@ -50,10 +51,10 @@ public class PlaneAngleTest {
final PlaneAngle aA = PlaneAngle.ofRadians(a);
final PlaneAngle aB = PlaneAngle.ofRadians(b);
final double c = aA.normalize(aB).toRadians();
- Assert.assertTrue((b - Math.PI) <= c);
- Assert.assertTrue(c <= (b + Math.PI));
+ Assertions.assertTrue((b - Math.PI) <= c);
+ Assertions.assertTrue(c <= (b + Math.PI));
double twoK = Math.rint((a - c) / Math.PI);
- Assert.assertEquals(c, a - twoK * Math.PI, 1e-14);
+ Assertions.assertEquals(c, a - twoK * Math.PI, 1e-14);
}
}
}
@@ -65,10 +66,10 @@ public class PlaneAngleTest {
final PlaneAngle aA = PlaneAngle.ofDegrees(a);
final PlaneAngle aB = PlaneAngle.ofRadians(b);
final double c = aA.normalize(aB).toTurns();
- Assert.assertTrue((aB.toTurns() - 0.5) <= c);
- Assert.assertTrue(c <= (aB.toTurns() + 0.5));
+ Assertions.assertTrue((aB.toTurns() - 0.5) <= c);
+ Assertions.assertTrue(c <= (aB.toTurns() + 0.5));
double twoK = Math.rint((aA.toTurns() - c));
- Assert.assertEquals(c, aA.toTurns() - twoK, 1e-14);
+ Assertions.assertEquals(c, aA.toTurns() - twoK, 1e-14);
}
}
}
@@ -79,7 +80,7 @@ public class PlaneAngleTest {
final double expected = 0.25;
final double actual = PlaneAngle.ofTurns(value).normalize(PlaneAngle.ZERO).toTurns();
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
public void testNormalizeAroundZero2() {
@@ -87,7 +88,7 @@ public class PlaneAngleTest {
final double expected = -0.25;
final double actual = PlaneAngle.ofTurns(value).normalize(PlaneAngle.ZERO).toTurns();
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
public void testNormalizeAroundZero3() {
@@ -95,7 +96,7 @@ public class PlaneAngleTest {
final double expected = -0.5 + 1e-10;
final double actual = PlaneAngle.ofTurns(value).normalize(PlaneAngle.ZERO).toTurns();
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
public void testNormalizeAroundZero4() {
@@ -103,7 +104,7 @@ public class PlaneAngleTest {
final double expected = Math.PI * (1d / 4 - 1);
final double actual = PlaneAngle.ofRadians(value).normalize(PlaneAngle.ZERO).toRadians();
final double tol = Math.ulp(expected);
- Assert.assertEquals(expected, actual, tol);
+ Assertions.assertEquals(expected, actual, tol);
}
@Test
@@ -112,17 +113,17 @@ public class PlaneAngleTest {
double eps = 1e-15;
// act/assert
- Assert.assertEquals(-0.5, PlaneAngle.ofTurns(-0.5).normalize(PlaneAngle.ZERO).toTurns(), eps);
- Assert.assertEquals(-0.5, PlaneAngle.ofTurns(0.5).normalize(PlaneAngle.ZERO).toTurns(), eps);
+ Assertions.assertEquals(-0.5, PlaneAngle.ofTurns(-0.5).normalize(PlaneAngle.ZERO).toTurns(), eps);
+ Assertions.assertEquals(-0.5, PlaneAngle.ofTurns(0.5).normalize(PlaneAngle.ZERO).toTurns(), eps);
- Assert.assertEquals(-0.5, PlaneAngle.ofTurns(-1.5).normalize(PlaneAngle.ZERO).toTurns(), eps);
- Assert.assertEquals(-0.5, PlaneAngle.ofTurns(1.5).normalize(PlaneAngle.ZERO).toTurns(), eps);
+ Assertions.assertEquals(-0.5, PlaneAngle.ofTurns(-1.5).normalize(PlaneAngle.ZERO).toTurns(), eps);
+ Assertions.assertEquals(-0.5, PlaneAngle.ofTurns(1.5).normalize(PlaneAngle.ZERO).toTurns(), eps);
- Assert.assertEquals(0.0, PlaneAngle.ofTurns(0).normalize(PlaneAngle.PI).toTurns(), eps);
- Assert.assertEquals(0.0, PlaneAngle.ofTurns(1).normalize(PlaneAngle.PI).toTurns(), eps);
+ Assertions.assertEquals(0.0, PlaneAngle.ofTurns(0).normalize(PlaneAngle.PI).toTurns(), eps);
+ Assertions.assertEquals(0.0, PlaneAngle.ofTurns(1).normalize(PlaneAngle.PI).toTurns(), eps);
- Assert.assertEquals(0.0, PlaneAngle.ofTurns(-1).normalize(PlaneAngle.PI).toTurns(), eps);
- Assert.assertEquals(0.0, PlaneAngle.ofTurns(2).normalize(PlaneAngle.PI).toTurns(), eps);
+ Assertions.assertEquals(0.0, PlaneAngle.ofTurns(-1).normalize(PlaneAngle.PI).toTurns(), eps);
+ Assertions.assertEquals(0.0, PlaneAngle.ofTurns(2).normalize(PlaneAngle.PI).toTurns(), eps);
}
@Test
@@ -134,17 +135,17 @@ public class PlaneAngleTest {
double tiny = 1e-18; // 0.5 + tiny = 0.5 (the value is too small to add to 0.5)
// act/assert
- Assert.assertEquals(1.0 - small, PlaneAngle.ofTurns(-small).normalize(PlaneAngle.PI).toTurns(), eps);
- Assert.assertEquals(small, PlaneAngle.ofTurns(small).normalize(PlaneAngle.PI).toTurns(), eps);
+ Assertions.assertEquals(1.0 - small, PlaneAngle.ofTurns(-small).normalize(PlaneAngle.PI).toTurns(), eps);
+ Assertions.assertEquals(small, PlaneAngle.ofTurns(small).normalize(PlaneAngle.PI).toTurns(), eps);
- Assert.assertEquals(0.5 - small, PlaneAngle.ofTurns(-0.5 - small).normalize(PlaneAngle.ZERO).toTurns(), eps);
- Assert.assertEquals(-0.5 + small, PlaneAngle.ofTurns(0.5 + small).normalize(PlaneAngle.ZERO).toTurns(), eps);
+ Assertions.assertEquals(0.5 - small, PlaneAngle.ofTurns(-0.5 - small).normalize(PlaneAngle.ZERO).toTurns(), eps);
+ Assertions.assertEquals(-0.5 + small, PlaneAngle.ofTurns(0.5 + small).normalize(PlaneAngle.ZERO).toTurns(), eps);
- Assert.assertEquals(0.0, PlaneAngle.ofTurns(-tiny).normalize(PlaneAngle.PI).toTurns(), eps);
- Assert.assertEquals(tiny, PlaneAngle.ofTurns(tiny).normalize(PlaneAngle.PI).toTurns(), eps);
+ Assertions.assertEquals(0.0, PlaneAngle.ofTurns(-tiny).normalize(PlaneAngle.PI).toTurns(), eps);
+ Assertions.assertEquals(tiny, PlaneAngle.ofTurns(tiny).normalize(PlaneAngle.PI).toTurns(), eps);
- Assert.assertEquals(-0.5, PlaneAngle.ofTurns(-0.5 - tiny).normalize(PlaneAngle.ZERO).toTurns(), eps);
- Assert.assertEquals(-0.5, PlaneAngle.ofTurns(0.5 + tiny).normalize(PlaneAngle.ZERO).toTurns(), eps);
+ Assertions.assertEquals(-0.5, PlaneAngle.ofTurns(-0.5 - tiny).normalize(PlaneAngle.ZERO).toTurns(), eps);
+ Assertions.assertEquals(-0.5, PlaneAngle.ofTurns(0.5 + tiny).normalize(PlaneAngle.ZERO).toTurns(), eps);
}
@Test
@@ -153,7 +154,7 @@ public class PlaneAngleTest {
final double value = -123.456789;
final int expected = Double.valueOf(value).hashCode();
final int actual = PlaneAngle.ofTurns(value).hashCode();
- Assert.assertEquals(actual, expected);
+ Assertions.assertEquals(actual, expected);
}
@Test
@@ -179,10 +180,10 @@ public class PlaneAngleTest {
@Test
public void testZero() {
- Assert.assertEquals(0, PlaneAngle.ZERO.toRadians(), 0d);
+ Assertions.assertEquals(0, PlaneAngle.ZERO.toRadians(), 0d);
}
@Test
public void testPi() {
- Assert.assertEquals(Math.PI, PlaneAngle.PI.toRadians(), 0d);
+ Assertions.assertEquals(Math.PI, PlaneAngle.PI.toRadians(), 0d);
}
}
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 a8593b4..1b0fe86 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
@@ -14,6 +14,7 @@
package org.apache.commons.numbers.arrays;
import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -26,24 +27,24 @@ public class CosAngleTest {
final double[] v1 = { 1, 0 };
expected = 1;
- Assert.assertEquals(expected, CosAngle.value(v1, v1), 0d);
+ Assertions.assertEquals(expected, CosAngle.value(v1, v1), 0d);
final double[] v2 = { 0, 1 };
expected = 0;
- Assert.assertEquals(expected, CosAngle.value(v1, v2), 0d);
+ Assertions.assertEquals(expected, CosAngle.value(v1, v2), 0d);
final double[] v3 = { 7, 7 };
expected = Math.sqrt(2) / 2;
- Assert.assertEquals(expected, CosAngle.value(v1, v3), 1e-15);
- Assert.assertEquals(expected, CosAngle.value(v3, v2), 1e-15);
+ Assertions.assertEquals(expected, CosAngle.value(v1, v3), 1e-15);
+ Assertions.assertEquals(expected, CosAngle.value(v3, v2), 1e-15);
final double[] v4 = { -5, 0 };
expected = -1;
- Assert.assertEquals(expected, CosAngle.value(v1, v4), 0);
+ Assertions.assertEquals(expected, CosAngle.value(v1, v4), 0);
final double[] v5 = { -100, 100 };
expected = 0;
- Assert.assertEquals(expected, CosAngle.value(v3, v5), 0);
+ Assertions.assertEquals(expected, CosAngle.value(v3, v5), 0);
}
@Test
@@ -52,11 +53,11 @@ public class CosAngleTest {
final double[] v1 = { 1, 1, 0 };
expected = 1;
- Assert.assertEquals(expected, CosAngle.value(v1, v1), 1e-15);
+ Assertions.assertEquals(expected, CosAngle.value(v1, v1), 1e-15);
final double[] v2 = { 1, 1, 1 };
expected = Math.sqrt(2) / Math.sqrt(3);
- Assert.assertEquals(expected, CosAngle.value(v1, v2), 1e-15);
+ Assertions.assertEquals(expected, CosAngle.value(v1, v2), 1e-15);
}
@Test
@@ -68,10 +69,10 @@ public class CosAngleTest {
final double big = 1e200;
final double[] v2 = { -big, -big };
expected = -1;
- Assert.assertEquals(expected, CosAngle.value(v1, v2), 1e-15);
+ Assertions.assertEquals(expected, CosAngle.value(v1, v2), 1e-15);
final double[] v3 = { big, -big };
expected = 0;
- Assert.assertEquals(expected, CosAngle.value(v1, v3), 1e-15);
+ Assertions.assertEquals(expected, CosAngle.value(v1, v3), 1e-15);
}
}
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 da7e769..2949772 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
@@ -14,6 +14,7 @@
package org.apache.commons.numbers.arrays;
import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.apache.commons.rng.UniformRandomProvider;
@@ -30,7 +31,7 @@ public class LinearCombinationTest {
final double[] a = { 1.23456789 };
final double[] b = { 98765432.1 };
- Assert.assertEquals(a[0] * b[0], LinearCombination.value(a, b), 0d);
+ Assertions.assertEquals(a[0] * b[0], LinearCombination.value(a, b), 0d);
}
@Test
@@ -59,7 +60,7 @@ public class LinearCombinationTest {
a[1], b[1],
a[2], b[2]);
final double abSumArray = LinearCombination.value(a, b);
- Assert.assertEquals(abSumInline, abSumArray, 0);
+ Assertions.assertEquals(abSumInline, abSumArray, 0);
// Compare with arbitrary precision computation.
BigFraction result = BigFraction.ZERO;
@@ -67,10 +68,10 @@ public class LinearCombinationTest {
result = result.add(aF[i].multiply(bF[i]));
}
final double expected = result.doubleValue();
- Assert.assertEquals(expected, abSumInline, 1e-15);
+ Assertions.assertEquals(expected, abSumInline, 1e-15);
final double naive = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
- Assert.assertTrue(Math.abs(naive - abSumInline) > 1.5);
+ Assertions.assertTrue(Math.abs(naive - abSumInline) > 1.5);
}
@Test
@@ -94,19 +95,19 @@ public class LinearCombinationTest {
sInline = LinearCombination.value(u1, v1, u2, v2);
sArray = LinearCombination.value(new double[] { u1, u2 },
new double[] { v1, v2 });
- Assert.assertEquals(sInline, sArray, 0);
+ Assertions.assertEquals(sInline, sArray, 0);
// Two sums.
sInline = LinearCombination.value(u1, v1, u2, v2, u3, v3);
sArray = LinearCombination.value(new double[] { u1, u2, u3 },
new double[] { v1, v2, v3 });
- Assert.assertEquals(sInline, sArray, 0);
+ Assertions.assertEquals(sInline, sArray, 0);
// 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 });
- Assert.assertEquals(sInline, sArray, 0);
+ Assertions.assertEquals(sInline, sArray, 0);
}
}
@@ -136,11 +137,11 @@ public class LinearCombinationTest {
scaledA[2], scaledB[2]);
final double abSumArray = LinearCombination.value(scaledA, scaledB);
- Assert.assertEquals(abSumInline, abSumArray, 0);
- Assert.assertEquals(-1.8551294182586248737720779899, abSumInline, 1e-15);
+ Assertions.assertEquals(abSumInline, abSumArray, 0);
+ Assertions.assertEquals(-1.8551294182586248737720779899, abSumInline, 1e-15);
final double naive = scaledA[0] * scaledB[0] + scaledA[1] * scaledB[1] + scaledA[2] * scaledB[2];
- Assert.assertTrue(Math.abs(naive - abSumInline) > 1.5);
+ Assertions.assertTrue(Math.abs(naive - abSumInline) > 1.5);
}
@Test
@@ -166,132 +167,132 @@ public class LinearCombinationTest {
{ Double.NaN, -2, 3, 4 }
};
- Assert.assertEquals(-3,
+ Assertions.assertEquals(-3,
LinearCombination.value(a[0][0], b[0][0],
a[0][1], b[0][1]),
1e-10);
- Assert.assertEquals(6,
+ Assertions.assertEquals(6,
LinearCombination.value(a[0][0], b[0][0],
a[0][1], b[0][1],
a[0][2], b[0][2]),
1e-10);
- Assert.assertEquals(22,
+ Assertions.assertEquals(22,
LinearCombination.value(a[0][0], b[0][0],
a[0][1], b[0][1],
a[0][2], b[0][2],
a[0][3], b[0][3]),
1e-10);
- Assert.assertEquals(22, LinearCombination.value(a[0], b[0]), 1e-10);
+ Assertions.assertEquals(22, LinearCombination.value(a[0], b[0]), 1e-10);
- Assert.assertEquals(Double.NEGATIVE_INFINITY,
+ Assertions.assertEquals(Double.NEGATIVE_INFINITY,
LinearCombination.value(a[1][0], b[1][0],
a[1][1], b[1][1]),
1e-10);
- Assert.assertEquals(Double.NEGATIVE_INFINITY,
+ Assertions.assertEquals(Double.NEGATIVE_INFINITY,
LinearCombination.value(a[1][0], b[1][0],
a[1][1], b[1][1],
a[1][2], b[1][2]),
1e-10);
- Assert.assertEquals(Double.NEGATIVE_INFINITY,
+ Assertions.assertEquals(Double.NEGATIVE_INFINITY,
LinearCombination.value(a[1][0], b[1][0],
a[1][1], b[1][1],
a[1][2], b[1][2],
a[1][3], b[1][3]),
1e-10);
- Assert.assertEquals(Double.NEGATIVE_INFINITY, LinearCombination.value(a[1], b[1]), 1e-10);
+ Assertions.assertEquals(Double.NEGATIVE_INFINITY, LinearCombination.value(a[1], b[1]), 1e-10);
- Assert.assertEquals(-3,
+ Assertions.assertEquals(-3,
LinearCombination.value(a[2][0], b[2][0],
a[2][1], b[2][1]),
1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY,
+ Assertions.assertEquals(Double.POSITIVE_INFINITY,
LinearCombination.value(a[2][0], b[2][0],
a[2][1], b[2][1],
a[2][2], b[2][2]),
1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY,
+ Assertions.assertEquals(Double.POSITIVE_INFINITY,
LinearCombination.value(a[2][0], b[2][0],
a[2][1], b[2][1],
a[2][2], b[2][2],
a[2][3], b[2][3]),
1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY, LinearCombination.value(a[2], b[2]), 1e-10);
+ Assertions.assertEquals(Double.POSITIVE_INFINITY, LinearCombination.value(a[2], b[2]), 1e-10);
- Assert.assertEquals(Double.NEGATIVE_INFINITY,
+ Assertions.assertEquals(Double.NEGATIVE_INFINITY,
LinearCombination.value(a[3][0], b[3][0],
a[3][1], b[3][1]),
1e-10);
- Assert.assertEquals(Double.NEGATIVE_INFINITY,
+ Assertions.assertEquals(Double.NEGATIVE_INFINITY,
LinearCombination.value(a[3][0], b[3][0],
a[3][1], b[3][1],
a[3][2], b[3][2]),
1e-10);
- Assert.assertEquals(Double.NEGATIVE_INFINITY,
+ Assertions.assertEquals(Double.NEGATIVE_INFINITY,
LinearCombination.value(a[3][0], b[3][0],
a[3][1], b[3][1],
a[3][2], b[3][2],
a[3][3], b[3][3]),
1e-10);
- Assert.assertEquals(Double.NEGATIVE_INFINITY, LinearCombination.value(a[3], b[3]), 1e-10);
+ Assertions.assertEquals(Double.NEGATIVE_INFINITY, LinearCombination.value(a[3], b[3]), 1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY,
+ Assertions.assertEquals(Double.POSITIVE_INFINITY,
LinearCombination.value(a[4][0], b[4][0],
a[4][1], b[4][1]),
1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY,
+ Assertions.assertEquals(Double.POSITIVE_INFINITY,
LinearCombination.value(a[4][0], b[4][0],
a[4][1], b[4][1],
a[4][2], b[4][2]),
1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY,
+ Assertions.assertEquals(Double.POSITIVE_INFINITY,
LinearCombination.value(a[4][0], b[4][0],
a[4][1], b[4][1],
a[4][2], b[4][2],
a[4][3], b[4][3]),
1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY, LinearCombination.value(a[4], b[4]), 1e-10);
+ Assertions.assertEquals(Double.POSITIVE_INFINITY, LinearCombination.value(a[4], b[4]), 1e-10);
- Assert.assertEquals(-3,
+ Assertions.assertEquals(-3,
LinearCombination.value(a[5][0], b[5][0],
a[5][1], b[5][1]),
1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY,
+ Assertions.assertEquals(Double.POSITIVE_INFINITY,
LinearCombination.value(a[5][0], b[5][0],
a[5][1], b[5][1],
a[5][2], b[5][2]),
1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY,
+ Assertions.assertEquals(Double.POSITIVE_INFINITY,
LinearCombination.value(a[5][0], b[5][0],
a[5][1], b[5][1],
a[5][2], b[5][2],
a[5][3], b[5][3]),
1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY, LinearCombination.value(a[5], b[5]), 1e-10);
+ Assertions.assertEquals(Double.POSITIVE_INFINITY, LinearCombination.value(a[5], b[5]), 1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY,
+ Assertions.assertEquals(Double.POSITIVE_INFINITY,
LinearCombination.value(a[6][0], b[6][0],
a[6][1], b[6][1]),
1e-10);
- Assert.assertEquals(Double.POSITIVE_INFINITY,
+ Assertions.assertEquals(Double.POSITIVE_INFINITY,
LinearCombination.value(a[6][0], b[6][0],
a[6][1], b[6][1],
a[6][2], b[6][2]),
1e-10);
- Assert.assertTrue(Double.isNaN(LinearCombination.value(a[6][0], b[6][0],
+ Assertions.assertTrue(Double.isNaN(LinearCombination.value(a[6][0], b[6][0],
a[6][1], b[6][1],
a[6][2], b[6][2],
a[6][3], b[6][3])));
- Assert.assertTrue(Double.isNaN(LinearCombination.value(a[6], b[6])));
+ Assertions.assertTrue(Double.isNaN(LinearCombination.value(a[6], b[6])));
- Assert.assertTrue(Double.isNaN(LinearCombination.value(a[7][0], b[7][0],
+ Assertions.assertTrue(Double.isNaN(LinearCombination.value(a[7][0], b[7][0],
a[7][1], b[7][1])));
- Assert.assertTrue(Double.isNaN(LinearCombination.value(a[7][0], b[7][0],
+ Assertions.assertTrue(Double.isNaN(LinearCombination.value(a[7][0], b[7][0],
a[7][1], b[7][1],
a[7][2], b[7][2])));
- Assert.assertTrue(Double.isNaN(LinearCombination.value(a[7][0], b[7][0],
+ Assertions.assertTrue(Double.isNaN(LinearCombination.value(a[7][0], b[7][0],
a[7][1], b[7][1],
a[7][2], b[7][2],
a[7][3], b[7][3])));
- Assert.assertTrue(Double.isNaN(LinearCombination.value(a[7], b[7])));
+ Assertions.assertTrue(Double.isNaN(LinearCombination.value(a[7], b[7])));
}
}
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 cbfbc22..e02c1df 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
@@ -14,6 +14,7 @@
package org.apache.commons.numbers.arrays;
import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -25,28 +26,28 @@ public class SafeNormTest {
public void testTiny() {
final double s = 1e-320;
final double[] v = new double[] { s, s };
- Assert.assertEquals(Math.sqrt(2) * s, SafeNorm.value(v), 0d);
+ Assertions.assertEquals(Math.sqrt(2) * s, SafeNorm.value(v), 0d);
}
@Test
public void testBig() {
final double s = 1e300;
final double[] v = new double[] { s, s };
- Assert.assertEquals(Math.sqrt(2) * s, SafeNorm.value(v), 0d);
+ Assertions.assertEquals(Math.sqrt(2) * s, SafeNorm.value(v), 0d);
}
@Test
public void testOne3D() {
final double s = 1;
final double[] v = new double[] { s, s, s };
- Assert.assertEquals(Math.sqrt(3), SafeNorm.value(v), 0d);
+ Assertions.assertEquals(Math.sqrt(3), SafeNorm.value(v), 0d);
}
@Test
public void testUnit3D() {
- Assert.assertEquals(1, SafeNorm.value(new double[] { 1, 0, 0 }), 0d);
- Assert.assertEquals(1, SafeNorm.value(new double[] { 0, 1, 0 }), 0d);
- Assert.assertEquals(1, SafeNorm.value(new double[] { 0, 0, 1 }), 0d);
+ 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);
}
@Test
@@ -57,6 +58,6 @@ public class SafeNormTest {
n += v[i] * v[i];
}
final double expected = Math.sqrt(n);
- Assert.assertEquals(expected, SafeNorm.value(v), 0d);
+ Assertions.assertEquals(expected, SafeNorm.value(v), 0d);
}
}
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 7491080..7bda440 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
@@ -26,29 +26,29 @@ import org.junit.jupiter.api.Test;
public class FactorialDoubleTest {
@Test
public void testFactorialZero() {
- Assert.assertEquals("0!", 1, FactorialDouble.create().value(0), 0d);
+ Assertions.assertEquals(1, FactorialDouble.create().value(0), 0d, "0!");
}
@Test
public void testFactorialDirect() {
for (int i = 1; i < 21; i++) {
- Assert.assertEquals(i + "!",
- factorialDirect(i), FactorialDouble.create().value(i), 0d);
+ Assertions.assertEquals(
+ factorialDirect(i), FactorialDouble.create().value(i), 0d, i + "!");
}
}
@Test
public void testLargestFactorialDouble() {
final int n = 170;
- Assert.assertTrue(n + "!",
- Double.POSITIVE_INFINITY != FactorialDouble.create().value(n));
+ Assertions.assertTrue(
+ Double.POSITIVE_INFINITY != FactorialDouble.create().value(n), n + "!");
}
@Test
public void testFactorialDoubleTooLarge() {
final int n = 171;
- Assert.assertEquals(n + "!",
- Double.POSITIVE_INFINITY, FactorialDouble.create().value(n), 0d);
+ Assertions.assertEquals(
+ Double.POSITIVE_INFINITY, FactorialDouble.create().value(n), 0d, n + "!");
}
@Test()
@@ -68,8 +68,8 @@ public class FactorialDoubleTest {
for (int i = 0; i < max; i++) {
final double expected = factorialDirect(i);
- Assert.assertEquals(i + "! ",
- expected, f.value(i), 100 * Math.ulp(expected));
+ Assertions.assertEquals(
+ expected, f.value(i), 100 * Math.ulp(expected), i + "! ");
}
}
@@ -80,8 +80,8 @@ public class FactorialDoubleTest {
for (int i = 0; i < max; i++) {
final double expected = factorialDirect(i);
- Assert.assertEquals(i + "! ",
- expected, f.value(i), 100 * Math.ulp(expected));
+ Assertions.assertEquals(
+ expected, f.value(i), 100 * Math.ulp(expected), i + "! ");
}
}
@@ -92,15 +92,15 @@ public class FactorialDoubleTest {
final FactorialDouble f2 = f1.withCache(2 * max);
final int val = max + max / 2;
- Assert.assertEquals(f1.value(val), f2.value(val), 0d);
+ Assertions.assertEquals(f1.value(val), f2.value(val), 0d);
}
@Test
public void testZeroCache() {
// Ensure that no exception is thrown.
final FactorialDouble f = FactorialDouble.create().withCache(0);
- Assert.assertEquals(1, f.value(0), 0d);
- Assert.assertEquals(1, f.value(1), 0d);
+ Assertions.assertEquals(1, f.value(0), 0d);
+ Assertions.assertEquals(1, f.value(1), 0d);
}
@Test
@@ -117,7 +117,7 @@ public class FactorialDoubleTest {
final FactorialDouble f2 = f1.withCache(max / 2);
final int val = max / 4;
- Assert.assertEquals(f1.value(val), f2.value(val), 0d);
+ Assertions.assertEquals(f1.value(val), f2.value(val), 0d);
}
/**
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 4e74dd8..eb4ec58 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
@@ -26,13 +26,13 @@ import org.junit.jupiter.api.Test;
public class FactorialTest {
@Test
public void testFactorialZero() {
- Assert.assertEquals("0!", 1, Factorial.value(0));
+ Assertions.assertEquals(1, Factorial.value(0), "0!");
}
@Test
public void testFactorial() {
for (int i = 1; i < 21; i++) {
- Assert.assertEquals(i + "!", factorial(i), Factorial.value(i));
+ Assertions.assertEquals(factorial(i), Factorial.value(i), i + "!");
}
}
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 1e1a8f5..666d5c4 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
@@ -27,7 +27,7 @@ public class LogBinomialCoefficientTest {
/** Verify that b(0,0) = 1 */
@Test
public void test0Choose0() {
- Assert.assertEquals(0d, LogBinomialCoefficient.value(0, 0), 0);
+ Assertions.assertEquals(0d, LogBinomialCoefficient.value(0, 0), 0);
}
@Test
@@ -37,9 +37,9 @@ public class LogBinomialCoefficientTest {
for (int n = 1; n < 10; n++) {
for (int k = 0; k <= n; k++) {
- Assert.assertEquals(n + " choose " + k,
- Math.log(BinomialCoefficientTest.binomialCoefficient(n, k)),
- LogBinomialCoefficient.value(n, k), 1e-12);
+ Assertions.assertEquals(
+ Math.log(BinomialCoefficientTest.binomialCoefficient(n, k)),
+ LogBinomialCoefficient.value(n, k), 1e-12, n + " choose " + k);
}
}
@@ -47,10 +47,10 @@ public class LogBinomialCoefficientTest {
final int[] k = { 17, 33, 10, 1500 - 4, 4 };
for (int i = 0; i < n.length; i++) {
final long expected = BinomialCoefficientTest.binomialCoefficient(n[i], k[i]);
- Assert.assertEquals("log(" + n[i] + " choose " + k[i] + ")",
- Math.log(expected),
+ Assertions.assertEquals(
+ Math.log(expected),
LogBinomialCoefficient.value(n[i], k[i]),
- 0d);
+ 0d, "log(" + n[i] + " choose " + k[i] + ")");
}
}
@@ -92,8 +92,8 @@ public class LogBinomialCoefficientTest {
}
if (!shouldThrow && exactResult > 1) {
- Assert.assertEquals(n + " choose " + k, 1,
- LogBinomialCoefficient.value(n, k) / Math.log(exactResult), 1e-10);
+ Assertions.assertEquals(1,
+ LogBinomialCoefficient.value(n, k) / Math.log(exactResult), 1e-10, n + " choose " + k);
}
}
}
@@ -101,6 +101,6 @@ public class LogBinomialCoefficientTest {
final int n = 10000;
final double actualOverExpected = LogBinomialCoefficient.value(n, 3) /
Math.log(BinomialCoefficientTest.binomialCoefficient(n, 3));
- Assert.assertEquals(1, actualOverExpected, 1e-10);
+ Assertions.assertEquals(1, actualOverExpected, 1e-10);
}
}
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 534a2bb..3840626 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
@@ -41,8 +41,8 @@ public class LogFactorialTest {
// "LogGamma" class.
for (int i = 21; i < 10000; i++) {
final double expected = LogGamma.value(i + 1);
- Assert.assertEquals(i + "! ",
- expected, f.value(i), 0d);
+ Assertions.assertEquals(
+ expected, f.value(i), 0d, i + "! ");
}
}
@@ -56,8 +56,8 @@ public class LogFactorialTest {
for (int i = 0; i < max; i++) {
final double expected = logFactorial(i);
- Assert.assertEquals(i + "! ",
- expected, f.value(i), 2 * Math.ulp(expected));
+ Assertions.assertEquals(
+ expected, f.value(i), 2 * Math.ulp(expected), i + "! ");
}
}
@@ -68,8 +68,8 @@ public class LogFactorialTest {
for (int i = 0; i < max; i++) {
final double expected = logFactorial(i);
- Assert.assertEquals(i + "! ",
- expected, f.value(i), 0d);
+ Assertions.assertEquals(
+ expected, f.value(i), 0d, i + "! ");
}
}
@@ -77,8 +77,8 @@ public class LogFactorialTest {
public void testZeroCache() {
// Ensure that no exception is thrown.
final LogFactorial f = LogFactorial.create().withCache(0);
- Assert.assertEquals(0, f.value(0), 0d);
- Assert.assertEquals(0, f.value(1), 0d);
+ Assertions.assertEquals(0, f.value(0), 0d);
+ Assertions.assertEquals(0, f.value(1), 0d);
}
@Test
@@ -96,7 +96,7 @@ public class LogFactorialTest {
final int val = max + max / 2;
final double expected = logFactorial(val);
- Assert.assertEquals(expected, f2.value(val), 0d);
+ Assertions.assertEquals(expected, f2.value(val), 0d);
}
@Test
@@ -107,7 +107,7 @@ public class LogFactorialTest {
final int val = max / 4;
final double expected = logFactorial(val);
- Assert.assertEquals(expected, f2.value(val), 0d);
+ Assertions.assertEquals(expected, f2.value(val), 0d);
}
// Direct implementation.
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 0f154b9..81a0c0a 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
@@ -29,13 +29,13 @@ import org.junit.jupiter.api.Test;
public class BigFractionTest {
private void assertFraction(int expectedNumerator, int expectedDenominator, BigFraction actual) {
- Assert.assertEquals(expectedNumerator, actual.getNumeratorAsInt());
- Assert.assertEquals(expectedDenominator, actual.getDenominatorAsInt());
+ Assertions.assertEquals(expectedNumerator, actual.getNumeratorAsInt());
+ Assertions.assertEquals(expectedDenominator, actual.getDenominatorAsInt());
}
private void assertFraction(long expectedNumerator, long expectedDenominator, BigFraction actual) {
- Assert.assertEquals(expectedNumerator, actual.getNumeratorAsLong());
- Assert.assertEquals(expectedDenominator, actual.getDenominatorAsLong());
+ Assertions.assertEquals(expectedNumerator, actual.getNumeratorAsLong());
+ Assertions.assertEquals(expectedDenominator, actual.getDenominatorAsLong());
}
@Test
@@ -57,32 +57,32 @@ public class BigFractionTest {
assertFraction(2, 5, BigFraction.from(0.40000000000001, 1.0e-5, 100));
assertFraction(15, 1, BigFraction.from(15.0000000000001, 1.0e-5, 100));
- Assert.assertEquals(0.00000000000001, BigFraction.from(0.00000000000001).doubleValue(), 0.0);
- Assert.assertEquals(0.40000000000001, BigFraction.from(0.40000000000001).doubleValue(), 0.0);
- Assert.assertEquals(15.0000000000001, BigFraction.from(15.0000000000001).doubleValue(), 0.0);
+ Assertions.assertEquals(0.00000000000001, BigFraction.from(0.00000000000001).doubleValue(), 0.0);
+ Assertions.assertEquals(0.40000000000001, BigFraction.from(0.40000000000001).doubleValue(), 0.0);
+ Assertions.assertEquals(15.0000000000001, BigFraction.from(15.0000000000001).doubleValue(), 0.0);
assertFraction(3602879701896487l, 9007199254740992l, BigFraction.from(0.40000000000001));
assertFraction(1055531162664967l, 70368744177664l, BigFraction.from(15.0000000000001));
try {
BigFraction.of(null, BigInteger.ONE);
- Assert.fail("Expecting NullPointerException");
+ Assertions.fail("Expecting NullPointerException");
} catch (NullPointerException npe) {
// expected
}
try {
BigFraction.of(BigInteger.ONE, null);
- Assert.fail("Expecting NullPointerException");
+ Assertions.fail("Expecting NullPointerException");
} catch (NullPointerException npe) {
// expected
}
try {
BigFraction.of(BigInteger.ONE, BigInteger.ZERO);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ignored) {
// expected
}
try {
BigFraction.from(2.0 * Integer.MAX_VALUE, 1.0e-5, 100000);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ignored) {
// expected
}
@@ -192,19 +192,19 @@ public class BigFractionTest {
BigFraction second = BigFraction.of(1, 3);
BigFraction third = BigFraction.of(1, 2);
- Assert.assertEquals(0, first.compareTo(first));
- Assert.assertEquals(0, first.compareTo(third));
- Assert.assertEquals(1, first.compareTo(second));
- Assert.assertEquals(-1, second.compareTo(first));
+ Assertions.assertEquals(0, first.compareTo(first));
+ Assertions.assertEquals(0, first.compareTo(third));
+ Assertions.assertEquals(1, first.compareTo(second));
+ Assertions.assertEquals(-1, second.compareTo(first));
// these two values are different approximations of PI
// the first one is approximately PI - 3.07e-18
// the second one is approximately PI + 1.936e-17
BigFraction pi1 = BigFraction.of(1068966896, 340262731);
BigFraction pi2 = BigFraction.of( 411557987, 131002976);
- Assert.assertEquals(-1, pi1.compareTo(pi2));
- Assert.assertEquals( 1, pi2.compareTo(pi1));
- Assert.assertEquals(0.0, pi1.doubleValue() - pi2.doubleValue(), 1.0e-20);
+ Assertions.assertEquals(-1, pi1.compareTo(pi2));
+ Assertions.assertEquals( 1, pi2.compareTo(pi1));
+ Assertions.assertEquals(0.0, pi1.doubleValue() - pi2.doubleValue(), 1.0e-20);
}
@@ -213,8 +213,8 @@ public class BigFractionTest {
BigFraction first = BigFraction.of(1, 2);
BigFraction second = BigFraction.of(1, 3);
- Assert.assertEquals(0.5, first.doubleValue(), 0.0);
- Assert.assertEquals(1.0 / 3.0, second.doubleValue(), 0.0);
+ Assertions.assertEquals(0.5, first.doubleValue(), 0.0);
+ Assertions.assertEquals(1.0 / 3.0, second.doubleValue(), 0.0);
}
// MATH-744
@@ -226,7 +226,7 @@ public class BigFractionTest {
final BigFraction large = BigFraction.of(pow401.add(BigInteger.ONE),
pow400.multiply(two));
- Assert.assertEquals(5, large.doubleValue(), 1e-15);
+ Assertions.assertEquals(5, large.doubleValue(), 1e-15);
}
// MATH-744
@@ -238,7 +238,7 @@ public class BigFractionTest {
final BigFraction large = BigFraction.of(pow401.add(BigInteger.ONE),
pow400.multiply(two));
- Assert.assertEquals(5, large.floatValue(), 1e-15);
+ Assertions.assertEquals(5, large.floatValue(), 1e-15);
}
// NUMBERS-15
@@ -249,7 +249,7 @@ public class BigFractionTest {
final BigFraction large = BigFraction.of(pow330.add(BigInteger.ONE),
pow300);
- Assert.assertEquals(1e30, large.doubleValue(), 1e-15);
+ Assertions.assertEquals(1e30, large.doubleValue(), 1e-15);
}
// NUMBERS-15
@@ -260,7 +260,7 @@ public class BigFractionTest {
final BigFraction large = BigFraction.of(pow40.add(BigInteger.ONE),
pow30);
- Assert.assertEquals(1e10f, large.floatValue(), 1e-15);
+ Assertions.assertEquals(1e10f, large.floatValue(), 1e-15);
}
@Test
@@ -268,8 +268,8 @@ public class BigFractionTest {
BigFraction first = BigFraction.of(1, 2);
BigFraction second = BigFraction.of(1, 3);
- Assert.assertEquals(0.5f, first.floatValue(), 0.0f);
- Assert.assertEquals((float) (1.0 / 3.0), second.floatValue(), 0.0f);
+ Assertions.assertEquals(0.5f, first.floatValue(), 0.0f);
+ Assertions.assertEquals((float) (1.0 / 3.0), second.floatValue(), 0.0f);
}
@Test
@@ -277,8 +277,8 @@ public class BigFractionTest {
BigFraction first = BigFraction.of(1, 2);
BigFraction second = BigFraction.of(3, 2);
- Assert.assertEquals(0, first.intValue());
- Assert.assertEquals(1, second.intValue());
+ Assertions.assertEquals(0, first.intValue());
+ Assertions.assertEquals(1, second.intValue());
}
@Test
@@ -286,8 +286,8 @@ public class BigFractionTest {
BigFraction first = BigFraction.of(1, 2);
BigFraction second = BigFraction.of(3, 2);
- Assert.assertEquals(0L, first.longValue());
- Assert.assertEquals(1L, second.longValue());
+ Assertions.assertEquals(0L, first.longValue());
+ Assertions.assertEquals(1L, second.longValue());
}
@Test
@@ -303,14 +303,14 @@ public class BigFractionTest {
for (double v : new double[] { Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}) {
try {
BigFraction.from(v);
- Assert.fail("Expecting IllegalArgumentException");
+ Assertions.fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException iae) {
// expected
}
}
- Assert.assertEquals(1l, BigFraction.from(Double.MAX_VALUE).getDenominatorAsLong());
- Assert.assertEquals(1l, BigFraction.from(Double.longBitsToDouble(0x0010000000000000L)).getNumeratorAsLong());
- Assert.assertEquals(1l, BigFraction.from(Double.MIN_VALUE).getNumeratorAsLong());
+ Assertions.assertEquals(1l, BigFraction.from(Double.MAX_VALUE).getDenominatorAsLong());
+ Assertions.assertEquals(1l, BigFraction.from(Double.longBitsToDouble(0x0010000000000000L)).getNumeratorAsLong());
+ Assertions.assertEquals(1l, BigFraction.from(Double.MIN_VALUE).getNumeratorAsLong());
}
@Test
@@ -330,31 +330,31 @@ public class BigFractionTest {
f = BigFraction.of(50, 75);
f = f.reciprocal();
- Assert.assertEquals(3, f.getNumeratorAsInt());
- Assert.assertEquals(2, f.getDenominatorAsInt());
+ Assertions.assertEquals(3, f.getNumeratorAsInt());
+ Assertions.assertEquals(2, f.getDenominatorAsInt());
f = BigFraction.of(4, 3);
f = f.reciprocal();
- Assert.assertEquals(3, f.getNumeratorAsInt());
- Assert.assertEquals(4, f.getDenominatorAsInt());
+ Assertions.assertEquals(3, f.getNumeratorAsInt());
+ Assertions.assertEquals(4, f.getDenominatorAsInt());
f = BigFraction.of(-15, 47);
f = f.reciprocal();
- Assert.assertEquals(-47, f.getNumeratorAsInt());
- Assert.assertEquals(15, f.getDenominatorAsInt());
+ Assertions.assertEquals(-47, f.getNumeratorAsInt());
+ Assertions.assertEquals(15, f.getDenominatorAsInt());
f = BigFraction.of(0, 3);
try {
f = f.reciprocal();
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ignored) {
}
// large values
f = BigFraction.of(Integer.MAX_VALUE, 1);
f = f.reciprocal();
- Assert.assertEquals(1, f.getNumeratorAsInt());
- Assert.assertEquals(Integer.MAX_VALUE, f.getDenominatorAsInt());
+ Assertions.assertEquals(1, f.getNumeratorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getDenominatorAsInt());
}
@Test
@@ -363,19 +363,19 @@ public class BigFractionTest {
f = BigFraction.of(50, 75);
f = f.negate();
- Assert.assertEquals(-2, f.getNumeratorAsInt());
- Assert.assertEquals(3, f.getDenominatorAsInt());
+ Assertions.assertEquals(-2, f.getNumeratorAsInt());
+ Assertions.assertEquals(3, f.getDenominatorAsInt());
f = BigFraction.of(-50, 75);
f = f.negate();
- Assert.assertEquals(2, f.getNumeratorAsInt());
- Assert.assertEquals(3, f.getDenominatorAsInt());
+ Assertions.assertEquals(2, f.getNumeratorAsInt());
+ Assertions.assertEquals(3, f.getDenominatorAsInt());
// large values
f = BigFraction.of(Integer.MAX_VALUE - 1, Integer.MAX_VALUE);
f = f.negate();
- Assert.assertEquals(Integer.MIN_VALUE + 2, f.getNumeratorAsInt());
- Assert.assertEquals(Integer.MAX_VALUE, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MIN_VALUE + 2, f.getNumeratorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getDenominatorAsInt());
}
@@ -392,18 +392,18 @@ public class BigFractionTest {
BigFraction f1 = BigFraction.of(Integer.MAX_VALUE - 1, 1);
BigFraction f2 = BigFraction.ONE;
BigFraction f = f1.add(f2);
- Assert.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
f1 = BigFraction.of(-1, 13 * 13 * 2 * 2);
f2 = BigFraction.of(-2, 13 * 17 * 2);
f = f1.add(f2);
- Assert.assertEquals(13 * 13 * 17 * 2 * 2, f.getDenominatorAsInt());
- Assert.assertEquals(-17 - 2 * 13 * 2, f.getNumeratorAsInt());
+ Assertions.assertEquals(13 * 13 * 17 * 2 * 2, f.getDenominatorAsInt());
+ Assertions.assertEquals(-17 - 2 * 13 * 2, f.getNumeratorAsInt());
try {
f.add((BigFraction) null);
- Assert.fail("expecting NullPointerException");
+ Assertions.fail("expecting NullPointerException");
} catch (NullPointerException ex) {
}
@@ -412,41 +412,41 @@ public class BigFractionTest {
f1 = BigFraction.of(1, 32768 * 3);
f2 = BigFraction.of(1, 59049);
f = f1.add(f2);
- Assert.assertEquals(52451, f.getNumeratorAsInt());
- Assert.assertEquals(1934917632, f.getDenominatorAsInt());
+ Assertions.assertEquals(52451, f.getNumeratorAsInt());
+ Assertions.assertEquals(1934917632, f.getDenominatorAsInt());
f1 = BigFraction.of(Integer.MIN_VALUE, 3);
f2 = BigFraction.of(1, 3);
f = f1.add(f2);
- Assert.assertEquals(Integer.MIN_VALUE + 1, f.getNumeratorAsInt());
- Assert.assertEquals(3, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MIN_VALUE + 1, f.getNumeratorAsInt());
+ Assertions.assertEquals(3, f.getDenominatorAsInt());
f1 = BigFraction.of(Integer.MAX_VALUE - 1, 1);
f = f1.add(BigInteger.ONE);
- Assert.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
f = f.add(BigInteger.ZERO);
- Assert.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
f1 = BigFraction.of(Integer.MAX_VALUE - 1, 1);
f = f1.add(1);
- Assert.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
f = f.add(0);
- Assert.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
f1 = BigFraction.of(Integer.MAX_VALUE - 1, 1);
f = f1.add(1l);
- Assert.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
f = f.add(0l);
- Assert.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
}
@@ -464,52 +464,52 @@ public class BigFractionTest {
BigFraction f2 = BigFraction.ZERO;
try {
f1.divide(f2);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {
}
f1 = BigFraction.of(0, 5);
f2 = BigFraction.of(2, 7);
BigFraction f = f1.divide(f2);
- Assert.assertSame(BigFraction.ZERO, f);
+ Assertions.assertSame(BigFraction.ZERO, f);
f1 = BigFraction.of(2, 7);
f2 = BigFraction.ONE;
f = f1.divide(f2);
- Assert.assertEquals(2, f.getNumeratorAsInt());
- Assert.assertEquals(7, f.getDenominatorAsInt());
+ Assertions.assertEquals(2, f.getNumeratorAsInt());
+ Assertions.assertEquals(7, f.getDenominatorAsInt());
f1 = BigFraction.of(1, Integer.MAX_VALUE);
f = f1.divide(f1);
- Assert.assertEquals(1, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(1, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
f1 = BigFraction.of(Integer.MIN_VALUE, Integer.MAX_VALUE);
f2 = BigFraction.of(1, Integer.MAX_VALUE);
f = f1.divide(f2);
- Assert.assertEquals(Integer.MIN_VALUE, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MIN_VALUE, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
try {
f.divide((BigFraction) null);
- Assert.fail("expecting NullPointerException");
+ Assertions.fail("expecting NullPointerException");
} catch (NullPointerException ex) {
}
f1 = BigFraction.of(Integer.MIN_VALUE, Integer.MAX_VALUE);
f = f1.divide(BigInteger.valueOf(Integer.MIN_VALUE));
- Assert.assertEquals(Integer.MAX_VALUE, f.getDenominatorAsInt());
- Assert.assertEquals(1, f.getNumeratorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getDenominatorAsInt());
+ Assertions.assertEquals(1, f.getNumeratorAsInt());
f1 = BigFraction.of(Integer.MIN_VALUE, Integer.MAX_VALUE);
f = f1.divide(Integer.MIN_VALUE);
- Assert.assertEquals(Integer.MAX_VALUE, f.getDenominatorAsInt());
- Assert.assertEquals(1, f.getNumeratorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getDenominatorAsInt());
+ Assertions.assertEquals(1, f.getNumeratorAsInt());
f1 = BigFraction.of(Integer.MIN_VALUE, Integer.MAX_VALUE);
f = f1.divide((long) Integer.MIN_VALUE);
- Assert.assertEquals(Integer.MAX_VALUE, f.getDenominatorAsInt());
- Assert.assertEquals(1, f.getNumeratorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getDenominatorAsInt());
+ Assertions.assertEquals(1, f.getNumeratorAsInt());
}
@@ -526,20 +526,20 @@ public class BigFractionTest {
BigFraction f1 = BigFraction.of(Integer.MAX_VALUE, 1);
BigFraction f2 = BigFraction.of(Integer.MIN_VALUE, Integer.MAX_VALUE);
BigFraction f = f1.multiply(f2);
- Assert.assertEquals(Integer.MIN_VALUE, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MIN_VALUE, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
f = f2.multiply(Integer.MAX_VALUE);
- Assert.assertEquals(Integer.MIN_VALUE, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MIN_VALUE, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
f = f2.multiply((long) Integer.MAX_VALUE);
- Assert.assertEquals(Integer.MIN_VALUE, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MIN_VALUE, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
try {
f.multiply((BigFraction) null);
- Assert.fail("expecting NullPointerException");
+ Assertions.fail("expecting NullPointerException");
} catch (NullPointerException ex) {
}
@@ -558,7 +558,7 @@ public class BigFractionTest {
BigFraction f = BigFraction.of(1, 1);
try {
f.subtract((BigFraction) null);
- Assert.fail("expecting NullPointerException");
+ Assertions.fail("expecting NullPointerException");
} catch (NullPointerException ex) {
}
@@ -567,29 +567,29 @@ public class BigFractionTest {
BigFraction f1 = BigFraction.of(1, 32768 * 3);
BigFraction f2 = BigFraction.of(1, 59049);
f = f1.subtract(f2);
- Assert.assertEquals(-13085, f.getNumeratorAsInt());
- Assert.assertEquals(1934917632, f.getDenominatorAsInt());
+ Assertions.assertEquals(-13085, f.getNumeratorAsInt());
+ Assertions.assertEquals(1934917632, f.getDenominatorAsInt());
f1 = BigFraction.of(Integer.MIN_VALUE, 3);
f2 = BigFraction.of(1, 3).negate();
f = f1.subtract(f2);
- Assert.assertEquals(Integer.MIN_VALUE + 1, f.getNumeratorAsInt());
- Assert.assertEquals(3, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MIN_VALUE + 1, f.getNumeratorAsInt());
+ Assertions.assertEquals(3, f.getDenominatorAsInt());
f1 = BigFraction.of(Integer.MAX_VALUE, 1);
f2 = BigFraction.ONE;
f = f1.subtract(f2);
- Assert.assertEquals(Integer.MAX_VALUE - 1, f.getNumeratorAsInt());
- Assert.assertEquals(1, f.getDenominatorAsInt());
+ Assertions.assertEquals(Integer.MAX_VALUE - 1, f.getNumeratorAsInt());
+ Assertions.assertEquals(1, f.getDenominatorAsInt());
}
@Test
public void testBigDecimalValue() {
- Assert.assertEquals(new BigDecimal(0.5), BigFraction.of(1, 2).bigDecimalValue());
- Assert.assertEquals(new BigDecimal("0.0003"), BigFraction.of(3, 10000).bigDecimalValue());
- Assert.assertEquals(new BigDecimal("0"), BigFraction.of(1, 3).bigDecimalValue(RoundingMode.DOWN));
- Assert.assertEquals(new BigDecimal("0.333"), BigFraction.of(1, 3).bigDecimalValue(3, RoundingMode.DOWN));
+ 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));
+ Assertions.assertEquals(new BigDecimal("0.333"), BigFraction.of(1, 3).bigDecimalValue(3, RoundingMode.DOWN));
}
@Test
@@ -601,9 +601,9 @@ public class BigFractionTest {
Assert.assertNotEquals(zero, Double.valueOf(0), 0.0);
BigFraction zero2 = BigFraction.of(0, 2);
Assert.assertEquals(zero, zero2);
- Assert.assertEquals(zero.hashCode(), zero2.hashCode());
+ Assertions.assertEquals(zero.hashCode(), zero2.hashCode());
BigFraction one = BigFraction.of(1, 1);
- Assert.assertFalse((one.equals(zero) || zero.equals(one)));
+ Assertions.assertFalse((one.equals(zero) || zero.equals(one)));
Assert.assertEquals(one, BigFraction.ONE);
}
@@ -614,25 +614,25 @@ public class BigFractionTest {
Assert.assertEquals(BigFraction.ZERO, BigFraction.getReducedFraction(0, -1));
try {
BigFraction.getReducedFraction(1, 0);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {
// expected
}
- Assert.assertEquals(-1, BigFraction.getReducedFraction(2, Integer.MIN_VALUE).getNumeratorAsInt());
- Assert.assertEquals(-1, BigFraction.getReducedFraction(1, -1).getNumeratorAsInt());
+ Assertions.assertEquals(-1, BigFraction.getReducedFraction(2, Integer.MIN_VALUE).getNumeratorAsInt());
+ Assertions.assertEquals(-1, BigFraction.getReducedFraction(1, -1).getNumeratorAsInt());
}
@Test
public void testPow() {
- Assert.assertEquals(BigFraction.of(8192, 1594323), BigFraction.of(2, 3).pow(13));
- Assert.assertEquals(BigFraction.of(8192, 1594323), BigFraction.of(2, 3).pow(13l));
- Assert.assertEquals(BigFraction.of(8192, 1594323), BigFraction.of(2, 3).pow(BigInteger.valueOf(13l)));
- Assert.assertEquals(BigFraction.ONE, BigFraction.of(2, 3).pow(0));
- Assert.assertEquals(BigFraction.ONE, BigFraction.of(2, 3).pow(0l));
- Assert.assertEquals(BigFraction.ONE, BigFraction.of(2, 3).pow(BigInteger.valueOf(0l)));
- Assert.assertEquals(BigFraction.of(1594323, 8192), BigFraction.of(2, 3).pow(-13));
- Assert.assertEquals(BigFraction.of(1594323, 8192), BigFraction.of(2, 3).pow(-13l));
- Assert.assertEquals(BigFraction.of(1594323, 8192), BigFraction.of(2, 3).pow(BigInteger.valueOf(-13l)));
+ Assertions.assertEquals(BigFraction.of(8192, 1594323), BigFraction.of(2, 3).pow(13));
+ Assertions.assertEquals(BigFraction.of(8192, 1594323), BigFraction.of(2, 3).pow(13l));
+ Assertions.assertEquals(BigFraction.of(8192, 1594323), BigFraction.of(2, 3).pow(BigInteger.valueOf(13l)));
+ Assertions.assertEquals(BigFraction.ONE, BigFraction.of(2, 3).pow(0));
+ Assertions.assertEquals(BigFraction.ONE, BigFraction.of(2, 3).pow(0l));
+ Assertions.assertEquals(BigFraction.ONE, BigFraction.of(2, 3).pow(BigInteger.valueOf(0l)));
+ Assertions.assertEquals(BigFraction.of(1594323, 8192), BigFraction.of(2, 3).pow(-13));
+ Assertions.assertEquals(BigFraction.of(1594323, 8192), BigFraction.of(2, 3).pow(-13l));
+ Assertions.assertEquals(BigFraction.of(1594323, 8192), BigFraction.of(2, 3).pow(BigInteger.valueOf(-13l)));
}
@Test
@@ -642,7 +642,7 @@ public class BigFractionTest {
BigFraction errorResult = fractionA.multiply(fractionB);
BigFraction correctResult = BigFraction.of(fractionA.getNumerator().multiply(fractionB.getNumerator()),
fractionA.getDenominator().multiply(fractionB.getDenominator()));
- Assert.assertEquals(correctResult, errorResult);
+ Assertions.assertEquals(correctResult, errorResult);
}
@Test
@@ -653,7 +653,7 @@ public class BigFractionTest {
BigFraction.of(-5, 2)
};
for (BigFraction fraction : fractions) {
- Assert.assertEquals(fraction, TestUtils.serializeAndRecover(fraction));
+ Assertions.assertEquals(fraction, TestUtils.serializeAndRecover(fraction));
}
}
@@ -675,7 +675,7 @@ public class BigFractionTest {
};
int inc = 0;
for (BigFraction fraction: fractions) {
- Assert.assertEquals(fraction,
+ Assertions.assertEquals(fraction,
BigFraction.parse(validExpressions[inc]));
inc++;
}
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 2943340..42abd6d 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
@@ -17,6 +17,7 @@
package org.apache.commons.numbers.fraction;
import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -41,7 +42,7 @@ public class ContinuedFractionTest {
final double eps = 1e-8;
double gr = cf.evaluate(0, eps);
- Assert.assertEquals(1.61803399, gr, eps);
+ Assertions.assertEquals(1.61803399, gr, eps);
}
// NUMBERS-46
@@ -61,7 +62,7 @@ public class ContinuedFractionTest {
final double eps = 10;
double gr = cf.evaluate(0, eps, 1);
- Assert.assertEquals(1.61, gr, eps);
+ Assertions.assertEquals(1.61, gr, eps);
}
// NUMBERS-46
@@ -81,6 +82,6 @@ public class ContinuedFractionTest {
final double eps = 0.5;
double gr = cf.evaluate(0, eps, 2);
- Assert.assertEquals(1.5, gr, 0d);
+ Assertions.assertEquals(1.5, gr, 0d);
}
}
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 0b95245..d36ffaa 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
@@ -27,8 +27,8 @@ import org.junit.jupiter.api.Test;
public class FractionTest {
private void assertFraction(int expectedNumerator, int expectedDenominator, Fraction actual) {
- Assert.assertEquals(expectedNumerator, actual.getNumerator());
- Assert.assertEquals(expectedDenominator, actual.getDenominator());
+ Assertions.assertEquals(expectedNumerator, actual.getNumerator());
+ Assertions.assertEquals(expectedDenominator, actual.getDenominator());
}
@Test
@@ -46,13 +46,13 @@ public class FractionTest {
// overflow
try {
Fraction.of(Integer.MIN_VALUE, -1);
- Assert.fail();
+ Assertions.fail();
} catch (ArithmeticException ex) {
// success
}
try {
Fraction.of(1, Integer.MIN_VALUE);
- Assert.fail();
+ Assertions.fail();
} catch (ArithmeticException ex) {
// success
}
@@ -145,7 +145,7 @@ public class FractionTest {
@SuppressWarnings("unused")
Fraction f = Fraction.from(a, 1.0e-12, 1000);
//System.out.println(f.getNumerator() + "/" + f.getDenominator());
- Assert.fail("an exception should have been thrown");
+ Assertions.fail("an exception should have been thrown");
} catch (ArithmeticException ignored) {
// expected behavior
}
@@ -169,19 +169,19 @@ public class FractionTest {
Fraction second = Fraction.of(1, 3);
Fraction third = Fraction.of(1, 2);
- Assert.assertEquals(0, first.compareTo(first));
- Assert.assertEquals(0, first.compareTo(third));
- Assert.assertEquals(1, first.compareTo(second));
- Assert.assertEquals(-1, second.compareTo(first));
+ Assertions.assertEquals(0, first.compareTo(first));
+ Assertions.assertEquals(0, first.compareTo(third));
+ Assertions.assertEquals(1, first.compareTo(second));
+ Assertions.assertEquals(-1, second.compareTo(first));
// these two values are different approximations of PI
// the first one is approximately PI - 3.07e-18
// the second one is approximately PI + 1.936e-17
Fraction pi1 = Fraction.of(1068966896, 340262731);
Fraction pi2 = Fraction.of( 411557987, 131002976);
- Assert.assertEquals(-1, pi1.compareTo(pi2));
- Assert.assertEquals( 1, pi2.compareTo(pi1));
- Assert.assertEquals(0.0, pi1.doubleValue() - pi2.doubleValue(), 1.0e-20);
+ Assertions.assertEquals(-1, pi1.compareTo(pi2));
+ Assertions.assertEquals( 1, pi2.compareTo(pi1));
+ Assertions.assertEquals(0.0, pi1.doubleValue() - pi2.doubleValue(), 1.0e-20);
}
@Test
@@ -189,8 +189,8 @@ public class FractionTest {
Fraction first = Fraction.of(1, 2);
Fraction second = Fraction.of(1, 3);
- Assert.assertEquals(0.5, first.doubleValue(), 0.0);
- Assert.assertEquals(1.0 / 3.0, second.doubleValue(), 0.0);
+ Assertions.assertEquals(0.5, first.doubleValue(), 0.0);
+ Assertions.assertEquals(1.0 / 3.0, second.doubleValue(), 0.0);
}
@Test
@@ -198,8 +198,8 @@ public class FractionTest {
Fraction first = Fraction.of(1, 2);
Fraction second = Fraction.of(1, 3);
- Assert.assertEquals(0.5f, first.floatValue(), 0.0f);
- Assert.assertEquals((float)(1.0 / 3.0), second.floatValue(), 0.0f);
+ Assertions.assertEquals(0.5f, first.floatValue(), 0.0f);
+ Assertions.assertEquals((float)(1.0 / 3.0), second.floatValue(), 0.0f);
}
@Test
@@ -207,8 +207,8 @@ public class FractionTest {
Fraction first = Fraction.of(1, 2);
Fraction second = Fraction.of(3, 2);
- Assert.assertEquals(0, first.intValue());
- Assert.assertEquals(1, second.intValue());
+ Assertions.assertEquals(0, first.intValue());
+ Assertions.assertEquals(1, second.intValue());
}
@Test
@@ -216,8 +216,8 @@ public class FractionTest {
Fraction first = Fraction.of(1, 2);
Fraction second = Fraction.of(3, 2);
- Assert.assertEquals(0L, first.longValue());
- Assert.assertEquals(1L, second.longValue());
+ Assertions.assertEquals(0L, first.longValue());
+ Assertions.assertEquals(1L, second.longValue());
}
@Test
@@ -260,30 +260,30 @@ public class FractionTest {
f = Fraction.of(50, 75);
f = f.reciprocal();
- Assert.assertEquals(3, f.getNumerator());
- Assert.assertEquals(2, f.getDenominator());
+ Assertions.assertEquals(3, f.getNumerator());
+ Assertions.assertEquals(2, f.getDenominator());
f = Fraction.of(4, 3);
f = f.reciprocal();
- Assert.assertEquals(3, f.getNumerator());
- Assert.assertEquals(4, f.getDenominator());
+ Assertions.assertEquals(3, f.getNumerator());
+ Assertions.assertEquals(4, f.getDenominator());
f = Fraction.of(-15, 47);
f = f.reciprocal();
- Assert.assertEquals(-47, f.getNumerator());
- Assert.assertEquals(15, f.getDenominator());
+ Assertions.assertEquals(-47, f.getNumerator());
+ Assertions.assertEquals(15, f.getDenominator());
f = Fraction.of(0, 3);
try {
f = f.reciprocal();
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ignored) {}
// large values
f = Fraction.of(Integer.MAX_VALUE, 1);
f = f.reciprocal();
- Assert.assertEquals(1, f.getNumerator());
- Assert.assertEquals(Integer.MAX_VALUE, f.getDenominator());
+ Assertions.assertEquals(1, f.getNumerator());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getDenominator());
}
@Test
@@ -292,24 +292,24 @@ public class FractionTest {
f = Fraction.of(50, 75);
f = f.negate();
- Assert.assertEquals(-2, f.getNumerator());
- Assert.assertEquals(3, f.getDenominator());
+ Assertions.assertEquals(-2, f.getNumerator());
+ Assertions.assertEquals(3, f.getDenominator());
f = Fraction.of(-50, 75);
f = f.negate();
- Assert.assertEquals(2, f.getNumerator());
- Assert.assertEquals(3, f.getDenominator());
+ Assertions.assertEquals(2, f.getNumerator());
+ Assertions.assertEquals(3, f.getDenominator());
// large values
f = Fraction.of(Integer.MAX_VALUE-1, Integer.MAX_VALUE);
f = f.negate();
- Assert.assertEquals(Integer.MIN_VALUE+2, f.getNumerator());
- Assert.assertEquals(Integer.MAX_VALUE, f.getDenominator());
+ Assertions.assertEquals(Integer.MIN_VALUE+2, f.getNumerator());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getDenominator());
f = Fraction.of(Integer.MIN_VALUE, 1);
try {
f = f.negate();
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
}
@@ -326,21 +326,21 @@ public class FractionTest {
Fraction f1 = Fraction.of(Integer.MAX_VALUE - 1, 1);
Fraction f2 = Fraction.ONE;
Fraction f = f1.add(f2);
- Assert.assertEquals(Integer.MAX_VALUE, f.getNumerator());
- Assert.assertEquals(1, f.getDenominator());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getNumerator());
+ Assertions.assertEquals(1, f.getDenominator());
f = f1.add(1);
- Assert.assertEquals(Integer.MAX_VALUE, f.getNumerator());
- Assert.assertEquals(1, f.getDenominator());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getNumerator());
+ Assertions.assertEquals(1, f.getDenominator());
f1 = Fraction.of(-1, 13*13*2*2);
f2 = Fraction.of(-2, 13*17*2);
f = f1.add(f2);
- Assert.assertEquals(13*13*17*2*2, f.getDenominator());
- Assert.assertEquals(-17 - 2*13*2, f.getNumerator());
+ Assertions.assertEquals(13*13*17*2*2, f.getDenominator());
+ Assertions.assertEquals(-17 - 2*13*2, f.getNumerator());
try {
f.add(null);
- Assert.fail("expecting NullArgumentException");
+ Assertions.fail("expecting NullArgumentException");
} catch (NullPointerException ex) {}
// if this fraction is added naively, it will overflow.
@@ -348,24 +348,24 @@ public class FractionTest {
f1 = Fraction.of(1,32768*3);
f2 = Fraction.of(1,59049);
f = f1.add(f2);
- Assert.assertEquals(52451, f.getNumerator());
- Assert.assertEquals(1934917632, f.getDenominator());
+ Assertions.assertEquals(52451, f.getNumerator());
+ Assertions.assertEquals(1934917632, f.getDenominator());
f1 = Fraction.of(Integer.MIN_VALUE, 3);
f2 = Fraction.of(1,3);
f = f1.add(f2);
- Assert.assertEquals(Integer.MIN_VALUE+1, f.getNumerator());
- Assert.assertEquals(3, f.getDenominator());
+ Assertions.assertEquals(Integer.MIN_VALUE+1, f.getNumerator());
+ Assertions.assertEquals(3, f.getDenominator());
f1 = Fraction.of(Integer.MAX_VALUE - 1, 1);
f2 = Fraction.ONE;
f = f1.add(f2);
- Assert.assertEquals(Integer.MAX_VALUE, f.getNumerator());
- Assert.assertEquals(1, f.getDenominator());
+ Assertions.assertEquals(Integer.MAX_VALUE, f.getNumerator());
+ Assertions.assertEquals(1, f.getDenominator());
try {
f = f.add(Fraction.ONE); // should overflow
- Assert.fail("expecting ArithmeticException but got: " + f.toString());
+ Assertions.fail("expecting ArithmeticException but got: " + f.toString());
} catch (ArithmeticException ex) {}
// denominator should not be a multiple of 2 or 3 to trigger overflow
@@ -373,26 +373,26 @@ public class FractionTest {
f2 = Fraction.of(-1,5);
try {
f = f1.add(f2); // should overflow
- Assert.fail("expecting ArithmeticException but got: " + f.toString());
+ Assertions.fail("expecting ArithmeticException but got: " + f.toString());
} catch (ArithmeticException ex) {}
try {
f= Fraction.of(-Integer.MAX_VALUE, 1);
f = f.add(f);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
try {
f= Fraction.of(-Integer.MAX_VALUE, 1);
f = f.add(f);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
f1 = Fraction.of(3,327680);
f2 = Fraction.of(2,59049);
try {
f = f1.add(f2); // should overflow
- Assert.fail("expecting ArithmeticException but got: " + f.toString());
+ Assertions.fail("expecting ArithmeticException but got: " + f.toString());
} catch (ArithmeticException ex) {}
}
@@ -410,51 +410,51 @@ public class FractionTest {
Fraction f2 = Fraction.ZERO;
try {
f1.divide(f2);
- Assert.fail("expecting FractionException");
+ Assertions.fail("expecting FractionException");
} catch (FractionException ex) {}
f1 = Fraction.of(0, 5);
f2 = Fraction.of(2, 7);
Fraction f = f1.divide(f2);
- Assert.assertSame(Fraction.ZERO, f);
+ Assertions.assertSame(Fraction.ZERO, f);
f1 = Fraction.of(2, 7);
f2 = Fraction.ONE;
f = f1.divide(f2);
- Assert.assertEquals(2, f.getNumerator());
- Assert.assertEquals(7, f.getDenominator());
+ Assertions.assertEquals(2, f.getNumerator());
+ Assertions.assertEquals(7, f.getDenominator());
f1 = Fraction.of(1, Integer.MAX_VALUE);
f = f1.divide(f1);
- Assert.assertEquals(1, f.getNumerator());
- Assert.assertEquals(1, f.getDenominator());
+ Assertions.assertEquals(1, f.getNumerator());
+ Assertions.assertEquals(1, f.getDenominator());
f1 = Fraction.of(Integer.MIN_VALUE, Integer.MAX_VALUE);
f2 = Fraction.of(1, Integer.MAX_VALUE);
f = f1.divide(f2);
- Assert.assertEquals(Integer.MIN_VALUE, f.getNumerator());
- Assert.assertEquals(1, f.getDenominator());
+ Assertions.assertEquals(Integer.MIN_VALUE, f.getNumerator());
+ Assertions.assertEquals(1, f.getDenominator());
try {
f.divide(null);
- Assert.fail("NullArgumentException");
+ Assertions.fail("NullArgumentException");
} catch (NullPointerException ex) {}
try {
f1 = Fraction.of(1, Integer.MAX_VALUE);
f = f1.divide(f1.reciprocal()); // should overflow
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
try {
f1 = Fraction.of(1, -Integer.MAX_VALUE);
f = f1.divide(f1.reciprocal()); // should overflow
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
f1 = Fraction.of(6, 35);
f = f1.divide(15);
- Assert.assertEquals(2, f.getNumerator());
- Assert.assertEquals(175, f.getDenominator());
+ Assertions.assertEquals(2, f.getNumerator());
+ Assertions.assertEquals(175, f.getDenominator());
}
@@ -471,18 +471,18 @@ public class FractionTest {
Fraction f1 = Fraction.of(Integer.MAX_VALUE, 1);
Fraction f2 = Fraction.of(Integer.MIN_VALUE, Integer.MAX_VALUE);
Fraction f = f1.multiply(f2);
- Assert.assertEquals(Integer.MIN_VALUE, f.getNumerator());
- Assert.assertEquals(1, f.getDenominator());
+ Assertions.assertEquals(Integer.MIN_VALUE, f.getNumerator());
+ Assertions.assertEquals(1, f.getDenominator());
try {
f.multiply(null);
- Assert.fail("expecting NullArgumentException");
+ Assertions.fail("expecting NullArgumentException");
} catch (NullPointerException ex) {}
f1 = Fraction.of(6, 35);
f = f1.multiply(15);
- Assert.assertEquals(18, f.getNumerator());
- Assert.assertEquals(7, f.getDenominator());
+ Assertions.assertEquals(18, f.getNumerator());
+ Assertions.assertEquals(7, f.getDenominator());
}
@Test
@@ -518,7 +518,7 @@ public class FractionTest {
Fraction f = Fraction.of(1,1);
try {
f.subtract(null);
- Assert.fail("expecting NullArgumentException");
+ Assertions.fail("expecting NullArgumentException");
} catch (NullPointerException ex) {}
// if this fraction is subtracted naively, it will overflow.
@@ -526,29 +526,29 @@ public class FractionTest {
Fraction f1 = Fraction.of(1,32768*3);
Fraction f2 = Fraction.of(1,59049);
f = f1.subtract(f2);
- Assert.assertEquals(-13085, f.getNumerator());
- Assert.assertEquals(1934917632, f.getDenominator());
+ Assertions.assertEquals(-13085, f.getNumerator());
+ Assertions.assertEquals(1934917632, f.getDenominator());
f1 = Fraction.of(Integer.MIN_VALUE, 3);
f2 = Fraction.of(1,3).negate();
f = f1.subtract(f2);
- Assert.assertEquals(Integer.MIN_VALUE+1, f.getNumerator());
- Assert.assertEquals(3, f.getDenominator());
+ Assertions.assertEquals(Integer.MIN_VALUE+1, f.getNumerator());
+ Assertions.assertEquals(3, f.getDenominator());
f1 = Fraction.of(Integer.MAX_VALUE, 1);
f2 = Fraction.ONE;
f = f1.subtract(f2);
- Assert.assertEquals(Integer.MAX_VALUE-1, f.getNumerator());
- Assert.assertEquals(1, f.getDenominator());
+ Assertions.assertEquals(Integer.MAX_VALUE-1, f.getNumerator());
+ Assertions.assertEquals(1, f.getDenominator());
f = f1.subtract(1);
- Assert.assertEquals(Integer.MAX_VALUE-1, f.getNumerator());
- Assert.assertEquals(1, f.getDenominator());
+ Assertions.assertEquals(Integer.MAX_VALUE-1, f.getNumerator());
+ Assertions.assertEquals(1, f.getDenominator());
try {
f1 = Fraction.of(1, Integer.MAX_VALUE);
f2 = Fraction.of(1, Integer.MAX_VALUE - 1);
f = f1.subtract(f2);
- Assert.fail("expecting ArithmeticException"); //should overflow
+ Assertions.fail("expecting ArithmeticException"); //should overflow
} catch (ArithmeticException ex) {}
// denominator should not be a multiple of 2 or 3 to trigger overflow
@@ -556,26 +556,26 @@ public class FractionTest {
f2 = Fraction.of(1,5);
try {
f = f1.subtract(f2); // should overflow
- Assert.fail("expecting ArithmeticException but got: " + f.toString());
+ Assertions.fail("expecting ArithmeticException but got: " + f.toString());
} catch (ArithmeticException ex) {}
try {
f= Fraction.of(Integer.MIN_VALUE, 1);
f = f.subtract(Fraction.ONE);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
try {
f= Fraction.of(Integer.MAX_VALUE, 1);
f = f.subtract(Fraction.ONE.negate());
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {}
f1 = Fraction.of(3,327680);
f2 = Fraction.of(2,59049);
try {
f = f1.subtract(f2); // should overflow
- Assert.fail("expecting ArithmeticException but got: " + f.toString());
+ Assertions.fail("expecting ArithmeticException but got: " + f.toString());
} catch (ArithmeticException ex) {}
}
@@ -588,9 +588,9 @@ public class FractionTest {
Assert.assertNotEquals(zero, Double.valueOf(0), 0.0);
Fraction zero2 = Fraction.of(0,2);
Assert.assertEquals(zero, zero2);
- Assert.assertEquals(zero.hashCode(), zero2.hashCode());
+ Assertions.assertEquals(zero.hashCode(), zero2.hashCode());
Fraction one = Fraction.of(1,1);
- Assert.assertFalse((one.equals(zero) ||zero.equals(one)));
+ Assertions.assertFalse((one.equals(zero) ||zero.equals(one)));
}
@Test
@@ -600,23 +600,23 @@ public class FractionTest {
Assert.assertEquals(Fraction.ZERO, Fraction.getReducedFraction(0, -1));
try {
Fraction.getReducedFraction(1, 0);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException ignored) {
// expected
}
- Assert.assertEquals(-1, Fraction.getReducedFraction
+ Assertions.assertEquals(-1, Fraction.getReducedFraction
(2, Integer.MIN_VALUE).getNumerator());
- Assert.assertEquals(-1, Fraction.getReducedFraction
+ Assertions.assertEquals(-1, Fraction.getReducedFraction
(1, -1).getNumerator());
}
@Test
public void testToString() {
- Assert.assertEquals("0", Fraction.of(0, 3).toString());
- Assert.assertEquals("3", Fraction.of(6, 2).toString());
- Assert.assertEquals("2 / 3", Fraction.of(18, 27).toString());
- Assert.assertEquals("-10 / 11", Fraction.of(-10, 11).toString());
- Assert.assertEquals("-10 / 11", Fraction.of(10, -11).toString());
+ Assertions.assertEquals("0", Fraction.of(0, 3).toString());
+ Assertions.assertEquals("3", Fraction.of(6, 2).toString());
+ Assertions.assertEquals("2 / 3", Fraction.of(18, 27).toString());
+ Assertions.assertEquals("-10 / 11", Fraction.of(-10, 11).toString());
+ Assertions.assertEquals("-10 / 11", Fraction.of(10, -11).toString());
}
@Test
@@ -627,7 +627,7 @@ public class FractionTest {
Fraction.of(-5, 2)
};
for (Fraction fraction : fractions) {
- Assert.assertEquals(fraction, TestUtils.serializeAndRecover(fraction));
+ Assertions.assertEquals(fraction, TestUtils.serializeAndRecover(fraction));
}
}
@@ -644,7 +644,7 @@ public class FractionTest {
};
int inc = 0;
for (Fraction fraction: fractions) {
- Assert.assertEquals(fraction,
+ Assertions.assertEquals(fraction,
Fraction.parse(validExpressions[inc]));
inc++;
}
[commons-numbers] 10/34: Migrate commons-numbers-core to JUnit 5:
class TestUtils (previously overlooked)
Posted by er...@apache.org.
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 <he...@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());
}
}
[commons-numbers] 05/34: Revert "BigFraction: use factory method"
Posted by er...@apache.org.
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 888e00e5c12d814670a6bd0ef4fd3bafd9cff780
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Fri Jun 7 19:05:03 2019 -0700
Revert "BigFraction: use factory method"
This reverts commit 3d5fab4fefecd75a672f0e316231d26b66bcdf98.
---
.../numbers/arrays/LinearCombinationTest.java | 24 +++++++++++-----------
1 file changed, 12 insertions(+), 12 deletions(-)
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 3919198..51d210e 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
@@ -35,15 +35,15 @@ public class LinearCombinationTest {
@Test
public void testTwoSums() {
- final BigFraction[] aF = {
- BigFraction.of(-1321008684645961L, 268435456L),
- BigFraction.of(-5774608829631843L, 268435456L),
- BigFraction.of(-7645843051051357L, 8589934592L)
+ final BigFraction[] aF = new BigFraction[] {
+ new BigFraction(-1321008684645961L, 268435456L),
+ new BigFraction(-5774608829631843L, 268435456L),
+ new BigFraction(-7645843051051357L, 8589934592L)
};
- final BigFraction[] bF = {
- BigFraction.of(-5712344449280879L, 2097152L),
- BigFraction.of(-4550117129121957L, 2097152L),
- BigFraction.of(8846951984510141L, 131072L)
+ final BigFraction[] bF = new BigFraction[] {
+ new BigFraction(-5712344449280879L, 2097152L),
+ new BigFraction(-4550117129121957L, 2097152L),
+ new BigFraction(8846951984510141L, 131072L)
};
final int len = aF.length;
@@ -113,12 +113,12 @@ public class LinearCombinationTest {
@Test
public void testHuge() {
int scale = 971;
- final double[] a = {
+ final double[] a = new double[] {
-1321008684645961.0 / 268435456.0,
-5774608829631843.0 / 268435456.0,
-7645843051051357.0 / 8589934592.0
};
- final double[] b = {
+ final double[] b = new double[] {
-5712344449280879.0 / 2097152.0,
-4550117129121957.0 / 2097152.0,
8846951984510141.0 / 131072.0
@@ -145,7 +145,7 @@ public class LinearCombinationTest {
@Test
public void testInfinite() {
- final double[][] a = {
+ final double[][] a = new double[][] {
{ 1, 2, 3, 4 },
{ 1, Double.POSITIVE_INFINITY, 3, 4 },
{ 1, 2, Double.POSITIVE_INFINITY, 4 },
@@ -155,7 +155,7 @@ public class LinearCombinationTest {
{ 1, 2, 3, 4 },
{ 1, 2, 3, 4 }
};
- final double[][] b = {
+ final double[][] b = new double[][] {
{ 1, -2, 3, 4 },
{ 1, -2, 3, 4 },
{ 1, -2, 3, 4 },
[commons-numbers] 04/34: BigFraction: use factory method
Posted by er...@apache.org.
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 3d5fab4fefecd75a672f0e316231d26b66bcdf98
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Fri Jun 7 05:16:31 2019 -0700
BigFraction: use factory method
---
.../numbers/arrays/LinearCombinationTest.java | 24 +++++++++++-----------
1 file changed, 12 insertions(+), 12 deletions(-)
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 51d210e..3919198 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
@@ -35,15 +35,15 @@ public class LinearCombinationTest {
@Test
public void testTwoSums() {
- final BigFraction[] aF = new BigFraction[] {
- new BigFraction(-1321008684645961L, 268435456L),
- new BigFraction(-5774608829631843L, 268435456L),
- new BigFraction(-7645843051051357L, 8589934592L)
+ final BigFraction[] aF = {
+ BigFraction.of(-1321008684645961L, 268435456L),
+ BigFraction.of(-5774608829631843L, 268435456L),
+ BigFraction.of(-7645843051051357L, 8589934592L)
};
- final BigFraction[] bF = new BigFraction[] {
- new BigFraction(-5712344449280879L, 2097152L),
- new BigFraction(-4550117129121957L, 2097152L),
- new BigFraction(8846951984510141L, 131072L)
+ final BigFraction[] bF = {
+ BigFraction.of(-5712344449280879L, 2097152L),
+ BigFraction.of(-4550117129121957L, 2097152L),
+ BigFraction.of(8846951984510141L, 131072L)
};
final int len = aF.length;
@@ -113,12 +113,12 @@ public class LinearCombinationTest {
@Test
public void testHuge() {
int scale = 971;
- final double[] a = new double[] {
+ final double[] a = {
-1321008684645961.0 / 268435456.0,
-5774608829631843.0 / 268435456.0,
-7645843051051357.0 / 8589934592.0
};
- final double[] b = new double[] {
+ final double[] b = {
-5712344449280879.0 / 2097152.0,
-4550117129121957.0 / 2097152.0,
8846951984510141.0 / 131072.0
@@ -145,7 +145,7 @@ public class LinearCombinationTest {
@Test
public void testInfinite() {
- final double[][] a = new double[][] {
+ final double[][] a = {
{ 1, 2, 3, 4 },
{ 1, Double.POSITIVE_INFINITY, 3, 4 },
{ 1, 2, Double.POSITIVE_INFINITY, 4 },
@@ -155,7 +155,7 @@ public class LinearCombinationTest {
{ 1, 2, 3, 4 },
{ 1, 2, 3, 4 }
};
- final double[][] b = new double[][] {
+ final double[][] b = {
{ 1, -2, 3, 4 },
{ 1, -2, 3, 4 },
{ 1, -2, 3, 4 },
[commons-numbers] 11/34: Merge branch 'master' of
http://gitbox.apache.org/repos/asf/commons-numbers into
eax/simple-migrate-map
Posted by er...@apache.org.
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 ab5d960ee0fd2f03bf516699793f687d7c309047
Merge: ad2d928 9243140
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Sat Jun 8 17:34:50 2019 -0700
Merge branch 'master' of http://gitbox.apache.org/repos/asf/commons-numbers into eax/simple-migrate-map
.../commons/numbers/fraction/BigFraction.java | 25 +-
commons-numbers-rootfinder/LICENSE.txt | 201 ++++++++++++++++
commons-numbers-rootfinder/NOTICE.txt | 5 +
commons-numbers-rootfinder/README.md | 98 ++++++++
commons-numbers-rootfinder/pom.xml | 52 ++++
.../commons/numbers/rootfinder/BrentSolver.java | 239 ++++++++++++++++++
.../numbers/rootfinder/SolverException.java | 55 +++++
.../commons/numbers/rootfinder/package-info.java | 20 ++
.../src/site/resources/profile.jacoco | 17 ++
commons-numbers-rootfinder/src/site/site.xml | 35 +++
commons-numbers-rootfinder/src/site/xdoc/index.xml | 40 ++++
.../numbers/rootfinder/BrentSolverTest.java | 266 +++++++++++++++++++++
.../numbers/rootfinder/MonitoredFunction.java | 52 ++++
.../numbers/rootfinder/QuinticFunction.java | 29 +++
.../org/apache/commons/numbers/rootfinder/Sin.java | 29 +++
pom.xml | 1 +
16 files changed, 1152 insertions(+), 12 deletions(-)
diff --cc commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
index 476972b,538dc8d..eff4c83
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
@@@ -267,10 -267,10 +267,10 @@@ public class BigFraction extends Numbe
* @param num the numerator, must not be {@code null}.
* @param den the denominator, must not be {@code null}.
* @throws ArithmeticException if the denominator is zero.
- * @return {@link BigFraction instance
+ * @return a new instance.
*/
public static BigFraction of(BigInteger num, BigInteger den) {
- return new BigFraction(num, den);
+ return new BigFraction(num, den);
}
/**
@@@ -290,13 -290,13 +290,13 @@@
* because the double number passed to the constructor is not exactly 1/3
* (this number cannot be stored exactly in IEEE754).
* </p>
- * @see #BigFraction(double, double, int)
+ * @see BigFraction#from(double, double, int)
* @param value the double value to convert to a fraction.
* @exception IllegalArgumentException if value is NaN or infinite
- * @return {@link BigFraction instance
+ * @return a new instance.
*/
public static BigFraction from(final double value) throws IllegalArgumentException {
- return new BigFraction(value);
+ return new BigFraction(value);
}
/**
[commons-numbers] 24/34: One more step
Posted by er...@apache.org.
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 74c8a9c753fc531c96eb6a9263adc4e3aa9aef96
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Sun Jun 9 22:44:41 2019 -0700
One more step
---
.../java/org/apache/commons/numbers/angle/PlaneAngleTest.java | 6 +++---
.../java/org/apache/commons/numbers/fraction/Fraction.java | 2 +-
.../org/apache/commons/numbers/quaternion/QuaternionTest.java | 8 ++++----
.../org/apache/commons/numbers/rootfinder/BrentSolverTest.java | 10 +++++-----
4 files changed, 13 insertions(+), 13 deletions(-)
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 54ddddd..98e315a 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
@@ -162,20 +162,20 @@ public class PlaneAngleTest {
final double value = 12345.6789;
final PlaneAngle a = PlaneAngle.ofRadians(value);
final PlaneAngle b = PlaneAngle.ofRadians(value);
- Assert.assertEquals(a, b);
+ Assertions.assertEquals(a, b);
}
@Test
public void testEquals2() {
final PlaneAngle a = PlaneAngle.ofRadians(153768.373486587);
final PlaneAngle b = null;
- Assert.assertNotEquals(a, b);
+ Assertions.assertNotEquals(b, a);
}
@Test
public void testEquals3() {
final double value = 0.987654321;
final PlaneAngle a = PlaneAngle.ofRadians(value);
final PlaneAngle b = PlaneAngle.ofRadians(value + 1e-16);
- Assert.assertNotEquals(a, b);
+ Assertions.assertNotEquals(a, b);
}
@Test
diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
index 74beb3b..fad2d50 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
@@ -286,7 +286,7 @@ public class Fraction
public int compareTo(Fraction object) {
long nOd = ((long) numerator) * object.denominator;
long dOn = ((long) denominator) * object.numerator;
- return (nOd < dOn) ? -1 : ((nOd > dOn) ? +1 : 0);
+ return (nOd < dOn) ? -1 : ((nOd > dOn) ? +1 : 0);
}
/**
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 31e6852..b2f7a82 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
@@ -35,16 +35,16 @@ public class QuaternionTest {
@Test
public void testUnitQuaternions() {
Assertions.assertEquals(1, Quaternion.ONE.norm(), 0d);
- Assertions.assertSame(Quaternion.ONE.normalize(), Quaternion.ONE);
+ Assertions.assertSame(Quaternion.ONE, Quaternion.ONE.normalize());
Assertions.assertEquals(1, Quaternion.I.norm(), 0d);
- Assertions.assertSame(Quaternion.I.normalize(), Quaternion.I);
+ Assertions.assertSame(Quaternion.I, Quaternion.I.normalize());
Assertions.assertEquals(1, Quaternion.J.norm(), 0d);
- Assertions.assertSame(Quaternion.J.normalize(), Quaternion.J);
+ Assertions.assertSame(Quaternion.J, Quaternion.J.normalize());
Assertions.assertEquals(1, Quaternion.K.norm(), 0d);
- Assertions.assertSame(Quaternion.K.normalize(), Quaternion.K);
+ Assertions.assertSame(Quaternion.K, Quaternion.K.normalize());
}
@Test
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 8dd5a4f..ef1ee7d 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
@@ -159,7 +159,7 @@ public class BrentSolverTest {
} catch (IllegalStateException ex) {
// Expected.
// Ensure expected error condition.
- Assertions.assertNotEquals(ex.getMessage().indexOf("too many calls"), -1);
+ Assertions.assertNotEquals(-1, ex.getMessage().indexOf("too many calls"));
}
}
@@ -195,21 +195,21 @@ public class BrentSolverTest {
Assertions.fail("Expecting bad interval condition");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assertions.assertNotEquals(ex.getMessage().indexOf(" > "), -1);
+ Assertions.assertNotEquals(-1, ex.getMessage().indexOf(" > "));
}
try { // No bracketing.
solver.findRoot(f, 1, 1.5);
Assertions.fail("Expecting non-bracketing condition");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assertions.assertNotEquals(ex.getMessage().indexOf("No bracketing"), -1);
+ Assertions.assertNotEquals(-1, ex.getMessage().indexOf("No bracketing"));
}
try { // No bracketing.
solver.findRoot(f, 1, 1.2, 1.5);
Assertions.fail("Expecting non-bracketing condition");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assertions.assertNotEquals(ex.getMessage().indexOf("No bracketing"), -1);
+ Assertions.assertNotEquals(-1, ex.getMessage().indexOf("No bracketing"));
}
}
@@ -226,7 +226,7 @@ public class BrentSolverTest {
Assertions.fail("an out of range condition was expected");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assertions.assertNotEquals(ex.getMessage().indexOf("out of range"), -1);
+ Assertions.assertNotEquals(-1, ex.getMessage().indexOf("out of range"));
}
}
[commons-numbers] 27/34: Correct parameter order in assertEquals
Posted by er...@apache.org.
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 e12bf62531bb1edb7c2d8fcd5c85cab486c631ca
Author: Schamschi <he...@gmx.at>
AuthorDate: Tue Jun 11 17:19:38 2019 +0200
Correct parameter order in assertEquals
---
.../java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java | 2 +-
.../java/org/apache/commons/numbers/primes/SmallPrimesTest.java | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
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 ea4fd30..f23fe2d 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
@@ -559,7 +559,7 @@ public class ArithmeticUtilsTest {
}
for (int i = 0; i < expected.length; i++) {
final boolean actual = ArithmeticUtils.isPowerOfTwo(i);
- Assertions.assertEquals(actual, expected[i], Integer.toString(i));
+ Assertions.assertEquals(expected[i], actual, Integer.toString(i));
}
}
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 a4fdab5..06023c5 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
@@ -59,7 +59,7 @@ public class SmallPrimesTest {
final int penultimatePrime = SmallPrimes.PRIMES[SmallPrimes.PRIMES.length-2];
final int result = SmallPrimes.smallTrialDivision(penultimatePrime*SmallPrimes.PRIMES_LAST, factors);
Assertions.assertEquals(1, result);
- Assertions.assertEquals(factors, Arrays.asList(penultimatePrime, SmallPrimes.PRIMES_LAST));
+ Assertions.assertEquals(Arrays.asList(penultimatePrime, SmallPrimes.PRIMES_LAST), factors);
}
@Test
@@ -83,7 +83,7 @@ public class SmallPrimesTest {
final List<Integer> factors = new ArrayList<Integer>();
final int result = SmallPrimes.boundedTrialDivision(LARGE_PRIME[0]*LARGE_PRIME[1], Integer.MAX_VALUE, factors);
Assertions.assertEquals(LARGE_PRIME[1], result);
- Assertions.assertEquals(factors, Arrays.asList(LARGE_PRIME[0], LARGE_PRIME[1]));
+ Assertions.assertEquals(Arrays.asList(LARGE_PRIME[0], LARGE_PRIME[1]), factors);
}
@Test
@@ -91,7 +91,7 @@ public class SmallPrimesTest {
final List<Integer> factors = new ArrayList<Integer>();
final int result = SmallPrimes.boundedTrialDivision(LARGE_PRIME[0]*LARGE_PRIME[0], Integer.MAX_VALUE, factors);
Assertions.assertEquals(LARGE_PRIME[0], result);
- Assertions.assertEquals(factors, Arrays.asList(LARGE_PRIME[0], LARGE_PRIME[0]));
+ Assertions.assertEquals(Arrays.asList(LARGE_PRIME[0], LARGE_PRIME[0]), factors);
}
@Test
[commons-numbers] 09/34: Migrate commons-numbers-core to JUnit 5
Posted by er...@apache.org.
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 d952ad52c5ed69377d4df3565d2c861c9992f150
Author: Schamschi <he...@gmx.at>
AuthorDate: Sat Jun 8 23:04:48 2019 +0200
Migrate commons-numbers-core to JUnit 5
Migrate the following classes:
ArithmeticUtilsTest
PrecisionTest
---
.../commons/numbers/core/ArithmeticUtilsTest.java | 361 +++++++++--------
.../apache/commons/numbers/core/PrecisionTest.java | 446 ++++++++++-----------
2 files changed, 403 insertions(+), 404 deletions(-)
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 72ba8f3..1ff7937 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
@@ -20,7 +20,6 @@ import java.util.Arrays;
import java.math.BigInteger;
import java.util.Collections;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -34,15 +33,15 @@ public class ArithmeticUtilsTest {
public void testAddAndCheck() {
int big = Integer.MAX_VALUE;
int bigNeg = Integer.MIN_VALUE;
- Assert.assertEquals(big, ArithmeticUtils.addAndCheck(big, 0));
+ Assertions.assertEquals(big, ArithmeticUtils.addAndCheck(big, 0));
try {
ArithmeticUtils.addAndCheck(big, 1);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {
}
try {
ArithmeticUtils.addAndCheck(bigNeg, -1);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {
}
}
@@ -51,15 +50,15 @@ public class ArithmeticUtilsTest {
public void testAddAndCheckLong() {
long max = Long.MAX_VALUE;
long min = Long.MIN_VALUE;
- Assert.assertEquals(max, ArithmeticUtils.addAndCheck(max, 0L));
- Assert.assertEquals(min, ArithmeticUtils.addAndCheck(min, 0L));
- Assert.assertEquals(max, ArithmeticUtils.addAndCheck(0L, max));
- Assert.assertEquals(min, ArithmeticUtils.addAndCheck(0L, min));
- Assert.assertEquals(1, ArithmeticUtils.addAndCheck(-1L, 2L));
- Assert.assertEquals(1, ArithmeticUtils.addAndCheck(2L, -1L));
- Assert.assertEquals(-3, ArithmeticUtils.addAndCheck(-2L, -1L));
- Assert.assertEquals(min, ArithmeticUtils.addAndCheck(min + 1, -1L));
- Assert.assertEquals(-1, ArithmeticUtils.addAndCheck(min, max));
+ Assertions.assertEquals(max, ArithmeticUtils.addAndCheck(max, 0L));
+ Assertions.assertEquals(min, ArithmeticUtils.addAndCheck(min, 0L));
+ Assertions.assertEquals(max, ArithmeticUtils.addAndCheck(0L, max));
+ Assertions.assertEquals(min, ArithmeticUtils.addAndCheck(0L, min));
+ Assertions.assertEquals(1, ArithmeticUtils.addAndCheck(-1L, 2L));
+ Assertions.assertEquals(1, ArithmeticUtils.addAndCheck(2L, -1L));
+ Assertions.assertEquals(-3, ArithmeticUtils.addAndCheck(-2L, -1L));
+ Assertions.assertEquals(min, ArithmeticUtils.addAndCheck(min + 1, -1L));
+ Assertions.assertEquals(-1, ArithmeticUtils.addAndCheck(min, max));
testAddAndCheckLongFailure(max, 1L);
testAddAndCheckLongFailure(min, -1L);
testAddAndCheckLongFailure(1L, max);
@@ -74,46 +73,46 @@ public class ArithmeticUtilsTest {
int b = 50;
int c = 77;
- Assert.assertEquals(0, ArithmeticUtils.gcd(0, 0));
+ Assertions.assertEquals(0, ArithmeticUtils.gcd(0, 0));
- Assert.assertEquals(b, ArithmeticUtils.gcd(0, b));
- Assert.assertEquals(a, ArithmeticUtils.gcd(a, 0));
- Assert.assertEquals(b, ArithmeticUtils.gcd(0, -b));
- Assert.assertEquals(a, ArithmeticUtils.gcd(-a, 0));
+ Assertions.assertEquals(b, ArithmeticUtils.gcd(0, b));
+ Assertions.assertEquals(a, ArithmeticUtils.gcd(a, 0));
+ Assertions.assertEquals(b, ArithmeticUtils.gcd(0, -b));
+ Assertions.assertEquals(a, ArithmeticUtils.gcd(-a, 0));
- Assert.assertEquals(10, ArithmeticUtils.gcd(a, b));
- Assert.assertEquals(10, ArithmeticUtils.gcd(-a, b));
- Assert.assertEquals(10, ArithmeticUtils.gcd(a, -b));
- Assert.assertEquals(10, ArithmeticUtils.gcd(-a, -b));
+ Assertions.assertEquals(10, ArithmeticUtils.gcd(a, b));
+ Assertions.assertEquals(10, ArithmeticUtils.gcd(-a, b));
+ Assertions.assertEquals(10, ArithmeticUtils.gcd(a, -b));
+ Assertions.assertEquals(10, ArithmeticUtils.gcd(-a, -b));
- Assert.assertEquals(1, ArithmeticUtils.gcd(a, c));
- Assert.assertEquals(1, ArithmeticUtils.gcd(-a, c));
- Assert.assertEquals(1, ArithmeticUtils.gcd(a, -c));
- Assert.assertEquals(1, ArithmeticUtils.gcd(-a, -c));
+ Assertions.assertEquals(1, ArithmeticUtils.gcd(a, c));
+ Assertions.assertEquals(1, ArithmeticUtils.gcd(-a, c));
+ Assertions.assertEquals(1, ArithmeticUtils.gcd(a, -c));
+ Assertions.assertEquals(1, ArithmeticUtils.gcd(-a, -c));
- Assert.assertEquals(3 * (1<<15), ArithmeticUtils.gcd(3 * (1<<20), 9 * (1<<15)));
+ Assertions.assertEquals(3 * (1<<15), ArithmeticUtils.gcd(3 * (1<<20), 9 * (1<<15)));
- Assert.assertEquals(Integer.MAX_VALUE, ArithmeticUtils.gcd(Integer.MAX_VALUE, 0));
- Assert.assertEquals(Integer.MAX_VALUE, ArithmeticUtils.gcd(-Integer.MAX_VALUE, 0));
- Assert.assertEquals(1<<30, ArithmeticUtils.gcd(1<<30, -Integer.MIN_VALUE));
+ Assertions.assertEquals(Integer.MAX_VALUE, ArithmeticUtils.gcd(Integer.MAX_VALUE, 0));
+ Assertions.assertEquals(Integer.MAX_VALUE, ArithmeticUtils.gcd(-Integer.MAX_VALUE, 0));
+ Assertions.assertEquals(1<<30, ArithmeticUtils.gcd(1<<30, -Integer.MIN_VALUE));
try {
// gcd(Integer.MIN_VALUE, 0) > Integer.MAX_VALUE
ArithmeticUtils.gcd(Integer.MIN_VALUE, 0);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
try {
// gcd(0, Integer.MIN_VALUE) > Integer.MAX_VALUE
ArithmeticUtils.gcd(0, Integer.MIN_VALUE);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
try {
// gcd(Integer.MIN_VALUE, Integer.MIN_VALUE) > Integer.MAX_VALUE
ArithmeticUtils.gcd(Integer.MIN_VALUE, Integer.MIN_VALUE);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
@@ -133,10 +132,10 @@ public class ArithmeticUtilsTest {
int i1 = p1 * p2 * p3;
int i2 = p1 * p2 * p4;
int gcd = p1 * p2;
- Assert.assertEquals(gcd, ArithmeticUtils.gcd(i1, i2));
+ Assertions.assertEquals(gcd, ArithmeticUtils.gcd(i1, i2));
long l1 = i1;
long l2 = i2;
- Assert.assertEquals(gcd, ArithmeticUtils.gcd(l1, l2));
+ Assertions.assertEquals(gcd, ArithmeticUtils.gcd(l1, l2));
}
}
@@ -146,48 +145,48 @@ public class ArithmeticUtilsTest {
long b = 50;
long c = 77;
- Assert.assertEquals(0, ArithmeticUtils.gcd(0L, 0));
+ Assertions.assertEquals(0, ArithmeticUtils.gcd(0L, 0));
- Assert.assertEquals(b, ArithmeticUtils.gcd(0, b));
- Assert.assertEquals(a, ArithmeticUtils.gcd(a, 0));
- Assert.assertEquals(b, ArithmeticUtils.gcd(0, -b));
- Assert.assertEquals(a, ArithmeticUtils.gcd(-a, 0));
+ Assertions.assertEquals(b, ArithmeticUtils.gcd(0, b));
+ Assertions.assertEquals(a, ArithmeticUtils.gcd(a, 0));
+ Assertions.assertEquals(b, ArithmeticUtils.gcd(0, -b));
+ Assertions.assertEquals(a, ArithmeticUtils.gcd(-a, 0));
- Assert.assertEquals(10, ArithmeticUtils.gcd(a, b));
- Assert.assertEquals(10, ArithmeticUtils.gcd(-a, b));
- Assert.assertEquals(10, ArithmeticUtils.gcd(a, -b));
- Assert.assertEquals(10, ArithmeticUtils.gcd(-a, -b));
+ Assertions.assertEquals(10, ArithmeticUtils.gcd(a, b));
+ Assertions.assertEquals(10, ArithmeticUtils.gcd(-a, b));
+ Assertions.assertEquals(10, ArithmeticUtils.gcd(a, -b));
+ Assertions.assertEquals(10, ArithmeticUtils.gcd(-a, -b));
- Assert.assertEquals(1, ArithmeticUtils.gcd(a, c));
- Assert.assertEquals(1, ArithmeticUtils.gcd(-a, c));
- Assert.assertEquals(1, ArithmeticUtils.gcd(a, -c));
- Assert.assertEquals(1, ArithmeticUtils.gcd(-a, -c));
+ Assertions.assertEquals(1, ArithmeticUtils.gcd(a, c));
+ Assertions.assertEquals(1, ArithmeticUtils.gcd(-a, c));
+ Assertions.assertEquals(1, ArithmeticUtils.gcd(a, -c));
+ Assertions.assertEquals(1, ArithmeticUtils.gcd(-a, -c));
- Assert.assertEquals(3L * (1L<<45), ArithmeticUtils.gcd(3L * (1L<<50), 9L * (1L<<45)));
+ Assertions.assertEquals(3L * (1L<<45), ArithmeticUtils.gcd(3L * (1L<<50), 9L * (1L<<45)));
- Assert.assertEquals(1L<<45, ArithmeticUtils.gcd(1L<<45, Long.MIN_VALUE));
+ Assertions.assertEquals(1L<<45, ArithmeticUtils.gcd(1L<<45, Long.MIN_VALUE));
- Assert.assertEquals(Long.MAX_VALUE, ArithmeticUtils.gcd(Long.MAX_VALUE, 0L));
- Assert.assertEquals(Long.MAX_VALUE, ArithmeticUtils.gcd(-Long.MAX_VALUE, 0L));
- Assert.assertEquals(1, ArithmeticUtils.gcd(60247241209L, 153092023L));
+ Assertions.assertEquals(Long.MAX_VALUE, ArithmeticUtils.gcd(Long.MAX_VALUE, 0L));
+ Assertions.assertEquals(Long.MAX_VALUE, ArithmeticUtils.gcd(-Long.MAX_VALUE, 0L));
+ Assertions.assertEquals(1, ArithmeticUtils.gcd(60247241209L, 153092023L));
try {
// gcd(Long.MIN_VALUE, 0) > Long.MAX_VALUE
ArithmeticUtils.gcd(Long.MIN_VALUE, 0);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
try {
// gcd(0, Long.MIN_VALUE) > Long.MAX_VALUE
ArithmeticUtils.gcd(0, Long.MIN_VALUE);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
try {
// gcd(Long.MIN_VALUE, Long.MIN_VALUE) > Long.MAX_VALUE
ArithmeticUtils.gcd(Long.MIN_VALUE, Long.MIN_VALUE);
- Assert.fail("expecting ArithmeticException");
+ Assertions.fail("expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
@@ -200,27 +199,27 @@ public class ArithmeticUtilsTest {
int b = 50;
int c = 77;
- Assert.assertEquals(0, ArithmeticUtils.lcm(0, b));
- Assert.assertEquals(0, ArithmeticUtils.lcm(a, 0));
- Assert.assertEquals(b, ArithmeticUtils.lcm(1, b));
- Assert.assertEquals(a, ArithmeticUtils.lcm(a, 1));
- Assert.assertEquals(150, ArithmeticUtils.lcm(a, b));
- Assert.assertEquals(150, ArithmeticUtils.lcm(-a, b));
- Assert.assertEquals(150, ArithmeticUtils.lcm(a, -b));
- Assert.assertEquals(150, ArithmeticUtils.lcm(-a, -b));
- Assert.assertEquals(2310, ArithmeticUtils.lcm(a, c));
+ Assertions.assertEquals(0, ArithmeticUtils.lcm(0, b));
+ Assertions.assertEquals(0, ArithmeticUtils.lcm(a, 0));
+ Assertions.assertEquals(b, ArithmeticUtils.lcm(1, b));
+ Assertions.assertEquals(a, ArithmeticUtils.lcm(a, 1));
+ Assertions.assertEquals(150, ArithmeticUtils.lcm(a, b));
+ Assertions.assertEquals(150, ArithmeticUtils.lcm(-a, b));
+ Assertions.assertEquals(150, ArithmeticUtils.lcm(a, -b));
+ Assertions.assertEquals(150, ArithmeticUtils.lcm(-a, -b));
+ Assertions.assertEquals(2310, ArithmeticUtils.lcm(a, c));
// Assert that no intermediate value overflows:
// The naive implementation of lcm(a,b) would be (a*b)/gcd(a,b)
- Assert.assertEquals((1<<20)*15, ArithmeticUtils.lcm((1<<20)*3, (1<<20)*5));
+ Assertions.assertEquals((1<<20)*15, ArithmeticUtils.lcm((1<<20)*3, (1<<20)*5));
// Special case
- Assert.assertEquals(0, ArithmeticUtils.lcm(0, 0));
+ Assertions.assertEquals(0, ArithmeticUtils.lcm(0, 0));
try {
// lcm == abs(MIN_VALUE) cannot be represented as a nonnegative int
ArithmeticUtils.lcm(Integer.MIN_VALUE, 1);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
@@ -228,14 +227,14 @@ public class ArithmeticUtilsTest {
try {
// lcm == abs(MIN_VALUE) cannot be represented as a nonnegative int
ArithmeticUtils.lcm(Integer.MIN_VALUE, 1<<20);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
try {
ArithmeticUtils.lcm(Integer.MAX_VALUE, Integer.MAX_VALUE - 1);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
@@ -247,29 +246,29 @@ public class ArithmeticUtilsTest {
long b = 50;
long c = 77;
- Assert.assertEquals(0, ArithmeticUtils.lcm(0, b));
- Assert.assertEquals(0, ArithmeticUtils.lcm(a, 0));
- Assert.assertEquals(b, ArithmeticUtils.lcm(1, b));
- Assert.assertEquals(a, ArithmeticUtils.lcm(a, 1));
- Assert.assertEquals(150, ArithmeticUtils.lcm(a, b));
- Assert.assertEquals(150, ArithmeticUtils.lcm(-a, b));
- Assert.assertEquals(150, ArithmeticUtils.lcm(a, -b));
- Assert.assertEquals(150, ArithmeticUtils.lcm(-a, -b));
- Assert.assertEquals(2310, ArithmeticUtils.lcm(a, c));
+ Assertions.assertEquals(0, ArithmeticUtils.lcm(0, b));
+ Assertions.assertEquals(0, ArithmeticUtils.lcm(a, 0));
+ Assertions.assertEquals(b, ArithmeticUtils.lcm(1, b));
+ Assertions.assertEquals(a, ArithmeticUtils.lcm(a, 1));
+ Assertions.assertEquals(150, ArithmeticUtils.lcm(a, b));
+ Assertions.assertEquals(150, ArithmeticUtils.lcm(-a, b));
+ Assertions.assertEquals(150, ArithmeticUtils.lcm(a, -b));
+ Assertions.assertEquals(150, ArithmeticUtils.lcm(-a, -b));
+ Assertions.assertEquals(2310, ArithmeticUtils.lcm(a, c));
- Assert.assertEquals(Long.MAX_VALUE, ArithmeticUtils.lcm(60247241209L, 153092023L));
+ Assertions.assertEquals(Long.MAX_VALUE, ArithmeticUtils.lcm(60247241209L, 153092023L));
// Assert that no intermediate value overflows:
// The naive implementation of lcm(a,b) would be (a*b)/gcd(a,b)
- Assert.assertEquals((1L<<50)*15, ArithmeticUtils.lcm((1L<<45)*3, (1L<<50)*5));
+ Assertions.assertEquals((1L<<50)*15, ArithmeticUtils.lcm((1L<<45)*3, (1L<<50)*5));
// Special case
- Assert.assertEquals(0L, ArithmeticUtils.lcm(0L, 0L));
+ Assertions.assertEquals(0L, ArithmeticUtils.lcm(0L, 0L));
try {
// lcm == abs(MIN_VALUE) cannot be represented as a nonnegative int
ArithmeticUtils.lcm(Long.MIN_VALUE, 1);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
@@ -277,16 +276,16 @@ public class ArithmeticUtilsTest {
try {
// lcm == abs(MIN_VALUE) cannot be represented as a nonnegative int
ArithmeticUtils.lcm(Long.MIN_VALUE, 1<<20);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
- Assert.assertEquals((long) Integer.MAX_VALUE * (Integer.MAX_VALUE - 1),
+ Assertions.assertEquals((long) Integer.MAX_VALUE * (Integer.MAX_VALUE - 1),
ArithmeticUtils.lcm((long)Integer.MAX_VALUE, Integer.MAX_VALUE - 1));
try {
ArithmeticUtils.lcm(Long.MAX_VALUE, Long.MAX_VALUE - 1);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException expected) {
// expected
}
@@ -296,15 +295,15 @@ public class ArithmeticUtilsTest {
public void testMulAndCheck() {
int big = Integer.MAX_VALUE;
int bigNeg = Integer.MIN_VALUE;
- Assert.assertEquals(big, ArithmeticUtils.mulAndCheck(big, 1));
+ Assertions.assertEquals(big, ArithmeticUtils.mulAndCheck(big, 1));
try {
ArithmeticUtils.mulAndCheck(big, 2);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {
}
try {
ArithmeticUtils.mulAndCheck(bigNeg, 2);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {
}
}
@@ -313,16 +312,16 @@ public class ArithmeticUtilsTest {
public void testMulAndCheckLong() {
long max = Long.MAX_VALUE;
long min = Long.MIN_VALUE;
- Assert.assertEquals(max, ArithmeticUtils.mulAndCheck(max, 1L));
- Assert.assertEquals(min, ArithmeticUtils.mulAndCheck(min, 1L));
- Assert.assertEquals(0L, ArithmeticUtils.mulAndCheck(max, 0L));
- Assert.assertEquals(0L, ArithmeticUtils.mulAndCheck(min, 0L));
- Assert.assertEquals(max, ArithmeticUtils.mulAndCheck(1L, max));
- Assert.assertEquals(min, ArithmeticUtils.mulAndCheck(1L, min));
- Assert.assertEquals(0L, ArithmeticUtils.mulAndCheck(0L, max));
- Assert.assertEquals(0L, ArithmeticUtils.mulAndCheck(0L, min));
- Assert.assertEquals(1L, ArithmeticUtils.mulAndCheck(-1L, -1L));
- Assert.assertEquals(min, ArithmeticUtils.mulAndCheck(min / 2, 2));
+ Assertions.assertEquals(max, ArithmeticUtils.mulAndCheck(max, 1L));
+ Assertions.assertEquals(min, ArithmeticUtils.mulAndCheck(min, 1L));
+ Assertions.assertEquals(0L, ArithmeticUtils.mulAndCheck(max, 0L));
+ Assertions.assertEquals(0L, ArithmeticUtils.mulAndCheck(min, 0L));
+ Assertions.assertEquals(max, ArithmeticUtils.mulAndCheck(1L, max));
+ Assertions.assertEquals(min, ArithmeticUtils.mulAndCheck(1L, min));
+ Assertions.assertEquals(0L, ArithmeticUtils.mulAndCheck(0L, max));
+ Assertions.assertEquals(0L, ArithmeticUtils.mulAndCheck(0L, min));
+ Assertions.assertEquals(1L, ArithmeticUtils.mulAndCheck(-1L, -1L));
+ Assertions.assertEquals(min, ArithmeticUtils.mulAndCheck(min / 2, 2));
testMulAndCheckLongFailure(max, 2L);
testMulAndCheckLongFailure(2L, max);
testMulAndCheckLongFailure(min, 2L);
@@ -335,17 +334,17 @@ public class ArithmeticUtilsTest {
public void testSubAndCheck() {
int big = Integer.MAX_VALUE;
int bigNeg = Integer.MIN_VALUE;
- Assert.assertEquals(big, ArithmeticUtils.subAndCheck(big, 0));
- Assert.assertEquals(bigNeg + 1, ArithmeticUtils.subAndCheck(bigNeg, -1));
- Assert.assertEquals(-1, ArithmeticUtils.subAndCheck(bigNeg, -big));
+ Assertions.assertEquals(big, ArithmeticUtils.subAndCheck(big, 0));
+ Assertions.assertEquals(bigNeg + 1, ArithmeticUtils.subAndCheck(bigNeg, -1));
+ Assertions.assertEquals(-1, ArithmeticUtils.subAndCheck(bigNeg, -big));
try {
ArithmeticUtils.subAndCheck(big, -1);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {
}
try {
ArithmeticUtils.subAndCheck(bigNeg, 1);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {
}
}
@@ -355,9 +354,9 @@ public class ArithmeticUtilsTest {
int big = Integer.MAX_VALUE;
try {
ArithmeticUtils.subAndCheck(big, -1);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {
- Assert.assertTrue(ex.getMessage().length() > 1);
+ Assertions.assertTrue(ex.getMessage().length() > 1);
}
}
@@ -365,13 +364,13 @@ public class ArithmeticUtilsTest {
public void testSubAndCheckLong() {
long max = Long.MAX_VALUE;
long min = Long.MIN_VALUE;
- Assert.assertEquals(max, ArithmeticUtils.subAndCheck(max, 0));
- Assert.assertEquals(min, ArithmeticUtils.subAndCheck(min, 0));
- Assert.assertEquals(-max, ArithmeticUtils.subAndCheck(0, max));
- Assert.assertEquals(min + 1, ArithmeticUtils.subAndCheck(min, -1));
+ Assertions.assertEquals(max, ArithmeticUtils.subAndCheck(max, 0));
+ Assertions.assertEquals(min, ArithmeticUtils.subAndCheck(min, 0));
+ Assertions.assertEquals(-max, ArithmeticUtils.subAndCheck(0, max));
+ Assertions.assertEquals(min + 1, ArithmeticUtils.subAndCheck(min, -1));
// min == -1-max
- Assert.assertEquals(-1, ArithmeticUtils.subAndCheck(-max - 1, -max));
- Assert.assertEquals(max, ArithmeticUtils.subAndCheck(-1, -1 - max));
+ Assertions.assertEquals(-1, ArithmeticUtils.subAndCheck(-max - 1, -max));
+ Assertions.assertEquals(max, ArithmeticUtils.subAndCheck(-1, -1 - max));
testSubAndCheckLongFailure(0L, min);
testSubAndCheckLongFailure(max, -1L);
testSubAndCheckLongFailure(min, 1L);
@@ -380,57 +379,57 @@ public class ArithmeticUtilsTest {
@Test
public void testPow() {
- Assert.assertEquals(1801088541, ArithmeticUtils.pow(21, 7));
- Assert.assertEquals(1, ArithmeticUtils.pow(21, 0));
+ Assertions.assertEquals(1801088541, ArithmeticUtils.pow(21, 7));
+ Assertions.assertEquals(1, ArithmeticUtils.pow(21, 0));
try {
ArithmeticUtils.pow(21, -7);
- Assert.fail("Expecting IllegalArgumentException");
+ Assertions.fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected behavior
}
- Assert.assertEquals(1801088541, ArithmeticUtils.pow(21, 7));
- Assert.assertEquals(1, ArithmeticUtils.pow(21, 0));
+ Assertions.assertEquals(1801088541, ArithmeticUtils.pow(21, 7));
+ Assertions.assertEquals(1, ArithmeticUtils.pow(21, 0));
try {
ArithmeticUtils.pow(21, -7);
- Assert.fail("Expecting IllegalArgumentException");
+ Assertions.fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected behavior
}
- Assert.assertEquals(1801088541l, ArithmeticUtils.pow(21l, 7));
- Assert.assertEquals(1l, ArithmeticUtils.pow(21l, 0));
+ Assertions.assertEquals(1801088541l, ArithmeticUtils.pow(21l, 7));
+ Assertions.assertEquals(1l, ArithmeticUtils.pow(21l, 0));
try {
ArithmeticUtils.pow(21l, -7);
- Assert.fail("Expecting IllegalArgumentException");
+ Assertions.fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected behavior
}
BigInteger twentyOne = BigInteger.valueOf(21l);
- Assert.assertEquals(BigInteger.valueOf(1801088541l), ArithmeticUtils.pow(twentyOne, 7));
- Assert.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, 0));
+ Assertions.assertEquals(BigInteger.valueOf(1801088541l), ArithmeticUtils.pow(twentyOne, 7));
+ Assertions.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, 0));
try {
ArithmeticUtils.pow(twentyOne, -7);
- Assert.fail("Expecting IllegalArgumentException");
+ Assertions.fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected behavior
}
- Assert.assertEquals(BigInteger.valueOf(1801088541l), ArithmeticUtils.pow(twentyOne, 7l));
- Assert.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, 0l));
+ Assertions.assertEquals(BigInteger.valueOf(1801088541l), ArithmeticUtils.pow(twentyOne, 7l));
+ Assertions.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, 0l));
try {
ArithmeticUtils.pow(twentyOne, -7l);
- Assert.fail("Expecting IllegalArgumentException");
+ Assertions.fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected behavior
}
- Assert.assertEquals(BigInteger.valueOf(1801088541l), ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(7l)));
- Assert.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, BigInteger.ZERO));
+ 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));
- Assert.fail("Expecting IllegalArgumentException");
+ Assertions.fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected behavior
}
@@ -439,13 +438,13 @@ public class ArithmeticUtilsTest {
new BigInteger("1543786922199448028351389769265814882661837148" +
"4763915343722775611762713982220306372888519211" +
"560905579993523402015636025177602059044911261");
- Assert.assertEquals(bigOne, ArithmeticUtils.pow(twentyOne, 103));
- Assert.assertEquals(bigOne, ArithmeticUtils.pow(twentyOne, 103l));
- Assert.assertEquals(bigOne, ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(103l)));
+ Assertions.assertEquals(bigOne, ArithmeticUtils.pow(twentyOne, 103));
+ Assertions.assertEquals(bigOne, ArithmeticUtils.pow(twentyOne, 103l));
+ Assertions.assertEquals(bigOne, ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(103l)));
}
- @Test()
+ @Test
public void testPowIntOverflow() {
Assertions.assertThrows(ArithmeticException.class,
() -> ArithmeticUtils.pow(21, 8)
@@ -456,13 +455,13 @@ public class ArithmeticUtilsTest {
public void testPowInt() {
final int base = 21;
- Assert.assertEquals(85766121L,
+ Assertions.assertEquals(85766121L,
ArithmeticUtils.pow(base, 6));
- Assert.assertEquals(1801088541L,
+ Assertions.assertEquals(1801088541L,
ArithmeticUtils.pow(base, 7));
}
- @Test()
+ @Test
public void testPowNegativeIntOverflow() {
Assertions.assertThrows(ArithmeticException.class,
() -> ArithmeticUtils.pow(-21, 8)
@@ -473,9 +472,9 @@ public class ArithmeticUtilsTest {
public void testPowNegativeInt() {
final int base = -21;
- Assert.assertEquals(85766121,
+ Assertions.assertEquals(85766121,
ArithmeticUtils.pow(base, 6));
- Assert.assertEquals(-1801088541,
+ Assertions.assertEquals(-1801088541,
ArithmeticUtils.pow(base, 7));
}
@@ -484,7 +483,7 @@ public class ArithmeticUtilsTest {
final int base = -1;
for (int i = 0; i < 100; i++) {
final int pow = ArithmeticUtils.pow(base, i);
- Assert.assertEquals("i: " + i, i % 2 == 0 ? 1 : -1, pow);
+ Assertions.assertEquals(i % 2 == 0 ? 1 : -1, pow, "i: " + i);
}
}
@@ -493,11 +492,11 @@ public class ArithmeticUtilsTest {
final int base = 1;
for (int i = 0; i < 100; i++) {
final int pow = ArithmeticUtils.pow(base, i);
- Assert.assertEquals("i: " + i, 1, pow);
+ Assertions.assertEquals(1, pow, "i: " + i);
}
}
- @Test()
+ @Test
public void testPowLongOverflow()
{
Assertions.assertThrows(ArithmeticException.class,
@@ -509,13 +508,13 @@ public class ArithmeticUtilsTest {
public void testPowLong() {
final long base = 21;
- Assert.assertEquals(154472377739119461L,
+ Assertions.assertEquals(154472377739119461L,
ArithmeticUtils.pow(base, 13));
- Assert.assertEquals(3243919932521508681L,
+ Assertions.assertEquals(3243919932521508681L,
ArithmeticUtils.pow(base, 14));
}
- @Test()
+ @Test
public void testPowNegativeLongOverflow() {
Assertions.assertThrows(ArithmeticException.class,
() -> ArithmeticUtils.pow(-21L, 15)
@@ -526,9 +525,9 @@ public class ArithmeticUtilsTest {
public void testPowNegativeLong() {
final long base = -21;
- Assert.assertEquals(-154472377739119461L,
+ Assertions.assertEquals(-154472377739119461L,
ArithmeticUtils.pow(base, 13));
- Assert.assertEquals(3243919932521508681L,
+ Assertions.assertEquals(3243919932521508681L,
ArithmeticUtils.pow(base, 14));
}
@@ -537,7 +536,7 @@ public class ArithmeticUtilsTest {
final long base = -1;
for (int i = 0; i < 100; i++) {
final long pow = ArithmeticUtils.pow(base, i);
- Assert.assertEquals("i: " + i, i % 2 == 0 ? 1 : -1, pow);
+ Assertions.assertEquals(i % 2 == 0 ? 1 : -1, pow, "i: " + i);
}
}
@@ -546,7 +545,7 @@ public class ArithmeticUtilsTest {
final long base = 1;
for (int i = 0; i < 100; i++) {
final long pow = ArithmeticUtils.pow(base, i);
- Assert.assertEquals("i: " + i, 1, pow);
+ Assertions.assertEquals(1, pow, "i: " + i);
}
}
@@ -560,14 +559,14 @@ public class ArithmeticUtilsTest {
}
for (int i = 0; i < expected.length; i++) {
final boolean actual = ArithmeticUtils.isPowerOfTwo(i);
- Assert.assertTrue(Integer.toString(i), actual == expected[i]);
+ Assertions.assertTrue(actual == expected[i], Integer.toString(i));
}
}
private void testAddAndCheckLongFailure(long a, long b) {
try {
ArithmeticUtils.addAndCheck(a, b);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {
// success
}
@@ -576,7 +575,7 @@ public class ArithmeticUtilsTest {
private void testMulAndCheckLongFailure(long a, long b) {
try {
ArithmeticUtils.mulAndCheck(a, b);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {
// success
}
@@ -585,7 +584,7 @@ public class ArithmeticUtilsTest {
private void testSubAndCheckLongFailure(long a, long b) {
try {
ArithmeticUtils.subAndCheck(a, b);
- Assert.fail("Expecting ArithmeticException");
+ Assertions.fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {
// success
}
@@ -684,13 +683,13 @@ public class ArithmeticUtilsTest {
return toUnsignedBigInteger(dividend).divide(toUnsignedBigInteger(divisor)).longValue();
}
- @Test()
+ @Test
public void testRemainderUnsignedInt() {
- Assert.assertEquals(36, ArithmeticUtils.remainderUnsigned(-2147479015, 63));
- Assert.assertEquals(6, ArithmeticUtils.remainderUnsigned(-2147479015, 25));
+ Assertions.assertEquals(36, ArithmeticUtils.remainderUnsigned(-2147479015, 63));
+ Assertions.assertEquals(6, ArithmeticUtils.remainderUnsigned(-2147479015, 25));
}
- @Test()
+ @Test
public void testRemainderUnsignedIntSpecialCases() {
int ints[] = getIntSpecialCases();
for (int dividend : ints) {
@@ -700,15 +699,15 @@ public class ArithmeticUtilsTest {
() -> ArithmeticUtils.remainderUnsigned(dividend, divisor)
);
} else {
- Assert.assertEquals(remainderUnsignedExpected(dividend, divisor), ArithmeticUtils.remainderUnsigned(dividend, divisor));
+ Assertions.assertEquals(remainderUnsignedExpected(dividend, divisor), ArithmeticUtils.remainderUnsigned(dividend, divisor));
}
}
}
}
- @Test()
+ @Test
public void testRemainderUnsignedLong() {
- Assert.assertEquals(48L, ArithmeticUtils.remainderUnsigned(-2147479015L, 63L));
+ Assertions.assertEquals(48L, ArithmeticUtils.remainderUnsigned(-2147479015L, 63L));
}
@Test
@@ -719,32 +718,32 @@ public class ArithmeticUtilsTest {
if (divisor == 0L) {
try {
ArithmeticUtils.remainderUnsigned(dividend, divisor);
- Assert.fail("Should have failed with ArithmeticException: division by zero");
+ Assertions.fail("Should have failed with ArithmeticException: division by zero");
} catch (ArithmeticException e) {
// Success.
}
} else {
- Assert.assertEquals(remainderUnsignedExpected(dividend, divisor), ArithmeticUtils.remainderUnsigned(dividend, divisor));
+ Assertions.assertEquals(remainderUnsignedExpected(dividend, divisor), ArithmeticUtils.remainderUnsigned(dividend, divisor));
}
}
}
}
- @Test()
+ @Test
public void testDivideUnsignedInt() {
- Assert.assertEquals(34087115, ArithmeticUtils.divideUnsigned(-2147479015, 63));
- Assert.assertEquals(85899531, ArithmeticUtils.divideUnsigned(-2147479015, 25));
- Assert.assertEquals(2147483646, ArithmeticUtils.divideUnsigned(-3, 2));
- Assert.assertEquals(330382098, ArithmeticUtils.divideUnsigned(-16, 13));
- Assert.assertEquals(306783377, ArithmeticUtils.divideUnsigned(-16, 14));
- Assert.assertEquals(2, ArithmeticUtils.divideUnsigned(-1, 2147483647));
- Assert.assertEquals(2, ArithmeticUtils.divideUnsigned(-2, 2147483647));
- Assert.assertEquals(1, ArithmeticUtils.divideUnsigned(-3, 2147483647));
- Assert.assertEquals(1, ArithmeticUtils.divideUnsigned(-16, 2147483647));
- Assert.assertEquals(1, ArithmeticUtils.divideUnsigned(-16, 2147483646));
- }
-
- @Test()
+ Assertions.assertEquals(34087115, ArithmeticUtils.divideUnsigned(-2147479015, 63));
+ Assertions.assertEquals(85899531, ArithmeticUtils.divideUnsigned(-2147479015, 25));
+ Assertions.assertEquals(2147483646, ArithmeticUtils.divideUnsigned(-3, 2));
+ Assertions.assertEquals(330382098, ArithmeticUtils.divideUnsigned(-16, 13));
+ Assertions.assertEquals(306783377, ArithmeticUtils.divideUnsigned(-16, 14));
+ Assertions.assertEquals(2, ArithmeticUtils.divideUnsigned(-1, 2147483647));
+ Assertions.assertEquals(2, ArithmeticUtils.divideUnsigned(-2, 2147483647));
+ Assertions.assertEquals(1, ArithmeticUtils.divideUnsigned(-3, 2147483647));
+ Assertions.assertEquals(1, ArithmeticUtils.divideUnsigned(-16, 2147483647));
+ Assertions.assertEquals(1, ArithmeticUtils.divideUnsigned(-16, 2147483646));
+ }
+
+ @Test
public void testDivideUnsignedIntSpecialCases() {
int ints[] = getIntSpecialCases();
for (int dividend : ints) {
@@ -754,18 +753,18 @@ public class ArithmeticUtilsTest {
() -> ArithmeticUtils.divideUnsigned(dividend, divisor)
);
} else {
- Assert.assertEquals(divideUnsignedExpected(dividend, divisor), ArithmeticUtils.divideUnsigned(dividend, divisor));
+ Assertions.assertEquals(divideUnsignedExpected(dividend, divisor), ArithmeticUtils.divideUnsigned(dividend, divisor));
}
}
}
}
- @Test()
+ @Test
public void testDivideUnsignedLong() {
- Assert.assertEquals(292805461453366231L, ArithmeticUtils.divideUnsigned(-2147479015L, 63L));
+ Assertions.assertEquals(292805461453366231L, ArithmeticUtils.divideUnsigned(-2147479015L, 63L));
}
- @Test()
+ @Test
public void testDivideUnsignedLongSpecialCases() {
long longs[] = getLongSpecialCases();
for (long dividend : longs) {
@@ -775,7 +774,7 @@ public class ArithmeticUtilsTest {
() -> ArithmeticUtils.divideUnsigned(dividend, divisor)
);
} else {
- Assert.assertEquals(divideUnsignedExpected(dividend, divisor), ArithmeticUtils.divideUnsigned(dividend, divisor));
+ Assertions.assertEquals(divideUnsignedExpected(dividend, divisor), ArithmeticUtils.divideUnsigned(dividend, divisor));
}
}
}
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 759ce50..07f7634 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
@@ -15,7 +15,7 @@ package org.apache.commons.numbers.core;
import java.math.RoundingMode;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
@@ -25,29 +25,29 @@ import org.junit.jupiter.api.Test;
public class PrecisionTest {
@Test
public void testEqualsWithRelativeTolerance() {
- Assert.assertTrue(Precision.equalsWithRelativeTolerance(0d, 0d, 0d));
- Assert.assertTrue(Precision.equalsWithRelativeTolerance(0d, 1 / Double.NEGATIVE_INFINITY, 0d));
+ Assertions.assertTrue(Precision.equalsWithRelativeTolerance(0d, 0d, 0d));
+ Assertions.assertTrue(Precision.equalsWithRelativeTolerance(0d, 1 / Double.NEGATIVE_INFINITY, 0d));
final double eps = 1e-14;
- Assert.assertFalse(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654988, eps));
- Assert.assertTrue(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654987, eps));
- Assert.assertFalse(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654948, eps));
- Assert.assertTrue(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654949, eps));
+ Assertions.assertFalse(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654988, eps));
+ Assertions.assertTrue(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654987, eps));
+ Assertions.assertFalse(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654948, eps));
+ Assertions.assertTrue(Precision.equalsWithRelativeTolerance(1.987654687654968, 1.987654687654949, eps));
- Assert.assertFalse(Precision.equalsWithRelativeTolerance(Precision.SAFE_MIN, 0.0, eps));
+ Assertions.assertFalse(Precision.equalsWithRelativeTolerance(Precision.SAFE_MIN, 0.0, eps));
- Assert.assertFalse(Precision.equalsWithRelativeTolerance(1.0000000000001e-300, 1e-300, eps));
- Assert.assertTrue(Precision.equalsWithRelativeTolerance(1.00000000000001e-300, 1e-300, eps));
+ Assertions.assertFalse(Precision.equalsWithRelativeTolerance(1.0000000000001e-300, 1e-300, eps));
+ Assertions.assertTrue(Precision.equalsWithRelativeTolerance(1.00000000000001e-300, 1e-300, eps));
- Assert.assertFalse(Precision.equalsWithRelativeTolerance(Double.NEGATIVE_INFINITY, 1.23, eps));
- Assert.assertFalse(Precision.equalsWithRelativeTolerance(Double.POSITIVE_INFINITY, 1.23, eps));
+ Assertions.assertFalse(Precision.equalsWithRelativeTolerance(Double.NEGATIVE_INFINITY, 1.23, eps));
+ Assertions.assertFalse(Precision.equalsWithRelativeTolerance(Double.POSITIVE_INFINITY, 1.23, eps));
- Assert.assertTrue(Precision.equalsWithRelativeTolerance(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, eps));
- Assert.assertTrue(Precision.equalsWithRelativeTolerance(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, eps));
- Assert.assertFalse(Precision.equalsWithRelativeTolerance(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, eps));
+ Assertions.assertTrue(Precision.equalsWithRelativeTolerance(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, eps));
+ Assertions.assertTrue(Precision.equalsWithRelativeTolerance(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, eps));
+ Assertions.assertFalse(Precision.equalsWithRelativeTolerance(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, eps));
- Assert.assertFalse(Precision.equalsWithRelativeTolerance(Double.NaN, 1.23, eps));
- Assert.assertFalse(Precision.equalsWithRelativeTolerance(Double.NaN, Double.NaN, eps));
+ Assertions.assertFalse(Precision.equalsWithRelativeTolerance(Double.NaN, 1.23, eps));
+ Assertions.assertFalse(Precision.equalsWithRelativeTolerance(Double.NaN, Double.NaN, eps));
}
@Test
@@ -61,11 +61,11 @@ public class PrecisionTest {
for (int i = 0; i < testArray.length; i++) {
for (int j = 0; j < testArray.length; j++) {
if (i == j) {
- Assert.assertTrue(Precision.equalsIncludingNaN(testArray[i], testArray[j]));
- Assert.assertTrue(Precision.equalsIncludingNaN(testArray[j], testArray[i]));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(testArray[i], testArray[j]));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(testArray[j], testArray[i]));
} else {
- Assert.assertTrue(!Precision.equalsIncludingNaN(testArray[i], testArray[j]));
- Assert.assertTrue(!Precision.equalsIncludingNaN(testArray[j], testArray[i]));
+ Assertions.assertTrue(!Precision.equalsIncludingNaN(testArray[i], testArray[j]));
+ Assertions.assertTrue(!Precision.equalsIncludingNaN(testArray[j], testArray[i]));
}
}
}
@@ -73,15 +73,15 @@ public class PrecisionTest {
@Test
public void testEqualsWithAllowedDelta() {
- Assert.assertTrue(Precision.equals(153.0000, 153.0000, .0625));
- Assert.assertTrue(Precision.equals(153.0000, 153.0625, .0625));
- Assert.assertTrue(Precision.equals(152.9375, 153.0000, .0625));
- Assert.assertFalse(Precision.equals(153.0000, 153.0625, .0624));
- Assert.assertFalse(Precision.equals(152.9374, 153.0000, .0625));
- Assert.assertFalse(Precision.equals(Double.NaN, Double.NaN, 1.0));
- Assert.assertTrue(Precision.equals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0));
- Assert.assertTrue(Precision.equals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1.0));
- Assert.assertFalse(Precision.equals(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0));
+ Assertions.assertTrue(Precision.equals(153.0000, 153.0000, .0625));
+ Assertions.assertTrue(Precision.equals(153.0000, 153.0625, .0625));
+ Assertions.assertTrue(Precision.equals(152.9375, 153.0000, .0625));
+ Assertions.assertFalse(Precision.equals(153.0000, 153.0625, .0624));
+ Assertions.assertFalse(Precision.equals(152.9374, 153.0000, .0625));
+ Assertions.assertFalse(Precision.equals(Double.NaN, Double.NaN, 1.0));
+ Assertions.assertTrue(Precision.equals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0));
+ Assertions.assertTrue(Precision.equals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1.0));
+ Assertions.assertFalse(Precision.equals(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0));
}
@Test
@@ -93,40 +93,40 @@ public class PrecisionTest {
// Because they are adjacent floating point numbers, "a" and "b" are
// considered equal even though the allowed error is smaller than
// their difference.
- Assert.assertTrue(Precision.equals(a, b, 0.5 * diff));
+ Assertions.assertTrue(Precision.equals(a, b, 0.5 * diff));
final double c = Math.nextUp(b);
diff = Math.abs(a - c);
// Because "a" and "c" are not adjacent, the tolerance is taken into
// account for assessing equality.
- Assert.assertTrue(Precision.equals(a, c, diff));
- Assert.assertFalse(Precision.equals(a, c, (1 - 1e-16) * diff));
+ Assertions.assertTrue(Precision.equals(a, c, diff));
+ Assertions.assertFalse(Precision.equals(a, c, (1 - 1e-16) * diff));
}
@Test
public void testEqualsIncludingNaNWithAllowedDelta() {
- Assert.assertTrue(Precision.equalsIncludingNaN(153.0000, 153.0000, .0625));
- Assert.assertTrue(Precision.equalsIncludingNaN(153.0000, 153.0625, .0625));
- Assert.assertTrue(Precision.equalsIncludingNaN(152.9375, 153.0000, .0625));
- Assert.assertTrue(Precision.equalsIncludingNaN(Double.NaN, Double.NaN, 1.0));
- Assert.assertTrue(Precision.equalsIncludingNaN(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0));
- Assert.assertTrue(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1.0));
- Assert.assertFalse(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0));
- Assert.assertFalse(Precision.equalsIncludingNaN(153.0000, 153.0625, .0624));
- Assert.assertFalse(Precision.equalsIncludingNaN(152.9374, 153.0000, .0625));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(153.0000, 153.0000, .0625));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(153.0000, 153.0625, .0625));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(152.9375, 153.0000, .0625));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(Double.NaN, Double.NaN, 1.0));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1.0));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(153.0000, 153.0625, .0624));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(152.9374, 153.0000, .0625));
}
// Tests for floating point equality
@Test
public void testFloatEqualsWithAllowedUlps() {
- Assert.assertTrue("+0.0f == -0.0f",Precision.equals(0.0f, -0.0f));
- Assert.assertTrue("+0.0f == -0.0f (1 ulp)",Precision.equals(0.0f, -0.0f, 1));
+ Assertions.assertTrue(Precision.equals(0.0f, -0.0f), "+0.0f == -0.0f");
+ Assertions.assertTrue(Precision.equals(0.0f, -0.0f, 1), "+0.0f == -0.0f (1 ulp)");
float oneFloat = 1.0f;
- Assert.assertTrue("1.0f == 1.0f + 1 ulp",Precision.equals(oneFloat, Float.intBitsToFloat(1 + Float.floatToIntBits(oneFloat))));
- Assert.assertTrue("1.0f == 1.0f + 1 ulp (1 ulp)",Precision.equals(oneFloat, Float.intBitsToFloat(1 + Float.floatToIntBits(oneFloat)), 1));
- Assert.assertFalse("1.0f != 1.0f + 2 ulp (1 ulp)",Precision.equals(oneFloat, Float.intBitsToFloat(2 + Float.floatToIntBits(oneFloat)), 1));
+ Assertions.assertTrue(Precision.equals(oneFloat, Float.intBitsToFloat(1 + Float.floatToIntBits(oneFloat))), "1.0f == 1.0f + 1 ulp");
+ Assertions.assertTrue(Precision.equals(oneFloat, Float.intBitsToFloat(1 + Float.floatToIntBits(oneFloat)), 1), "1.0f == 1.0f + 1 ulp (1 ulp)");
+ Assertions.assertFalse(Precision.equals(oneFloat, Float.intBitsToFloat(2 + Float.floatToIntBits(oneFloat)), 1), "1.0f != 1.0f + 2 ulp (1 ulp)");
- Assert.assertTrue(Precision.equals(153.0f, 153.0f, 1));
+ Assertions.assertTrue(Precision.equals(153.0f, 153.0f, 1));
// These tests need adjusting for floating point precision
// Assert.assertTrue(Precision.equals(153.0f, 153.00000000000003f, 1));
@@ -139,110 +139,110 @@ public class PrecisionTest {
// Assert.assertTrue(Precision.equals(-128.0f, -128.00000000000003f, 1));
// Assert.assertFalse(Precision.equals(-128.0f, -128.00000000000006f, 1));
- Assert.assertTrue(Precision.equals(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, 1));
- Assert.assertTrue(Precision.equals(Double.MAX_VALUE, Float.POSITIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equals(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equals(Double.MAX_VALUE, Float.POSITIVE_INFINITY, 1));
- Assert.assertTrue(Precision.equals(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, 1));
- Assert.assertTrue(Precision.equals(-Float.MAX_VALUE, Float.NEGATIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equals(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equals(-Float.MAX_VALUE, Float.NEGATIVE_INFINITY, 1));
- Assert.assertFalse(Precision.equals(Float.NaN, Float.NaN, 1));
- Assert.assertFalse(Precision.equals(Float.NaN, Float.NaN, 0));
- Assert.assertFalse(Precision.equals(Float.NaN, 0, 0));
- Assert.assertFalse(Precision.equals(Float.NaN, Float.POSITIVE_INFINITY, 0));
- Assert.assertFalse(Precision.equals(Float.NaN, Float.NEGATIVE_INFINITY, 0));
+ Assertions.assertFalse(Precision.equals(Float.NaN, Float.NaN, 1));
+ Assertions.assertFalse(Precision.equals(Float.NaN, Float.NaN, 0));
+ Assertions.assertFalse(Precision.equals(Float.NaN, 0, 0));
+ Assertions.assertFalse(Precision.equals(Float.NaN, Float.POSITIVE_INFINITY, 0));
+ Assertions.assertFalse(Precision.equals(Float.NaN, Float.NEGATIVE_INFINITY, 0));
- Assert.assertFalse(Precision.equals(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, 100000));
+ Assertions.assertFalse(Precision.equals(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, 100000));
}
@Test
public void testEqualsWithAllowedUlps() {
- Assert.assertTrue(Precision.equals(0.0, -0.0, 1));
+ Assertions.assertTrue(Precision.equals(0.0, -0.0, 1));
- Assert.assertTrue(Precision.equals(1.0, 1 + Math.ulp(1d), 1));
- Assert.assertFalse(Precision.equals(1.0, 1 + 2 * Math.ulp(1d), 1));
+ Assertions.assertTrue(Precision.equals(1.0, 1 + Math.ulp(1d), 1));
+ Assertions.assertFalse(Precision.equals(1.0, 1 + 2 * Math.ulp(1d), 1));
final double nUp1 = Math.nextAfter(1d, Double.POSITIVE_INFINITY);
final double nnUp1 = Math.nextAfter(nUp1, Double.POSITIVE_INFINITY);
- Assert.assertTrue(Precision.equals(1.0, nUp1, 1));
- Assert.assertTrue(Precision.equals(nUp1, nnUp1, 1));
- Assert.assertFalse(Precision.equals(1.0, nnUp1, 1));
+ Assertions.assertTrue(Precision.equals(1.0, nUp1, 1));
+ Assertions.assertTrue(Precision.equals(nUp1, nnUp1, 1));
+ Assertions.assertFalse(Precision.equals(1.0, nnUp1, 1));
- Assert.assertTrue(Precision.equals(0.0, Math.ulp(0d), 1));
- Assert.assertTrue(Precision.equals(0.0, -Math.ulp(0d), 1));
+ Assertions.assertTrue(Precision.equals(0.0, Math.ulp(0d), 1));
+ Assertions.assertTrue(Precision.equals(0.0, -Math.ulp(0d), 1));
- Assert.assertTrue(Precision.equals(153.0, 153.0, 1));
+ Assertions.assertTrue(Precision.equals(153.0, 153.0, 1));
- Assert.assertTrue(Precision.equals(153.0, 153.00000000000003, 1));
- Assert.assertFalse(Precision.equals(153.0, 153.00000000000006, 1));
- Assert.assertTrue(Precision.equals(153.0, 152.99999999999997, 1));
- Assert.assertFalse(Precision.equals(153, 152.99999999999994, 1));
+ Assertions.assertTrue(Precision.equals(153.0, 153.00000000000003, 1));
+ Assertions.assertFalse(Precision.equals(153.0, 153.00000000000006, 1));
+ Assertions.assertTrue(Precision.equals(153.0, 152.99999999999997, 1));
+ Assertions.assertFalse(Precision.equals(153, 152.99999999999994, 1));
- Assert.assertTrue(Precision.equals(-128.0, -127.99999999999999, 1));
- Assert.assertFalse(Precision.equals(-128.0, -127.99999999999997, 1));
- Assert.assertTrue(Precision.equals(-128.0, -128.00000000000003, 1));
- Assert.assertFalse(Precision.equals(-128.0, -128.00000000000006, 1));
+ Assertions.assertTrue(Precision.equals(-128.0, -127.99999999999999, 1));
+ Assertions.assertFalse(Precision.equals(-128.0, -127.99999999999997, 1));
+ Assertions.assertTrue(Precision.equals(-128.0, -128.00000000000003, 1));
+ Assertions.assertFalse(Precision.equals(-128.0, -128.00000000000006, 1));
- Assert.assertTrue(Precision.equals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1));
- Assert.assertTrue(Precision.equals(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equals(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 1));
- Assert.assertTrue(Precision.equals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1));
- Assert.assertTrue(Precision.equals(-Double.MAX_VALUE, Double.NEGATIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equals(-Double.MAX_VALUE, Double.NEGATIVE_INFINITY, 1));
- Assert.assertFalse(Precision.equals(Double.NaN, Double.NaN, 1));
- Assert.assertFalse(Precision.equals(Double.NaN, Double.NaN, 0));
- Assert.assertFalse(Precision.equals(Double.NaN, 0, 0));
- Assert.assertFalse(Precision.equals(Double.NaN, Double.POSITIVE_INFINITY, 0));
- Assert.assertFalse(Precision.equals(Double.NaN, Double.NEGATIVE_INFINITY, 0));
+ Assertions.assertFalse(Precision.equals(Double.NaN, Double.NaN, 1));
+ Assertions.assertFalse(Precision.equals(Double.NaN, Double.NaN, 0));
+ Assertions.assertFalse(Precision.equals(Double.NaN, 0, 0));
+ Assertions.assertFalse(Precision.equals(Double.NaN, Double.POSITIVE_INFINITY, 0));
+ Assertions.assertFalse(Precision.equals(Double.NaN, Double.NEGATIVE_INFINITY, 0));
- Assert.assertFalse(Precision.equals(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 100000));
+ Assertions.assertFalse(Precision.equals(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 100000));
}
@Test
public void testEqualsIncludingNaNWithAllowedUlps() {
- Assert.assertTrue(Precision.equalsIncludingNaN(0.0, -0.0, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(0.0, -0.0, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(1.0, 1 + Math.ulp(1d), 1));
- Assert.assertFalse(Precision.equalsIncludingNaN(1.0, 1 + 2 * Math.ulp(1d), 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(1.0, 1 + Math.ulp(1d), 1));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(1.0, 1 + 2 * Math.ulp(1d), 1));
final double nUp1 = Math.nextAfter(1d, Double.POSITIVE_INFINITY);
final double nnUp1 = Math.nextAfter(nUp1, Double.POSITIVE_INFINITY);
- Assert.assertTrue(Precision.equalsIncludingNaN(1.0, nUp1, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(nUp1, nnUp1, 1));
- Assert.assertFalse(Precision.equalsIncludingNaN(1.0, nnUp1, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(1.0, nUp1, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(nUp1, nnUp1, 1));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(1.0, nnUp1, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(0.0, Math.ulp(0d), 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(0.0, -Math.ulp(0d), 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(0.0, Math.ulp(0d), 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(0.0, -Math.ulp(0d), 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(153.0, 153.0, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(153.0, 153.0, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(153.0, 153.00000000000003, 1));
- Assert.assertFalse(Precision.equalsIncludingNaN(153.0, 153.00000000000006, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(153.0, 152.99999999999997, 1));
- Assert.assertFalse(Precision.equalsIncludingNaN(153, 152.99999999999994, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(153.0, 153.00000000000003, 1));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(153.0, 153.00000000000006, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(153.0, 152.99999999999997, 1));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(153, 152.99999999999994, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(-128.0, -127.99999999999999, 1));
- Assert.assertFalse(Precision.equalsIncludingNaN(-128.0, -127.99999999999997, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(-128.0, -128.00000000000003, 1));
- Assert.assertFalse(Precision.equalsIncludingNaN(-128.0, -128.00000000000006, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(-128.0, -127.99999999999999, 1));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(-128.0, -127.99999999999997, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(-128.0, -128.00000000000003, 1));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(-128.0, -128.00000000000006, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(-Double.MAX_VALUE, Double.NEGATIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(-Double.MAX_VALUE, Double.NEGATIVE_INFINITY, 1));
- Assert.assertTrue(Precision.equalsIncludingNaN(Double.NaN, Double.NaN, 1));
+ Assertions.assertTrue(Precision.equalsIncludingNaN(Double.NaN, Double.NaN, 1));
- Assert.assertFalse(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 100000));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 100000));
}
@Test
public void testCompareToEpsilon() {
- Assert.assertEquals(0, Precision.compareTo(152.33, 152.32, .011));
- Assert.assertTrue(Precision.compareTo(152.308, 152.32, .011) < 0);
- Assert.assertTrue(Precision.compareTo(152.33, 152.318, .011) > 0);
- Assert.assertEquals(0, Precision.compareTo(Double.MIN_VALUE, +0.0, Double.MIN_VALUE));
- Assert.assertEquals(0, Precision.compareTo(Double.MIN_VALUE, -0.0, Double.MIN_VALUE));
+ 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);
+ Assertions.assertEquals(0, Precision.compareTo(Double.MIN_VALUE, +0.0, Double.MIN_VALUE));
+ Assertions.assertEquals(0, Precision.compareTo(Double.MIN_VALUE, -0.0, Double.MIN_VALUE));
}
@Test
@@ -251,147 +251,147 @@ public class PrecisionTest {
double delta = Math.ulp(a);
for (int i = 0; i <= 10; ++i) {
if (i <= 5) {
- Assert.assertEquals( 0, Precision.compareTo(a, a + i * delta, 5));
- Assert.assertEquals( 0, Precision.compareTo(a, a - i * delta, 5));
+ Assertions.assertEquals( 0, Precision.compareTo(a, a + i * delta, 5));
+ Assertions.assertEquals( 0, Precision.compareTo(a, a - i * delta, 5));
} else {
- Assert.assertEquals(-1, Precision.compareTo(a, a + i * delta, 5));
- Assert.assertEquals(+1, Precision.compareTo(a, a - i * delta, 5));
+ Assertions.assertEquals(-1, Precision.compareTo(a, a + i * delta, 5));
+ Assertions.assertEquals(+1, Precision.compareTo(a, a - i * delta, 5));
}
}
- Assert.assertEquals( 0, Precision.compareTo(-0.0, 0.0, 0));
+ Assertions.assertEquals( 0, Precision.compareTo(-0.0, 0.0, 0));
- Assert.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, -0.0, 0));
- Assert.assertEquals( 0, Precision.compareTo(-Double.MIN_VALUE, -0.0, 1));
- Assert.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, +0.0, 0));
- Assert.assertEquals( 0, Precision.compareTo(-Double.MIN_VALUE, +0.0, 1));
+ Assertions.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, -0.0, 0));
+ Assertions.assertEquals( 0, Precision.compareTo(-Double.MIN_VALUE, -0.0, 1));
+ Assertions.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, +0.0, 0));
+ Assertions.assertEquals( 0, Precision.compareTo(-Double.MIN_VALUE, +0.0, 1));
- Assert.assertEquals(+1, Precision.compareTo( Double.MIN_VALUE, -0.0, 0));
- Assert.assertEquals( 0, Precision.compareTo( Double.MIN_VALUE, -0.0, 1));
- Assert.assertEquals(+1, Precision.compareTo( Double.MIN_VALUE, +0.0, 0));
- Assert.assertEquals( 0, Precision.compareTo( Double.MIN_VALUE, +0.0, 1));
+ Assertions.assertEquals(+1, Precision.compareTo( Double.MIN_VALUE, -0.0, 0));
+ Assertions.assertEquals( 0, Precision.compareTo( Double.MIN_VALUE, -0.0, 1));
+ Assertions.assertEquals(+1, Precision.compareTo( Double.MIN_VALUE, +0.0, 0));
+ Assertions.assertEquals( 0, Precision.compareTo( Double.MIN_VALUE, +0.0, 1));
- Assert.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, Double.MIN_VALUE, 0));
- Assert.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, Double.MIN_VALUE, 1));
- Assert.assertEquals( 0, Precision.compareTo(-Double.MIN_VALUE, Double.MIN_VALUE, 2));
+ Assertions.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, Double.MIN_VALUE, 0));
+ Assertions.assertEquals(-1, Precision.compareTo(-Double.MIN_VALUE, Double.MIN_VALUE, 1));
+ Assertions.assertEquals( 0, Precision.compareTo(-Double.MIN_VALUE, Double.MIN_VALUE, 2));
- Assert.assertEquals( 0, Precision.compareTo(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 1));
- Assert.assertEquals(-1, Precision.compareTo(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 0));
+ Assertions.assertEquals( 0, Precision.compareTo(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 1));
+ Assertions.assertEquals(-1, Precision.compareTo(Double.MAX_VALUE, Double.POSITIVE_INFINITY, 0));
- Assert.assertEquals(+1, Precision.compareTo(Double.MAX_VALUE, Double.NaN, Integer.MAX_VALUE));
- Assert.assertEquals(+1, Precision.compareTo(Double.NaN, Double.MAX_VALUE, Integer.MAX_VALUE));
+ Assertions.assertEquals(+1, Precision.compareTo(Double.MAX_VALUE, Double.NaN, Integer.MAX_VALUE));
+ Assertions.assertEquals(+1, Precision.compareTo(Double.NaN, Double.MAX_VALUE, Integer.MAX_VALUE));
}
@Test
public void testRoundDouble() {
double x = 1.234567890;
- Assert.assertEquals(1.23, Precision.round(x, 2), 0.0);
- Assert.assertEquals(1.235, Precision.round(x, 3), 0.0);
- Assert.assertEquals(1.2346, Precision.round(x, 4), 0.0);
+ 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);
// JIRA MATH-151
- Assert.assertEquals(39.25, Precision.round(39.245, 2), 0.0);
- Assert.assertEquals(39.24, Precision.round(39.245, 2, RoundingMode.DOWN), 0.0);
+ Assertions.assertEquals(39.25, Precision.round(39.245, 2), 0.0);
+ Assertions.assertEquals(39.24, Precision.round(39.245, 2, RoundingMode.DOWN), 0.0);
double xx = 39.0;
xx += 245d / 1000d;
- Assert.assertEquals(39.25, Precision.round(xx, 2), 0.0);
+ Assertions.assertEquals(39.25, Precision.round(xx, 2), 0.0);
// BZ 35904
- Assert.assertEquals(30.1d, Precision.round(30.095d, 2), 0.0d);
- Assert.assertEquals(30.1d, Precision.round(30.095d, 1), 0.0d);
- Assert.assertEquals(33.1d, Precision.round(33.095d, 1), 0.0d);
- Assert.assertEquals(33.1d, Precision.round(33.095d, 2), 0.0d);
- Assert.assertEquals(50.09d, Precision.round(50.085d, 2), 0.0d);
- Assert.assertEquals(50.19d, Precision.round(50.185d, 2), 0.0d);
- Assert.assertEquals(50.01d, Precision.round(50.005d, 2), 0.0d);
- Assert.assertEquals(30.01d, Precision.round(30.005d, 2), 0.0d);
- Assert.assertEquals(30.65d, Precision.round(30.645d, 2), 0.0d);
-
- Assert.assertEquals(1.24, Precision.round(x, 2, RoundingMode.CEILING), 0.0);
- Assert.assertEquals(1.235, Precision.round(x, 3, RoundingMode.CEILING), 0.0);
- Assert.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.CEILING), 0.0);
- Assert.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.CEILING), 0.0);
- Assert.assertEquals(-1.234, Precision.round(-x, 3, RoundingMode.CEILING), 0.0);
- Assert.assertEquals(-1.2345, Precision.round(-x, 4, RoundingMode.CEILING), 0.0);
-
- Assert.assertEquals(1.23, Precision.round(x, 2, RoundingMode.DOWN), 0.0);
- Assert.assertEquals(1.234, Precision.round(x, 3, RoundingMode.DOWN), 0.0);
- Assert.assertEquals(1.2345, Precision.round(x, 4, RoundingMode.DOWN), 0.0);
- Assert.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.DOWN), 0.0);
- Assert.assertEquals(-1.234, Precision.round(-x, 3, RoundingMode.DOWN), 0.0);
- Assert.assertEquals(-1.2345, Precision.round(-x, 4, RoundingMode.DOWN), 0.0);
-
- Assert.assertEquals(1.23, Precision.round(x, 2, RoundingMode.FLOOR), 0.0);
- Assert.assertEquals(1.234, Precision.round(x, 3, RoundingMode.FLOOR), 0.0);
- Assert.assertEquals(1.2345, Precision.round(x, 4, RoundingMode.FLOOR), 0.0);
- Assert.assertEquals(-1.24, Precision.round(-x, 2, RoundingMode.FLOOR), 0.0);
- Assert.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.FLOOR), 0.0);
- Assert.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.FLOOR), 0.0);
-
- Assert.assertEquals(1.23, Precision.round(x, 2, RoundingMode.HALF_DOWN), 0.0);
- Assert.assertEquals(1.235, Precision.round(x, 3, RoundingMode.HALF_DOWN), 0.0);
- Assert.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.HALF_DOWN), 0.0);
- Assert.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.HALF_DOWN), 0.0);
- Assert.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.HALF_DOWN), 0.0);
- Assert.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.HALF_DOWN), 0.0);
- Assert.assertEquals(1.234, Precision.round(1.2345, 3, RoundingMode.HALF_DOWN), 0.0);
- Assert.assertEquals(-1.234, Precision.round(-1.2345, 3, RoundingMode.HALF_DOWN), 0.0);
-
- Assert.assertEquals(1.23, Precision.round(x, 2, RoundingMode.HALF_EVEN), 0.0);
- Assert.assertEquals(1.235, Precision.round(x, 3, RoundingMode.HALF_EVEN), 0.0);
- Assert.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.HALF_EVEN), 0.0);
- Assert.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.HALF_EVEN), 0.0);
- Assert.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.HALF_EVEN), 0.0);
- Assert.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.HALF_EVEN), 0.0);
- Assert.assertEquals(1.234, Precision.round(1.2345, 3, RoundingMode.HALF_EVEN), 0.0);
- Assert.assertEquals(-1.234, Precision.round(-1.2345, 3, RoundingMode.HALF_EVEN), 0.0);
- Assert.assertEquals(1.236, Precision.round(1.2355, 3, RoundingMode.HALF_EVEN), 0.0);
- Assert.assertEquals(-1.236, Precision.round(-1.2355, 3, RoundingMode.HALF_EVEN), 0.0);
-
- Assert.assertEquals(1.23, Precision.round(x, 2, RoundingMode.HALF_UP), 0.0);
- Assert.assertEquals(1.235, Precision.round(x, 3, RoundingMode.HALF_UP), 0.0);
- Assert.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.HALF_UP), 0.0);
- Assert.assertEquals(-1.23, Precision.round(-x, 2, RoundingMode.HALF_UP), 0.0);
- Assert.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.HALF_UP), 0.0);
- Assert.assertEquals(-1.2346, Precision.round(-x, 4, RoundingMode.HALF_UP), 0.0);
- Assert.assertEquals(1.235, Precision.round(1.2345, 3, RoundingMode.HALF_UP), 0.0);
- Assert.assertEquals(-1.235, Precision.round(-1.2345, 3, RoundingMode.HALF_UP), 0.0);
-
- Assert.assertEquals(-1.23, Precision.round(-1.23, 2, RoundingMode.UNNECESSARY), 0.0);
- Assert.assertEquals(1.23, Precision.round(1.23, 2, RoundingMode.UNNECESSARY), 0.0);
+ 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(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.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.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.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_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_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(-1.23, 2, RoundingMode.UNNECESSARY), 0.0);
+ Assertions.assertEquals(1.23, Precision.round(1.23, 2, RoundingMode.UNNECESSARY), 0.0);
try {
Precision.round(1.234, 2, RoundingMode.UNNECESSARY);
- Assert.fail();
+ Assertions.fail();
} catch (ArithmeticException ex) {
// expected
}
- Assert.assertEquals(1.24, Precision.round(x, 2, RoundingMode.UP), 0.0);
- Assert.assertEquals(1.235, Precision.round(x, 3, RoundingMode.UP), 0.0);
- Assert.assertEquals(1.2346, Precision.round(x, 4, RoundingMode.UP), 0.0);
- Assert.assertEquals(-1.24, Precision.round(-x, 2, RoundingMode.UP), 0.0);
- Assert.assertEquals(-1.235, Precision.round(-x, 3, RoundingMode.UP), 0.0);
- Assert.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), 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);
// MATH-151
- Assert.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), 0.0);
// special values
TestUtils.assertEquals(Double.NaN, Precision.round(Double.NaN, 2), 0.0);
- Assert.assertEquals(0.0, Precision.round(0.0, 2), 0.0);
- Assert.assertEquals(Double.POSITIVE_INFINITY, Precision.round(Double.POSITIVE_INFINITY, 2), 0.0);
- Assert.assertEquals(Double.NEGATIVE_INFINITY, Precision.round(Double.NEGATIVE_INFINITY, 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);
// comparison of positive and negative zero is not possible -> always equal thus do string comparison
- Assert.assertEquals("-0.0", Double.toString(Precision.round(-0.0, 0)));
- Assert.assertEquals("-0.0", Double.toString(Precision.round(-1e-10, 0)));
+ 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 testIssue721() {
- Assert.assertEquals(-53, Math.getExponent(Precision.EPSILON));
- Assert.assertEquals(-1022, Math.getExponent(Precision.SAFE_MIN));
+ Assertions.assertEquals(-53, Math.getExponent(Precision.EPSILON));
+ Assertions.assertEquals(-1022, Math.getExponent(Precision.SAFE_MIN));
}
@@ -408,7 +408,7 @@ public class PrecisionTest {
}
}
- Assert.assertTrue(nonRepresentableCount / (double) numTrials > 0.9);
+ Assertions.assertTrue(nonRepresentableCount / (double) numTrials > 0.9);
}
@Test
@@ -417,17 +417,17 @@ public class PrecisionTest {
Double.POSITIVE_INFINITY);
// a) 1 + EPSILON is equal to 1.
- Assert.assertTrue(1 + Precision.EPSILON == 1);
+ Assertions.assertTrue(1 + Precision.EPSILON == 1);
// b) 1 + "the number after EPSILON" is not equal to 1.
- Assert.assertFalse(1 + afterEpsilon == 1);
+ Assertions.assertFalse(1 + afterEpsilon == 1);
}
@Test
public void testMath1127() {
- Assert.assertFalse(Precision.equals(2.0, -2.0, 1));
- Assert.assertTrue(Precision.equals(0.0, -0.0, 0));
- Assert.assertFalse(Precision.equals(2.0f, -2.0f, 1));
- Assert.assertTrue(Precision.equals(0.0f, -0.0f, 0));
+ 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));
+ Assertions.assertTrue(Precision.equals(0.0f, -0.0f, 0));
}
}
[commons-numbers] 15/34: Migrate commons-numbers-complex-streams to
JUnit 5
Posted by er...@apache.org.
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 773f4d7975d99bd230c0338c9d84b0d18e293886
Author: Schamschi <he...@gmx.at>
AuthorDate: Sun Jun 9 15:10:13 2019 +0200
Migrate commons-numbers-complex-streams to JUnit 5
Migrate the following classes:
ComplexUtilsTest
TestUtils
---
.../numbers/complex/streams/ComplexUtilsTest.java | 15 +++++++--------
.../commons/numbers/complex/streams/TestUtils.java | 22 +++++++++++-----------
2 files changed, 18 insertions(+), 19 deletions(-)
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 dba04a5..fc1fec2 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
@@ -19,7 +19,6 @@ package org.apache.commons.numbers.complex.streams;
import org.apache.commons.numbers.complex.Complex;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -266,9 +265,9 @@ public class ComplexUtilsTest {
theta1D[5-i] = theta1D[5 + i + 1] - pi/6;
}
Complex[] observed1D = ComplexUtils.polar2Complex(r1D, theta1D);
- Assert.assertEquals(r1D.length, observed1D.length);
+ Assertions.assertEquals(r1D.length, observed1D.length);
for (int i = 0; i < r1D.length; i++) {
- Assert.assertEquals(ComplexUtils.polar2Complex(r1D[i], theta1D[i]), observed1D[i]);
+ Assertions.assertEquals(ComplexUtils.polar2Complex(r1D[i], theta1D[i]), observed1D[i]);
}
// 2D
@@ -281,7 +280,7 @@ public class ComplexUtilsTest {
}
}
Complex[][] observed2D = ComplexUtils.polar2Complex(r2D, theta2D);
- Assert.assertEquals(r2D.length, observed2D.length);
+ Assertions.assertEquals(r2D.length, observed2D.length);
for (int i = 0; i < r2D.length; i++) {
TestUtils.assertSame(msg, ComplexUtils.polar2Complex(r2D[i], theta2D[i]), observed2D[i]);
}
@@ -298,7 +297,7 @@ public class ComplexUtilsTest {
}
}
Complex[][][] observed3D = ComplexUtils.polar2Complex(r3D, theta3D);
- Assert.assertEquals(r3D.length, observed3D.length);
+ Assertions.assertEquals(r3D.length, observed3D.length);
for (int i = 0; i < r3D.length; i++) {
TestUtils.assertSame(msg, ComplexUtils.polar2Complex(r3D[i], theta3D[i]), observed3D[i]);
}
@@ -362,7 +361,7 @@ public class ComplexUtilsTest {
final Complex[] complex = ComplexUtils.real2Complex(real);
for (int i = 0; i < real.length; i++) {
- Assert.assertEquals(real[i], complex[i].getReal(), 0d);
+ Assertions.assertEquals(real[i], complex[i].getReal(), 0d);
}
}
@@ -755,7 +754,7 @@ public class ComplexUtilsTest {
public void testAbs() {
setArrays();
double[] observed = ComplexUtils.abs(c);
- Assert.assertEquals(c.length, observed.length);
+ Assertions.assertEquals(c.length, observed.length);
for (int i = 0; i < c.length; i++) {
TestUtils.assertEquals(c[i].abs(), observed[i], 0);
}
@@ -765,7 +764,7 @@ public class ComplexUtilsTest {
public void testArg() {
setArrays();
double[] observed = ComplexUtils.arg(c);
- Assert.assertEquals(c.length, observed.length);
+ Assertions.assertEquals(c.length, observed.length);
for (int i = 0; i < c.length; i++) {
TestUtils.assertEquals(c[i].getArgument(), observed[i], 0);
}
diff --git a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java
index 1daa267..92088e5 100644
--- a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java
+++ b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java
@@ -20,7 +20,7 @@ package org.apache.commons.numbers.complex.streams;
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.
@@ -49,10 +49,10 @@ class TestUtils {
public static void assertEquals(String msg, double expected, double actual, double delta) {
// check for NaN
if(Double.isNaN(expected)){
- Assert.assertTrue((msg == null ? "" : msg + "\n") + actual + " is not NaN.",
- Double.isNaN(actual));
+ Assertions.assertTrue(Double.isNaN(actual),
+ (msg == null ? "" : msg + "\n") + actual + " is not NaN.");
} else {
- Assert.assertEquals(msg, expected, actual, delta);
+ Assertions.assertEquals(expected, actual, delta, msg);
}
}
@@ -109,7 +109,7 @@ 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);
}
/**
@@ -126,8 +126,8 @@ 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("Real Values Differ", expected.getReal(), actual.getReal(), delta);
- Assert.assertEquals("Imaginary Values Differ", expected.getImaginary(), actual.getImaginary(), delta);
+ Assertions.assertEquals(expected.getReal(), actual.getReal(), delta, "Real Values Differ");
+ Assertions.assertEquals(expected.getImaginary(), actual.getImaginary(), delta, "Imaginary Values Differ");
}
/** verifies that two arrays are close (sup norm) */
@@ -147,7 +147,7 @@ class TestUtils {
}
}
if (failure) {
- Assert.fail(out.toString());
+ Assertions.fail(out.toString());
}
}
@@ -200,7 +200,7 @@ class TestUtils {
}
}
if (failure) {
- Assert.fail(out.toString());
+ Assertions.fail(out.toString());
}
}
@@ -246,7 +246,7 @@ class TestUtils {
}
}
if (failure) {
- Assert.fail(out.toString());
+ Assertions.fail(out.toString());
}
}
@@ -315,7 +315,7 @@ class TestUtils {
out.append("Arrays not same length. \n");
out.append("expected has length ").append(expectedLength);
out.append(" observed has length = ").append(observedLength);
- Assert.fail(out.toString());
+ Assertions.fail(out.toString());
}
}
[commons-numbers] 16/34: Remove unneeded parentheses in class
ComplexUtilsTest
Posted by er...@apache.org.
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 4718fc226064c90e4abcc7713635a588130e291b
Author: Schamschi <he...@gmx.at>
AuthorDate: Sun Jun 9 16:29:41 2019 +0200
Remove unneeded parentheses in class ComplexUtilsTest
---
.../numbers/complex/streams/ComplexUtilsTest.java | 48 +++++++++++-----------
1 file changed, 24 insertions(+), 24 deletions(-)
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 fc1fec2..fb8f4d7 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
@@ -307,28 +307,28 @@ public class ComplexUtilsTest {
return Complex.I.multiply(Complex.ofCartesian(theta, 0)).exp().multiply(Complex.ofCartesian(r, 0));
}
- @Test()
+ @Test
public void testPolar2ComplexIllegalModulus() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.polar2Complex(-1, 0)
);
}
- @Test()
+ @Test
public void testPolar2ComplexIllegalModulus1D() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.polar2Complex(new double[]{0, -1, 2}, new double[]{0, 1, 2})
);
}
- @Test()
+ @Test
public 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()
+ @Test
public void testPolar2ComplexIllegalModulus3D() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.polar2Complex(new double[][][]{{{0, 2, 2}}, {{0, -1, 2}}}, new double[][][]{{{0, 1, 2}}, {{0, 1, 2}}})
@@ -487,63 +487,63 @@ public class ComplexUtilsTest {
// INTERLEAVED <-> COMPLEX
- @Test()
+ @Test
public void testComplex2InterleavedIllegalIndex2Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c2d, -1)
);
}
- @Test()
+ @Test
public void testComplex2InterleavedIllegalIndex2Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c2d, 2)
);
}
- @Test()
+ @Test
public void testComplex2InterleavedIllegalIndex3Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c3d, -1)
);
}
- @Test()
+ @Test
public void testComplex2InterleavedIllegalIndex3Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c3d, 3)
);
}
- @Test()
+ @Test
public void testComplex2InterleavedIllegalIndex4Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c4d, -1)
);
}
- @Test()
+ @Test
public void testComplex2InterleavedIllegalIndex4Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2Interleaved(c4d, 4)
);
}
- @Test()
+ @Test
public void testComplex2InterleavedFloatIllegalIndex2Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2InterleavedFloat(c2d, -1)
);
}
- @Test()
+ @Test
public void testComplex2InterleavedFloatIllegalIndex2Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.complex2InterleavedFloat(c2d, 2)
);
}
- @Test()
+ @Test
public void testComplex2InterleavedFloatIllegalIndex3Dmin()
{
Assertions.assertThrows(IllegalArgumentException.class,
@@ -551,7 +551,7 @@ public class ComplexUtilsTest {
);
}
- @Test()
+ @Test
public void testComplex2InterleavedFloatIllegalIndex3Dmax()
{
Assertions.assertThrows(IllegalArgumentException.class,
@@ -559,28 +559,28 @@ public class ComplexUtilsTest {
);
}
- @Test()
+ @Test
public void testInterleaved2ComplexIllegalIndex2Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(di2d0, -1)
);
}
- @Test()
+ @Test
public void testInterleaved2ComplexIllegalIndex2Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(di2d0, 2)
);
}
- @Test()
+ @Test
public void testInterleaved2ComplexIllegalIndex3Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(di3d0, -1)
);
}
- @Test()
+ @Test
public void testInterleaved2ComplexIllegalIndex3Dmax()
{
Assertions.assertThrows(IllegalArgumentException.class,
@@ -588,42 +588,42 @@ public class ComplexUtilsTest {
);
}
- @Test()
+ @Test
public void testInterleaved2ComplexIllegalIndex4Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(di4d0, -1)
);
}
- @Test()
+ @Test
public void testInterleaved2ComplexIllegalIndex4Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(di4d0, 4)
);
}
- @Test()
+ @Test
public void testInterleaved2ComplexFloatIllegalIndex2Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(fi2d0, -1)
);
}
- @Test()
+ @Test
public void testInterleaved2ComplexFloatIllegalIndex2Dmax() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(fi2d0, 2)
);
}
- @Test()
+ @Test
public void testInterleaved2ComplexFloatIllegalIndex3Dmin() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> ComplexUtils.interleaved2Complex(fi3d0, -1)
);
}
- @Test()
+ @Test
public void testInterleaved2ComplexFloatIllegalIndex3Dmax()
{
Assertions.assertThrows(IllegalArgumentException.class,
[commons-numbers] 03/34: Restore relevant changes overwritten in
the merge of the master branch
Posted by er...@apache.org.
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 5f7f230895b985231267abb88727cbd622a5665d
Author: Schamschi <he...@gmx.at>
AuthorDate: Fri Jun 7 12:20:40 2019 +0200
Restore relevant changes overwritten in the merge of the master branch
---
.../org/apache/commons/numbers/fraction/BigFractionTest.java | 12 ++++++------
.../org/apache/commons/numbers/fraction/FractionTest.java | 7 ++++---
2 files changed, 10 insertions(+), 9 deletions(-)
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 2234b1b..671164d 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
@@ -88,11 +88,11 @@ public class BigFractionTest {
}
}
- @Test()
+ @Test
public void testGoldenRatio() {
// the golden ratio is notoriously a difficult number for continuous fraction
Assertions.assertThrows(FractionException.class,
- () -> new BigFraction((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
+ () -> BigFraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
);
}
@@ -159,18 +159,18 @@ public class BigFractionTest {
}
// MATH-1029
- @Test()
+ @Test
public void testPositiveValueOverflow() {
Assertions.assertThrows(ArithmeticException.class,
- () -> assertFraction((long) 1e10, 1, new BigFraction(1e10, 1000))
+ () -> assertFraction((long) 1e10, 1, BigFraction.from(1e10, 1000))
);
}
// MATH-1029
- @Test()
+ @Test
public void testNegativeValueOverflow() {
Assertions.assertThrows(ArithmeticException.class,
- () -> assertFraction((long) -1e10, 1, new BigFraction(-1e10, 1000))
+ () -> assertFraction((long) -1e10, 1, BigFraction.from(-1e10, 1000))
);
}
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 444f2ef..557895e 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
@@ -62,11 +62,11 @@ public class FractionTest {
assertFraction(15, 1, Fraction.from(15.0000000000001));
}
- @Test()
+ @Test
public void testGoldenRatio() {
// the golden ratio is notoriously a difficult number for continuous fraction
Assertions.assertThrows(ArithmeticException.class,
- () -> new Fraction((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
+ () -> Fraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
);
}
@@ -644,7 +644,8 @@ public class FractionTest {
};
int inc = 0;
for (Fraction fraction: fractions) {
- Assert.assertEquals(fraction,Fraction.parse(validExpressions[inc]));
+ Assert.assertEquals(fraction,
+ Fraction.parse(validExpressions[inc]));
inc++;
}
}
[commons-numbers] 12/34: fix FieldParametricTest
Posted by er...@apache.org.
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 526d93ff6d0efe245e2f4d7ba73e553181469cf3
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Sat Jun 8 17:41:34 2019 -0700
fix FieldParametricTest
---
.../commons/numbers/field/FieldParametricTest.java | 114 ++++++++++++++-------
.../apache/commons/numbers/field/FieldsList.java | 13 ++-
2 files changed, 86 insertions(+), 41 deletions(-)
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 d68af63..873642f 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
@@ -16,82 +16,125 @@
*/
package org.apache.commons.numbers.field;
-import org.junit.Assert;
-import org.junit.jupiter.api.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.util.stream.Stream;
/**
* Tests for fields.
*/
-@RunWith(value=Parameterized.class)
public class FieldParametricTest {
- /** Field under test. */
- @Parameterized.Parameter(0)
- private Field field;
- @Parameterized.Parameter(1)
- private Object a;
- @Parameterized.Parameter(2)
- private Object b;
- @Parameterized.Parameter(3)
- private Object c;
- @Parameterized.Parameters()
- public static Iterable<FieldTestData[]> getList() {
- return FieldsList.list();
+ private static Stream<FieldTestData> getList() {
+ return FieldsList.list().stream();
}
- public void testAdditionAssociativity() {
+ @ParameterizedTest
+ @MethodSource("getList")
+ public void testAdditionAssociativity(FieldTestData data) {
+ Field field = data.getField();
+ Object a = data.getA();
+ Object b = data.getB();
+ Object c = data.getC();
final Object r1 = field.add(field.add(a, b), c);
final Object r2 = field.add(a, field.add(b, c));
assertEquals(r1, r2);
}
- @Test
- public void testAdditionCommutativity() {
+
+ @ParameterizedTest
+ @MethodSource("getList")
+ public void testAdditionCommutativity(FieldTestData data) {
+ Field field = data.getField();
+ Object a = data.getA();
+ Object b = data.getB();
+ Object c = data.getC();
final Object r1 = field.add(a, b);
final Object r2 = field.add(b, a);
assertEquals(r1, r2);
}
- @Test
- public void testAdditiveIdentity() {
+
+ @ParameterizedTest
+ @MethodSource("getList")
+ public void testAdditiveIdentity(FieldTestData data) {
+ Field field = data.getField();
+ Object a = data.getA();
+ Object b = data.getB();
+ Object c = data.getC();
final Object r1 = field.add(a, field.zero());
final Object r2 = a;
assertEquals(r1, r2);
}
- @Test
- public void testAdditiveInverse() {
+
+ @ParameterizedTest
+ @MethodSource("getList")
+ public void testAdditiveInverse(FieldTestData data) {
+ Field field = data.getField();
+ Object a = data.getA();
+ Object b = data.getB();
+ Object c = data.getC();
final Object r1 = field.add(a, field.negate(a));
final Object r2 = field.zero();
assertEquals(r1, r2);
}
- @Test
- public void testMultiplicationAssociativity() {
+ @ParameterizedTest
+ @MethodSource("getList")
+ public void testMultiplicationAssociativity(FieldTestData data) {
+ Field field = data.getField();
+ Object a = data.getA();
+ Object b = data.getB();
+ Object c = data.getC();
final Object r1 = field.multiply(field.multiply(a, b), c);
final Object r2 = field.multiply(a, field.multiply(b, c));
assertEquals(r1, r2);
}
- @Test
- public void testMultiplicationCommutativity() {
+
+ @ParameterizedTest
+ @MethodSource("getList")
+ public void testMultiplicationCommutativity(FieldTestData data) {
+ Field field = data.getField();
+ Object a = data.getA();
+ Object b = data.getB();
+ Object c = data.getC();
final Object r1 = field.multiply(a, b);
final Object r2 = field.multiply(b, a);
assertEquals(r1, r2);
}
- @Test
- public void testMultiplicativeIdentity() {
+
+ @ParameterizedTest
+ @MethodSource("getList")
+ public void testMultiplicativeIdentity(FieldTestData data) {
+ Field field = data.getField();
+ Object a = data.getA();
+ Object b = data.getB();
+ Object c = data.getC();
final Object r1 = field.multiply(a, field.one());
final Object r2 = a;
assertEquals(r1, r2);
}
- @Test
- public void testMultiplicativeInverse() {
+
+ @ParameterizedTest
+ @MethodSource("getList")
+ public void testMultiplicativeInverse(FieldTestData data) {
+ Field field = data.getField();
+ Object a = data.getA();
+ Object b = data.getB();
+ Object c = data.getC();
final Object r1 = field.multiply(a, field.reciprocal(a));
final Object r2 = field.one();
assertEquals(r1, r2);
}
- @Test
- public void testDistributivity() {
+ @ParameterizedTest
+ @MethodSource("getList")
+ public void testDistributivity(FieldTestData data) {
+ Field field = data.getField();
+ Object a = data.getA();
+ Object b = data.getB();
+ Object c = data.getC();
final Object r1 = field.multiply(a, field.add(b, c));
final Object r2 = field.add(field.multiply(a, b), field.multiply(a, c));
assertEquals(r1, r2);
@@ -103,7 +146,6 @@ public class FieldParametricTest {
*/
private static void assertEquals(Object a,
Object b) {
- Assert.assertTrue(a + " != " + b,
- a.equals(b));
+ Assertions.assertEquals(a, b, a + " != " + b);
}
}
diff --git a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
index a341171..396c83f 100644
--- a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
+++ b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
@@ -26,10 +26,10 @@ import org.apache.commons.numbers.fraction.Fraction;
/**
* List of fields.
*/
-public class FieldsList {
+final class FieldsList {
/** List of all fields implemented in the library. */
- private static final List<FieldTestData[]> LIST =
- new ArrayList<FieldTestData[]>();
+ private static final List<FieldTestData> LIST =
+ new ArrayList<>();
static {
try {
@@ -50,6 +50,9 @@ public class FieldsList {
}
}
+ private FieldsList() {
+ }
+
/**
* @param field Field.
* @param a Field element.
@@ -59,7 +62,7 @@ public class FieldsList {
T a,
T b,
T c) {
- LIST.add(new FieldTestData[] { new FieldTestData(field, a, b, c) });
+ LIST.add(new FieldTestData(field, a, b, c));
}
/**
@@ -68,7 +71,7 @@ public class FieldsList {
*
* @return the list of all fields.
*/
- public static Iterable<FieldTestData[]> list() {
+ static List<FieldTestData> list() {
return Collections.unmodifiableList(LIST);
}
}
[commons-numbers] 21/34: Simplify junit
Posted by er...@apache.org.
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 de949a139839afd9be005c4fcbba47d323dea7ac
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Sun Jun 9 22:28:24 2019 -0700
Simplify junit
---
.../commons/numbers/angle/PlaneAngleTest.java | 6 +--
.../numbers/combinatorics/CombinationsTest.java | 2 +-
.../commons/numbers/complex/ComplexTest.java | 44 +++++++++++-----------
.../commons/numbers/core/ArithmeticUtilsTest.java | 2 +-
.../apache/commons/numbers/core/PrecisionTest.java | 8 ++--
.../commons/numbers/fraction/BigFractionTest.java | 14 +++----
.../commons/numbers/fraction/FractionTest.java | 16 ++++----
.../commons/numbers/quaternion/QuaternionTest.java | 38 +++++++++----------
.../numbers/rootfinder/BrentSolverTest.java | 10 ++---
9 files changed, 70 insertions(+), 70 deletions(-)
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 a33b3a6..48e7f21 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
@@ -161,20 +161,20 @@ public class PlaneAngleTest {
final double value = 12345.6789;
final PlaneAngle a = PlaneAngle.ofRadians(value);
final PlaneAngle b = PlaneAngle.ofRadians(value);
- Assert.assertTrue(a.equals(b));
+ Assert.assertEquals(a, b);
}
@Test
public void testEquals2() {
final PlaneAngle a = PlaneAngle.ofRadians(153768.373486587);
final PlaneAngle b = null;
- Assert.assertFalse(a.equals(b));
+ Assert.assertNotEquals(a, b);
}
@Test
public void testEquals3() {
final double value = 0.987654321;
final PlaneAngle a = PlaneAngle.ofRadians(value);
final PlaneAngle b = PlaneAngle.ofRadians(value + 1e-16);
- Assert.assertFalse(a.equals(b));
+ Assert.assertNotEquals(a, b);
}
@Test
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 ee27e89..0b768c2 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
@@ -175,7 +175,7 @@ public class CombinationsTest {
// Check that the sequence of iterates is ordered.
if (lastIterate != null) {
- Assertions.assertTrue(comp.compare(iterate, lastIterate) == 1);
+ Assertions.assertEquals(1, comp.compare(iterate, lastIterate));
}
// Check that each iterate is ordered.
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 014aeb6..9dff601 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
@@ -384,7 +384,7 @@ public class ComplexTest {
@Test
public void testEqualsNull() {
Complex x = Complex.ofCartesian(3.0, 4.0);
- Assertions.assertFalse(x.equals(null));
+ Assertions.assertNotEquals(null, x);
}
@Test
@@ -404,13 +404,13 @@ public class ComplexTest {
@Test
public void testEqualsClass() {
Complex x = Complex.ofCartesian(3.0, 4.0);
- Assertions.assertFalse(x.equals(this));
+ Assertions.assertNotEquals(x, this);
}
@Test
public void testEqualsSame() {
Complex x = Complex.ofCartesian(3.0, 4.0);
- Assertions.assertTrue(x.equals(x));
+ Assertions.assertEquals(x, x);
}
@Test
@@ -421,7 +421,7 @@ public class ComplexTest {
final Complex x = Complex.ofCartesian(re, im);
Complex y = Complex.ofCartesian(re, im);
- Assertions.assertTrue(x.equals(y));
+ Assertions.assertEquals(x, y);
Assertions.assertTrue(Complex.equals(x, y));
final int maxUlps = 5;
@@ -494,30 +494,30 @@ public class ComplexTest {
public void testEqualsTrue() {
Complex x = Complex.ofCartesian(3.0, 4.0);
Complex y = Complex.ofCartesian(3.0, 4.0);
- Assertions.assertTrue(x.equals(y));
+ Assertions.assertEquals(x, y);
}
@Test
public void testEqualsRealDifference() {
Complex x = Complex.ofCartesian(0.0, 0.0);
Complex y = Complex.ofCartesian(0.0 + Double.MIN_VALUE, 0.0);
- Assertions.assertFalse(x.equals(y));
+ Assertions.assertNotEquals(x, y);
}
@Test
public void testEqualsImaginaryDifference() {
Complex x = Complex.ofCartesian(0.0, 0.0);
Complex y = Complex.ofCartesian(0.0, 0.0 + Double.MIN_VALUE);
- Assertions.assertFalse(x.equals(y));
+ Assertions.assertNotEquals(x, y);
}
@Test
public void testHashCode() {
Complex x = Complex.ofCartesian(0.0, 0.0);
Complex y = Complex.ofCartesian(0.0, 0.0 + Double.MIN_VALUE);
- Assertions.assertFalse(x.hashCode()==y.hashCode());
+ Assertions.assertNotEquals(x.hashCode(), y.hashCode());
y = Complex.ofCartesian(0.0 + Double.MIN_VALUE, 0.0);
- Assertions.assertFalse(x.hashCode()==y.hashCode());
+ Assertions.assertNotEquals(x.hashCode(), y.hashCode());
Complex realNaN = Complex.ofCartesian(Double.NaN, 0.0);
Complex imaginaryNaN = Complex.ofCartesian(0.0, Double.NaN);
Assertions.assertEquals(realNaN.hashCode(), imaginaryNaN.hashCode());
@@ -531,12 +531,12 @@ public class ComplexTest {
x = Complex.ofCartesian(0.0, 0.0);
y = Complex.ofCartesian(0.0, -0.0);
Assertions.assertTrue(x.hashCode() != y.hashCode());
- Assertions.assertFalse(x.equals(y), msg);
+ Assertions.assertNotEquals(x, y, msg);
x = Complex.ofCartesian(0.0, 0.0);
y = Complex.ofCartesian(-0.0, 0.0);
Assertions.assertTrue(x.hashCode() != y.hashCode());
- Assertions.assertFalse(x.equals(y), msg);
+ Assertions.assertNotEquals(x, y, msg);
}
@Test
@@ -840,16 +840,16 @@ public class ComplexTest {
@Test
public void testParse() {
- 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())));
+ Assertions.assertEquals(Complex.ZERO, Complex.parse(Complex.ZERO.toString()));
+ Assertions.assertEquals(Complex.ONE, Complex.parse(Complex.ONE.toString()));
+ Assertions.assertEquals(Complex.I, Complex.parse(Complex.I.toString()));
+ Assertions.assertEquals(Complex.INF, Complex.parse(Complex.INF.toString()));
+ Assertions.assertEquals(NAN, Complex.parse(NAN.toString()));
+ Assertions.assertEquals(oneInf, Complex.parse(oneInf.toString()));
+ Assertions.assertEquals(negInfZero, Complex.parse(negInfZero.toString()));
+ Assertions.assertEquals(Complex.ofReal(pi), Complex.parse(Complex.ofReal(pi).toString()));
+ Assertions.assertEquals(Complex.ofPolar(2, pi), Complex.parse(Complex.ofPolar(2, pi).toString()));
+ Assertions.assertEquals(Complex.ofCis(pi), Complex.parse(Complex.ofCis(pi).toString()));
}
@Test
@@ -900,6 +900,6 @@ public class ComplexTest {
final double re = 1.234;
final double im = 5.678;
final String str = "( " + re + " , " + im + " )";
- Assertions.assertTrue(Complex.ofCartesian(re, im).equals(Complex.parse(str)));
+ Assertions.assertEquals(Complex.ofCartesian(re, im), Complex.parse(str));
}
}
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 1ff7937..ea4fd30 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
@@ -559,7 +559,7 @@ public class ArithmeticUtilsTest {
}
for (int i = 0; i < expected.length; i++) {
final boolean actual = ArithmeticUtils.isPowerOfTwo(i);
- Assertions.assertTrue(actual == expected[i], Integer.toString(i));
+ Assertions.assertEquals(actual, expected[i], Integer.toString(i));
}
}
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 07f7634..9433a63 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
@@ -64,8 +64,8 @@ public class PrecisionTest {
Assertions.assertTrue(Precision.equalsIncludingNaN(testArray[i], testArray[j]));
Assertions.assertTrue(Precision.equalsIncludingNaN(testArray[j], testArray[i]));
} else {
- Assertions.assertTrue(!Precision.equalsIncludingNaN(testArray[i], testArray[j]));
- Assertions.assertTrue(!Precision.equalsIncludingNaN(testArray[j], testArray[i]));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(testArray[i], testArray[j]));
+ Assertions.assertFalse(Precision.equalsIncludingNaN(testArray[j], testArray[i]));
}
}
}
@@ -417,10 +417,10 @@ public class PrecisionTest {
Double.POSITIVE_INFINITY);
// a) 1 + EPSILON is equal to 1.
- Assertions.assertTrue(1 + Precision.EPSILON == 1);
+ Assertions.assertEquals(1, 1 + Precision.EPSILON);
// b) 1 + "the number after EPSILON" is not equal to 1.
- Assertions.assertFalse(1 + afterEpsilon == 1);
+ Assertions.assertNotEquals(1, 1 + afterEpsilon, 0.0);
}
@Test
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 52dd953..0f154b9 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
@@ -596,22 +596,22 @@ public class BigFractionTest {
public void testEqualsAndHashCode() {
BigFraction zero = BigFraction.of(0, 1);
BigFraction nullFraction = null;
- Assert.assertTrue(zero.equals(zero));
- Assert.assertFalse(zero.equals(nullFraction));
- Assert.assertFalse(zero.equals(Double.valueOf(0)));
+ Assert.assertEquals(zero, zero);
+ Assert.assertNotEquals(zero, nullFraction);
+ Assert.assertNotEquals(zero, Double.valueOf(0), 0.0);
BigFraction zero2 = BigFraction.of(0, 2);
- Assert.assertTrue(zero.equals(zero2));
+ Assert.assertEquals(zero, zero2);
Assert.assertEquals(zero.hashCode(), zero2.hashCode());
BigFraction one = BigFraction.of(1, 1);
Assert.assertFalse((one.equals(zero) || zero.equals(one)));
- Assert.assertTrue(one.equals(BigFraction.ONE));
+ Assert.assertEquals(one, BigFraction.ONE);
}
@Test
public void testGetReducedFraction() {
BigFraction threeFourths = BigFraction.of(3, 4);
- Assert.assertTrue(threeFourths.equals(BigFraction.getReducedFraction(6, 8)));
- Assert.assertTrue(BigFraction.ZERO.equals(BigFraction.getReducedFraction(0, -1)));
+ Assert.assertEquals(threeFourths, BigFraction.getReducedFraction(6, 8));
+ Assert.assertEquals(BigFraction.ZERO, BigFraction.getReducedFraction(0, -1));
try {
BigFraction.getReducedFraction(1, 0);
Assert.fail("expecting ArithmeticException");
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 30c9d33..0b95245 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
@@ -247,11 +247,11 @@ public class FractionTest {
public void testMath1261() {
final Fraction a = Fraction.of(Integer.MAX_VALUE, 2);
final Fraction b = a.multiply(2);
- Assert.assertTrue(b.equals(Fraction.of(Integer.MAX_VALUE)));
+ Assert.assertEquals(b, Fraction.of(Integer.MAX_VALUE));
final Fraction c = Fraction.of(2, Integer.MAX_VALUE);
final Fraction d = c.divide(2);
- Assert.assertTrue(d.equals(Fraction.of(1, Integer.MAX_VALUE)));
+ Assert.assertEquals(d, Fraction.of(1, Integer.MAX_VALUE));
}
@Test
@@ -583,11 +583,11 @@ public class FractionTest {
public void testEqualsAndHashCode() {
Fraction zero = Fraction.of(0,1);
Fraction nullFraction = null;
- Assert.assertTrue( zero.equals(zero));
- Assert.assertFalse(zero.equals(nullFraction));
- Assert.assertFalse(zero.equals(Double.valueOf(0)));
+ Assert.assertEquals(zero, zero);
+ Assert.assertNotEquals(zero, nullFraction);
+ Assert.assertNotEquals(zero, Double.valueOf(0), 0.0);
Fraction zero2 = Fraction.of(0,2);
- Assert.assertTrue(zero.equals(zero2));
+ Assert.assertEquals(zero, zero2);
Assert.assertEquals(zero.hashCode(), zero2.hashCode());
Fraction one = Fraction.of(1,1);
Assert.assertFalse((one.equals(zero) ||zero.equals(one)));
@@ -596,8 +596,8 @@ public class FractionTest {
@Test
public void testGetReducedFraction() {
Fraction threeFourths = Fraction.of(3, 4);
- Assert.assertTrue(threeFourths.equals(Fraction.getReducedFraction(6, 8)));
- Assert.assertTrue(Fraction.ZERO.equals(Fraction.getReducedFraction(0, -1)));
+ Assert.assertEquals(threeFourths, Fraction.getReducedFraction(6, 8));
+ Assert.assertEquals(Fraction.ZERO, Fraction.getReducedFraction(0, -1));
try {
Fraction.getReducedFraction(1, 0);
Assert.fail("expecting ArithmeticException");
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 f82e6b7..31e6852 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
@@ -35,16 +35,16 @@ public class QuaternionTest {
@Test
public void testUnitQuaternions() {
Assertions.assertEquals(1, Quaternion.ONE.norm(), 0d);
- Assertions.assertTrue(Quaternion.ONE.normalize() == Quaternion.ONE);
+ Assertions.assertSame(Quaternion.ONE.normalize(), Quaternion.ONE);
Assertions.assertEquals(1, Quaternion.I.norm(), 0d);
- Assertions.assertTrue(Quaternion.I.normalize() == Quaternion.I);
+ Assertions.assertSame(Quaternion.I.normalize(), Quaternion.I);
Assertions.assertEquals(1, Quaternion.J.norm(), 0d);
- Assertions.assertTrue(Quaternion.J.normalize() == Quaternion.J);
+ Assertions.assertSame(Quaternion.J.normalize(), Quaternion.J);
Assertions.assertEquals(1, Quaternion.K.norm(), 0d);
- Assertions.assertTrue(Quaternion.K.normalize() == Quaternion.K);
+ Assertions.assertSame(Quaternion.K.normalize(), Quaternion.K);
}
@Test
@@ -330,7 +330,7 @@ public class QuaternionTest {
Assertions.assertEquals(1, versor.norm(), 0);
- Assertions.assertTrue(versor.normalize() == versor);
+ Assertions.assertSame(versor.normalize(), versor);
}
@Test
@@ -370,24 +370,24 @@ public class QuaternionTest {
public final void testObjectEquals() {
final double one = 1;
final Quaternion q1 = Quaternion.of(one, one, one, one);
- Assertions.assertTrue(q1.equals(q1));
+ Assertions.assertEquals(q1, q1);
final Quaternion q2 = Quaternion.of(one, one, one, one);
- Assertions.assertTrue(q2.equals(q1));
+ Assertions.assertEquals(q2, q1);
final Quaternion q3 = Quaternion.of(one, Math.nextUp(one), one, one);
- Assertions.assertFalse(q3.equals(q1));
+ Assertions.assertNotEquals(q3, q1);
- Assertions.assertFalse(q3.equals("bar"));
+ Assertions.assertNotEquals("bar", q3);
}
@Test
public 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.assertFalse(x.hashCode()==y.hashCode());
+ Assertions.assertNotEquals(x.hashCode(), y.hashCode());
y = Quaternion.of(0.0 + Double.MIN_VALUE, 0.0, 0.0, 0.0);
- Assertions.assertFalse(x.hashCode()==y.hashCode());
+ Assertions.assertNotEquals(x.hashCode(), y.hashCode());
// "equals" and "hashCode" must be compatible: if two objects have
// different hash codes, "equals" must return false.
@@ -396,22 +396,22 @@ public class QuaternionTest {
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.assertFalse(x.equals(y), msg);
+ 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.assertFalse(x.equals(y), msg);
+ 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.assertFalse(x.equals(y), msg);
+ 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.assertFalse(x.equals(y), msg);
+ Assertions.assertNotEquals(x, y, msg);
}
@Test
@@ -485,7 +485,7 @@ public class QuaternionTest {
Quaternion expected = Quaternion.of(0.5, -0.5, -0.5, 0.5);
assertEquals(q, expected, EPS);
- Assertions.assertTrue(q.positivePolarForm() == q);
+ Assertions.assertSame(q.positivePolarForm(), q);
}
@Test
@@ -494,7 +494,7 @@ public class QuaternionTest {
Quaternion expected = Quaternion.of(0.5, -0.5, 0.5, -0.5);
assertEquals(q, expected, EPS);
- Assertions.assertTrue(q.positivePolarForm() == q);
+ Assertions.assertSame(q.positivePolarForm(), q);
}
@Test
@@ -502,7 +502,7 @@ public class QuaternionTest {
Quaternion q = Quaternion.of(123, 45, 67, 89).normalize().positivePolarForm();
Assertions.assertTrue(q.getW() >= 0);
- Assertions.assertTrue(q.positivePolarForm() == q);
+ Assertions.assertSame(q.positivePolarForm(), q);
}
@Test
@@ -510,7 +510,7 @@ public class QuaternionTest {
Quaternion q = Quaternion.of(123, 45, 67, 89).normalize().negate().positivePolarForm();
Assertions.assertTrue(q.getW() >= 0);
- Assertions.assertTrue(q.positivePolarForm() == q);
+ Assertions.assertSame(q.positivePolarForm(), q);
}
@Test
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 84a2e97..8dd5a4f 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
@@ -159,7 +159,7 @@ public class BrentSolverTest {
} catch (IllegalStateException ex) {
// Expected.
// Ensure expected error condition.
- Assertions.assertFalse(ex.getMessage().indexOf("too many calls") == -1);
+ Assertions.assertNotEquals(ex.getMessage().indexOf("too many calls"), -1);
}
}
@@ -195,21 +195,21 @@ public class BrentSolverTest {
Assertions.fail("Expecting bad interval condition");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assertions.assertFalse(ex.getMessage().indexOf(" > ") == -1);
+ Assertions.assertNotEquals(ex.getMessage().indexOf(" > "), -1);
}
try { // No bracketing.
solver.findRoot(f, 1, 1.5);
Assertions.fail("Expecting non-bracketing condition");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assertions.assertFalse(ex.getMessage().indexOf("No bracketing") == -1);
+ Assertions.assertNotEquals(ex.getMessage().indexOf("No bracketing"), -1);
}
try { // No bracketing.
solver.findRoot(f, 1, 1.2, 1.5);
Assertions.fail("Expecting non-bracketing condition");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assertions.assertFalse(ex.getMessage().indexOf("No bracketing") == -1);
+ Assertions.assertNotEquals(ex.getMessage().indexOf("No bracketing"), -1);
}
}
@@ -226,7 +226,7 @@ public class BrentSolverTest {
Assertions.fail("an out of range condition was expected");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assertions.assertFalse(ex.getMessage().indexOf("out of range") == -1);
+ Assertions.assertNotEquals(ex.getMessage().indexOf("out of range"), -1);
}
}
[commons-numbers] 18/34: Migrate commons-numbers-combinatorics to
JUnit 5: 3 classes
Posted by er...@apache.org.
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 f5837b75a81704ed32262eb94e57407d73cee210
Author: Schamschi <he...@gmx.at>
AuthorDate: Sun Jun 9 23:29:37 2019 +0200
Migrate commons-numbers-combinatorics to JUnit 5: 3 classes
Migrate the following classes:
BinomialCoefficientDoubleTest
BinomialCoefficientTest
CombinationsTest
---
.../BinomialCoefficientDoubleTest.java | 37 +++++++++------
.../combinatorics/BinomialCoefficientTest.java | 49 ++++++++++---------
.../numbers/combinatorics/CombinationsTest.java | 55 +++++++++++-----------
3 files changed, 76 insertions(+), 65 deletions(-)
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 4f6252c..fd38458 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
@@ -16,7 +16,6 @@
*/
package org.apache.commons.numbers.combinatorics;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -27,7 +26,7 @@ public class BinomialCoefficientDoubleTest {
/** Verify that b(0,0) = 1 */
@Test
public void test0Choose0() {
- Assert.assertEquals(1d, BinomialCoefficientDouble.value(0, 0), 0);
+ Assertions.assertEquals(1d, BinomialCoefficientDouble.value(0, 0), 0);
}
@Test
@@ -37,10 +36,12 @@ public class BinomialCoefficientDoubleTest {
for (int n = 1; n < 10; n++) {
for (int k = 0; k <= n; k++) {
- Assert.assertEquals(n + " choose " + k,
- BinomialCoefficientTest.binomialCoefficient(n, k),
- BinomialCoefficientDouble.value(n, k),
- Double.MIN_VALUE);
+ Assertions.assertEquals(
+ BinomialCoefficientTest.binomialCoefficient(n, k),
+ BinomialCoefficientDouble.value(n, k),
+ Double.MIN_VALUE,
+ n + " choose " + k
+ );
}
}
@@ -48,19 +49,23 @@ public class BinomialCoefficientDoubleTest {
final int[] k = { 17, 33, 10, 1500 - 4, 4 };
for (int i = 0; i < n.length; i++) {
final long expected = BinomialCoefficientTest.binomialCoefficient(n[i], k[i]);
- Assert.assertEquals(n[i] + " choose " + k[i], expected,
- BinomialCoefficientDouble.value(n[i], k[i]), 0.0);
+ Assertions.assertEquals(
+ expected,
+ BinomialCoefficientDouble.value(n[i], k[i]),
+ 0.0,
+ n[i] + " choose " + k[i]
+ );
}
}
- @Test()
+ @Test
public void testBinomialCoefficientFail1() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficientDouble.value(4, 5)
);
}
- @Test()
+ @Test
public void testBinomialCoefficientFail2() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficientDouble.value(-1, -2)
@@ -70,7 +75,7 @@ public class BinomialCoefficientDoubleTest {
@Test
public void testBinomialCoefficientFail3() {
final double x = BinomialCoefficientDouble.value(1030, 515);
- Assert.assertTrue("expecting infinite binomial coefficient", Double.isInfinite(x));
+ Assertions.assertTrue(Double.isInfinite(x), "expecting infinite binomial coefficient");
}
/**
@@ -97,8 +102,12 @@ public class BinomialCoefficientDoubleTest {
}
if (!shouldThrow && exactResult > 1) {
- Assert.assertEquals(n + " choose " + k, 1.,
- BinomialCoefficientDouble.value(n, k) / exactResult, 1e-10);
+ Assertions.assertEquals(
+ 1.,
+ BinomialCoefficientDouble.value(n, k) / exactResult,
+ 1e-10,
+ n + " choose " + k
+ );
}
}
}
@@ -106,6 +115,6 @@ public class BinomialCoefficientDoubleTest {
final int n = 10000;
final double actualOverExpected = BinomialCoefficientDouble.value(n, 3) /
BinomialCoefficientTest.binomialCoefficient(n, 3);
- Assert.assertEquals(1, actualOverExpected, 1e-10);
+ Assertions.assertEquals(1, actualOverExpected, 1e-10);
}
}
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 9abf1b6..ad87d12 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
@@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -38,7 +37,7 @@ public class BinomialCoefficientTest {
/** Verify that b(0,0) = 1 */
@Test
public void test0Choose0() {
- Assert.assertEquals(BinomialCoefficient.value(0, 0), 1);
+ Assertions.assertEquals(BinomialCoefficient.value(0, 0), 1);
}
@Test
@@ -47,17 +46,19 @@ public class BinomialCoefficientTest {
final long[] bcoef6 = { 1, 6, 15, 20, 15, 6, 1 };
for (int i = 0; i < 6; i++) {
- Assert.assertEquals("5 choose " + i, bcoef5[i], BinomialCoefficient.value(5, i));
+ Assertions.assertEquals(bcoef5[i], BinomialCoefficient.value(5, i), "5 choose " + i);
}
for (int i = 0; i < 7; i++) {
- Assert.assertEquals("6 choose " + i, bcoef6[i], BinomialCoefficient.value(6, i));
+ Assertions.assertEquals(bcoef6[i], BinomialCoefficient.value(6, i), "6 choose " + i);
}
for (int n = 1; n < 10; n++) {
for (int k = 0; k <= n; k++) {
- Assert.assertEquals(n + " choose " + k,
- binomialCoefficient(n, k),
- BinomialCoefficient.value(n, k));
+ Assertions.assertEquals(
+ binomialCoefficient(n, k),
+ BinomialCoefficient.value(n, k),
+ n + " choose " + k
+ );
}
}
@@ -65,27 +66,29 @@ public class BinomialCoefficientTest {
final int[] k = { 17, 33, 10, 1500 - 4, 4 };
for (int i = 0; i < n.length; i++) {
final long expected = binomialCoefficient(n[i], k[i]);
- Assert.assertEquals(n[i] + " choose " + k[i],
- expected,
- BinomialCoefficient.value(n[i], k[i]));
+ Assertions.assertEquals(
+ expected,
+ BinomialCoefficient.value(n[i], k[i]),
+ n[i] + " choose " + k[i]
+ );
}
}
- @Test()
+ @Test
public void testBinomialCoefficientFail1() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficient.value(4, 5)
);
}
- @Test()
+ @Test
public void testBinomialCoefficientFail2() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficient.value(-1, -2)
);
}
- @Test()
+ @Test
public void testBinomialCoefficientFail3()
{
Assertions.assertThrows(ArithmeticException.class,
@@ -93,14 +96,14 @@ public class BinomialCoefficientTest {
);
}
- @Test()
+ @Test
public void testBinomialCoefficientFail4() {
Assertions.assertThrows(ArithmeticException.class,
() -> BinomialCoefficient.value(67, 34)
);
}
- @Test()
+ @Test
public void testBinomialCoefficientFail5() {
Assertions.assertThrows(ArithmeticException.class,
() -> BinomialCoefficient.value(700, 300)
@@ -130,35 +133,35 @@ public class BinomialCoefficientTest {
} catch (ArithmeticException ex) {
shouldThrow = true;
}
- Assert.assertEquals(n + " choose " + k, exactResult, ourResult);
- Assert.assertEquals(n + " choose " + k, shouldThrow, didThrow);
- Assert.assertTrue(n + " choose " + k, (n > 66 || !didThrow));
+ Assertions.assertEquals(exactResult, ourResult, n + " choose " + k);
+ Assertions.assertEquals(shouldThrow, didThrow, n + " choose " + k);
+ Assertions.assertTrue((n > 66 || !didThrow), n + " choose " + k);
}
}
long ourResult = BinomialCoefficient.value(300, 3);
long exactResult = binomialCoefficient(300, 3);
- Assert.assertEquals(exactResult, ourResult);
+ Assertions.assertEquals(exactResult, ourResult);
ourResult = BinomialCoefficient.value(700, 697);
exactResult = binomialCoefficient(700, 697);
- Assert.assertEquals(exactResult, ourResult);
+ Assertions.assertEquals(exactResult, ourResult);
final int n = 10000;
ourResult = BinomialCoefficient.value(n, 3);
exactResult = binomialCoefficient(n, 3);
- Assert.assertEquals(exactResult, ourResult);
+ Assertions.assertEquals(exactResult, ourResult);
}
- @Test()
+ @Test
public void checkNLessThanOne() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficient.checkBinomial(-1, -2)
);
}
- @Test()
+ @Test
public void checkKGreaterThanN() {
Assertions.assertThrows(CombinatoricsException.class,
() -> BinomialCoefficient.checkBinomial(4, 5)
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 227c7cb..ee27e89 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
@@ -19,7 +19,6 @@ package org.apache.commons.numbers.combinatorics;
import java.util.Iterator;
import java.util.Comparator;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -31,13 +30,13 @@ public class CombinationsTest {
public void testAccessor1() {
final int n = 5;
final int k = 3;
- Assert.assertEquals(n, new Combinations(n, k).getN());
+ Assertions.assertEquals(n, new Combinations(n, k).getN());
}
@Test
public void testAccessor2() {
final int n = 5;
final int k = 3;
- Assert.assertEquals(k, new Combinations(n, k).getK());
+ Assertions.assertEquals(k, new Combinations(n, k).getK());
}
@Test
@@ -54,7 +53,7 @@ public class CombinationsTest {
checkLexicographicIterator(new Combinations.LexicographicComparator(123, 2));
}
- @Test()
+ @Test
public void testLexicographicComparatorWrongIterate1() {
final int n = 5;
final int k = 3;
@@ -64,7 +63,7 @@ public class CombinationsTest {
);
}
- @Test()
+ @Test
public void testLexicographicComparatorWrongIterate2() {
final int n = 5;
final int k = 3;
@@ -74,7 +73,7 @@ public class CombinationsTest {
);
}
- @Test()
+ @Test
public void testLexicographicComparatorWrongIterate3() {
final int n = 5;
final int k = 3;
@@ -84,7 +83,7 @@ public class CombinationsTest {
);
}
- @Test()
+ @Test
public void testLexicographicComparatorWrongIterate4() {
final int n = 5;
final int k = 3;
@@ -100,8 +99,8 @@ public class CombinationsTest {
final int k = 6;
final Combinations.LexicographicComparator comp =
new Combinations.LexicographicComparator(n, k);
- Assert.assertEquals(n, comp.getN());
- Assert.assertEquals(k, comp.getK());
+ Assertions.assertEquals(n, comp.getN());
+ Assertions.assertEquals(k, comp.getK());
}
@Test
@@ -109,11 +108,11 @@ public class CombinationsTest {
final int n = 5;
final int k = 3;
final Comparator<int[]> comp = new Combinations.LexicographicComparator(n, k);
- Assert.assertEquals(1, comp.compare(new int[] {1, 2, 4},
+ Assertions.assertEquals(1, comp.compare(new int[] {1, 2, 4},
new int[] {1, 2, 3}));
- Assert.assertEquals(-1, comp.compare(new int[] {0, 1, 4},
+ Assertions.assertEquals(-1, comp.compare(new int[] {0, 1, 4},
new int[] {0, 2, 4}));
- Assert.assertEquals(0, comp.compare(new int[] {1, 3, 4},
+ Assertions.assertEquals(0, comp.compare(new int[] {1, 3, 4},
new int[] {1, 3, 4}));
}
@@ -125,36 +124,36 @@ public class CombinationsTest {
final int n = 5;
final int k = 3;
final Comparator<int[]> comp = new Combinations.LexicographicComparator(n, k);
- Assert.assertEquals(1, comp.compare(new int[] {1, 4, 2},
+ Assertions.assertEquals(1, comp.compare(new int[] {1, 4, 2},
new int[] {1, 3, 2}));
- Assert.assertEquals(-1, comp.compare(new int[] {0, 4, 1},
+ Assertions.assertEquals(-1, comp.compare(new int[] {0, 4, 1},
new int[] {0, 4, 2}));
- Assert.assertEquals(0, comp.compare(new int[] {1, 4, 3},
+ Assertions.assertEquals(0, comp.compare(new int[] {1, 4, 3},
new int[] {1, 3, 4}));
}
@Test
public void testEmptyCombination() {
final Iterator<int[]> iter = new Combinations(12345, 0).iterator();
- Assert.assertTrue(iter.hasNext());
+ Assertions.assertTrue(iter.hasNext());
final int[] c = iter.next();
- Assert.assertEquals(0, c.length);
- Assert.assertFalse(iter.hasNext());
+ Assertions.assertEquals(0, c.length);
+ Assertions.assertFalse(iter.hasNext());
}
@Test
public void testFullSetCombination() {
final int n = 67;
final Iterator<int[]> iter = new Combinations(n, n).iterator();
- Assert.assertTrue(iter.hasNext());
+ Assertions.assertTrue(iter.hasNext());
final int[] c = iter.next();
- Assert.assertEquals(n, c.length);
+ Assertions.assertEquals(n, c.length);
for (int i = 0; i < n; i++) {
- Assert.assertEquals(i, c[i]);
+ Assertions.assertEquals(i, c[i]);
}
- Assert.assertFalse(iter.hasNext());
+ Assertions.assertFalse(iter.hasNext());
}
/**
@@ -172,16 +171,16 @@ public class CombinationsTest {
long numIterates = 0;
for (int[] iterate : new Combinations(n, k)) {
- Assert.assertEquals(k, iterate.length);
+ Assertions.assertEquals(k, iterate.length);
// Check that the sequence of iterates is ordered.
if (lastIterate != null) {
- Assert.assertTrue(comp.compare(iterate, lastIterate) == 1);
+ Assertions.assertTrue(comp.compare(iterate, lastIterate) == 1);
}
// Check that each iterate is ordered.
for (int i = 1; i < iterate.length; i++) {
- Assert.assertTrue(iterate[i] > iterate[i - 1]);
+ Assertions.assertTrue(iterate[i] > iterate[i - 1]);
}
lastIterate = iterate;
@@ -189,16 +188,16 @@ public class CombinationsTest {
}
// Check the number of iterates.
- Assert.assertEquals(BinomialCoefficient.value(n, k), numIterates);
+ Assertions.assertEquals(BinomialCoefficient.value(n, k), numIterates);
}
- @Test()
+ @Test
public void testCombinationsIteratorFail1() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> new Combinations(4, 5).iterator()
);
}
- @Test()
+ @Test
public void testCombinationsIteratorFail2() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> new Combinations(-1, -2).iterator()
[commons-numbers] 14/34: Add the dep
Posted by er...@apache.org.
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 fe4d700c02f7560a6940740f8cad4ec09efb5f83
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Sat Jun 8 17:57:21 2019 -0700
Add the dep
---
pom.xml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/pom.xml b/pom.xml
index c22e030..d40454e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -118,6 +118,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
[commons-numbers] 23/34: Fix stragglers
Posted by er...@apache.org.
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 bf6de4fc369986130ac6f77d3d3c41dfe39a23cc
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Sun Jun 9 22:32:13 2019 -0700
Fix stragglers
---
.../apache/commons/numbers/fraction/BigFractionTest.java | 14 +++++++-------
.../apache/commons/numbers/fraction/FractionTest.java | 16 ++++++++--------
2 files changed, 15 insertions(+), 15 deletions(-)
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 81a0c0a..539c624 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
@@ -596,22 +596,22 @@ public class BigFractionTest {
public void testEqualsAndHashCode() {
BigFraction zero = BigFraction.of(0, 1);
BigFraction nullFraction = null;
- Assert.assertEquals(zero, zero);
- Assert.assertNotEquals(zero, nullFraction);
- Assert.assertNotEquals(zero, Double.valueOf(0), 0.0);
+ Assertions.assertEquals(zero, zero);
+ Assertions.assertNotEquals(nullFraction, zero);
+ Assertions.assertNotEquals(0.0d, zero);
BigFraction zero2 = BigFraction.of(0, 2);
- Assert.assertEquals(zero, zero2);
+ Assertions.assertEquals(zero, zero2);
Assertions.assertEquals(zero.hashCode(), zero2.hashCode());
BigFraction one = BigFraction.of(1, 1);
Assertions.assertFalse((one.equals(zero) || zero.equals(one)));
- Assert.assertEquals(one, BigFraction.ONE);
+ Assertions.assertEquals(BigFraction.ONE, one);
}
@Test
public void testGetReducedFraction() {
BigFraction threeFourths = BigFraction.of(3, 4);
- Assert.assertEquals(threeFourths, BigFraction.getReducedFraction(6, 8));
- Assert.assertEquals(BigFraction.ZERO, BigFraction.getReducedFraction(0, -1));
+ Assertions.assertEquals(threeFourths, BigFraction.getReducedFraction(6, 8));
+ Assertions.assertEquals(BigFraction.ZERO, BigFraction.getReducedFraction(0, -1));
try {
BigFraction.getReducedFraction(1, 0);
Assertions.fail("expecting ArithmeticException");
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 d36ffaa..05a777f 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
@@ -247,11 +247,11 @@ public class FractionTest {
public void testMath1261() {
final Fraction a = Fraction.of(Integer.MAX_VALUE, 2);
final Fraction b = a.multiply(2);
- Assert.assertEquals(b, Fraction.of(Integer.MAX_VALUE));
+ Assertions.assertEquals(b, Fraction.of(Integer.MAX_VALUE));
final Fraction c = Fraction.of(2, Integer.MAX_VALUE);
final Fraction d = c.divide(2);
- Assert.assertEquals(d, Fraction.of(1, Integer.MAX_VALUE));
+ Assertions.assertEquals(d, Fraction.of(1, Integer.MAX_VALUE));
}
@Test
@@ -583,11 +583,11 @@ public class FractionTest {
public void testEqualsAndHashCode() {
Fraction zero = Fraction.of(0,1);
Fraction nullFraction = null;
- Assert.assertEquals(zero, zero);
- Assert.assertNotEquals(zero, nullFraction);
- Assert.assertNotEquals(zero, Double.valueOf(0), 0.0);
+ Assertions.assertEquals(zero, zero);
+ Assertions.assertNotEquals(nullFraction, zero);
+ Assertions.assertNotEquals(0.0, zero);
Fraction zero2 = Fraction.of(0,2);
- Assert.assertEquals(zero, zero2);
+ Assertions.assertEquals(zero, zero2);
Assertions.assertEquals(zero.hashCode(), zero2.hashCode());
Fraction one = Fraction.of(1,1);
Assertions.assertFalse((one.equals(zero) ||zero.equals(one)));
@@ -596,8 +596,8 @@ public class FractionTest {
@Test
public void testGetReducedFraction() {
Fraction threeFourths = Fraction.of(3, 4);
- Assert.assertEquals(threeFourths, Fraction.getReducedFraction(6, 8));
- Assert.assertEquals(Fraction.ZERO, Fraction.getReducedFraction(0, -1));
+ Assertions.assertEquals(threeFourths, Fraction.getReducedFraction(6, 8));
+ Assertions.assertEquals(Fraction.ZERO, Fraction.getReducedFraction(0, -1));
try {
Fraction.getReducedFraction(1, 0);
Assertions.fail("expecting ArithmeticException");
[commons-numbers] 34/34: Merge branch 'NUMBERS-115__heinrich'
Posted by er...@apache.org.
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 c3586cf3df16b08c0b1fbd0e3275d07ae3eb3a8d
Merge: 934be57 b1a114f
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Tue Jun 18 15:11:32 2019 +0200
Merge branch 'NUMBERS-115__heinrich'
Completes issue NUMBERS-115.
Closes #48.
.../numbers/angle/PlaneAngleRadiansTest.java | 34 +-
.../commons/numbers/angle/PlaneAngleTest.java | 74 ++--
.../commons/numbers/arrays/CosAngleTest.java | 24 +-
.../numbers/arrays/LinearCombinationTest.java | 88 ++--
.../commons/numbers/arrays/SafeNormTest.java | 18 +-
.../BinomialCoefficientDoubleTest.java | 48 ++-
.../combinatorics/BinomialCoefficientTest.java | 89 ++--
.../numbers/combinatorics/CombinationsTest.java | 84 ++--
.../numbers/combinatorics/FactorialDoubleTest.java | 47 ++-
.../numbers/combinatorics/FactorialTest.java | 20 +-
.../combinatorics/LogBinomialCoefficientTest.java | 36 +-
.../numbers/combinatorics/LogFactorialTest.java | 30 +-
.../numbers/complex/streams/ComplexUtilsTest.java | 174 +++++---
.../commons/numbers/complex/streams/TestUtils.java | 22 +-
.../commons/numbers/complex/CStandardTest.java | 13 +-
.../commons/numbers/complex/ComplexTest.java | 404 +++++++++---------
.../apache/commons/numbers/complex/TestUtils.java | 46 +--
.../commons/numbers/core/ArithmeticUtilsTest.java | 412 +++++++++----------
.../apache/commons/numbers/core/PrecisionTest.java | 449 ++++++++++-----------
.../org/apache/commons/numbers/core/TestUtils.java | 37 +-
.../commons/numbers/field/FieldParametricTest.java | 155 +++----
.../commons/numbers/field/FieldTestData.java | 28 +-
.../apache/commons/numbers/field/FieldsList.java | 13 +-
.../commons/numbers/fraction/BigFraction.java | 10 +-
.../apache/commons/numbers/fraction/Fraction.java | 14 +-
.../commons/numbers/fraction/BigFractionTest.java | 286 ++++++-------
.../numbers/fraction/ContinuedFractionTest.java | 10 +-
.../commons/numbers/fraction/FractionTest.java | 129 +++---
.../apache/commons/numbers/gamma/DigammaTest.java | 36 +-
.../commons/numbers/gamma/ErfDifferenceTest.java | 8 +-
.../org/apache/commons/numbers/gamma/ErfTest.java | 66 +--
.../org/apache/commons/numbers/gamma/ErfcTest.java | 10 +-
.../apache/commons/numbers/gamma/GammaTest.java | 10 +-
.../commons/numbers/gamma/InvGamma1pm1Test.java | 24 +-
.../commons/numbers/gamma/InverseErfTest.java | 18 +-
.../commons/numbers/gamma/InverseErfcTest.java | 18 +-
.../numbers/gamma/LanczosApproximationTest.java | 12 +-
.../apache/commons/numbers/gamma/LogBetaTest.java | 55 ++-
.../commons/numbers/gamma/LogGamma1pTest.java | 18 +-
.../commons/numbers/gamma/LogGammaSumTest.java | 30 +-
.../apache/commons/numbers/gamma/LogGammaTest.java | 12 +-
.../commons/numbers/gamma/RegularizedBetaTest.java | 10 +-
.../numbers/gamma/RegularizedGammaTest.java | 8 +-
.../apache/commons/numbers/gamma/TrigammaTest.java | 12 +-
.../apache/commons/numbers/primes/PrimesTest.java | 50 +--
.../commons/numbers/primes/SmallPrimesTest.java | 51 +--
.../commons/numbers/quaternion/QuaternionTest.java | 335 ++++++++-------
.../commons/numbers/quaternion/SlerpTest.java | 61 +--
.../numbers/rootfinder/BrentSolverTest.java | 101 ++---
pom.xml | 5 +
50 files changed, 1981 insertions(+), 1763 deletions(-)
[commons-numbers] 20/34: Order of arguments
Posted by er...@apache.org.
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 e8a071ee1f664e3b855c734e528d1dcda25472ee
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Sun Jun 9 22:27:48 2019 -0700
Order of arguments
---
.../commons/numbers/combinatorics/BinomialCoefficientTest.java | 2 +-
.../numbers/combinatorics/LogBinomialCoefficientTest.java | 2 +-
.../java/org/apache/commons/numbers/complex/ComplexTest.java | 8 ++++----
.../org/apache/commons/numbers/fraction/BigFractionTest.java | 4 ++--
.../java/org/apache/commons/numbers/fraction/FractionTest.java | 8 ++++----
.../org/apache/commons/numbers/primes/SmallPrimesTest.java | 6 +++---
.../org/apache/commons/numbers/rootfinder/BrentSolverTest.java | 10 +++++-----
7 files changed, 20 insertions(+), 20 deletions(-)
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 ad87d12..9c1dde2 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
@@ -37,7 +37,7 @@ public class BinomialCoefficientTest {
/** Verify that b(0,0) = 1 */
@Test
public void test0Choose0() {
- Assertions.assertEquals(BinomialCoefficient.value(0, 0), 1);
+ Assertions.assertEquals(1, BinomialCoefficient.value(0, 0));
}
@Test
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 22d3124..1e1a8f5 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
@@ -27,7 +27,7 @@ public class LogBinomialCoefficientTest {
/** Verify that b(0,0) = 1 */
@Test
public void test0Choose0() {
- Assert.assertEquals(LogBinomialCoefficient.value(0, 0), 0d, 0);
+ Assert.assertEquals(0d, LogBinomialCoefficient.value(0, 0), 0);
}
@Test
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 65bc505..014aeb6 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
@@ -96,7 +96,7 @@ public class ComplexTest {
Complex x = Complex.ofCartesian(1, 1);
Complex z = Complex.ofCartesian(inf, 0);
Complex w = x.add(z);
- Assertions.assertEquals(w.getImaginary(), 1, 0);
+ Assertions.assertEquals(1, w.getImaginary(), 0);
Assertions.assertEquals(inf, w.getReal(), 0);
x = Complex.ofCartesian(neginf, 0);
@@ -182,14 +182,14 @@ public class ComplexTest {
public void testDivideZero() {
Complex x = Complex.ofCartesian(3.0, 4.0);
Complex z = x.divide(Complex.ZERO);
- Assertions.assertEquals(z, Complex.INF);
+ Assertions.assertEquals(Complex.INF, z);
}
@Test
public void testDivideZeroZero() {
Complex x = Complex.ofCartesian(0.0, 0.0);
Complex z = x.divide(Complex.ZERO);
- Assertions.assertEquals(z, NAN);
+ Assertions.assertEquals(NAN, z);
}
@Test
@@ -346,7 +346,7 @@ public class ComplexTest {
Complex x = Complex.ofCartesian(1, 1);
Complex z = Complex.ofCartesian(neginf, 0);
Complex w = x.subtract(z);
- Assertions.assertEquals(w.getImaginary(), 1, 0);
+ Assertions.assertEquals(1, w.getImaginary(), 0);
Assertions.assertEquals(inf, w.getReal(), 0);
x = Complex.ofCartesian(neginf, 0);
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 671164d..52dd953 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
@@ -618,8 +618,8 @@ public class BigFractionTest {
} catch (ArithmeticException ex) {
// expected
}
- Assert.assertEquals(BigFraction.getReducedFraction(2, Integer.MIN_VALUE).getNumeratorAsInt(), -1);
- Assert.assertEquals(BigFraction.getReducedFraction(1, -1).getNumeratorAsInt(), -1);
+ Assert.assertEquals(-1, BigFraction.getReducedFraction(2, Integer.MIN_VALUE).getNumeratorAsInt());
+ Assert.assertEquals(-1, BigFraction.getReducedFraction(1, -1).getNumeratorAsInt());
}
@Test
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 557895e..30c9d33 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
@@ -604,10 +604,10 @@ public class FractionTest {
} catch (ArithmeticException ignored) {
// expected
}
- Assert.assertEquals(Fraction.getReducedFraction
- (2, Integer.MIN_VALUE).getNumerator(),-1);
- Assert.assertEquals(Fraction.getReducedFraction
- (1, -1).getNumerator(), -1);
+ Assert.assertEquals(-1, Fraction.getReducedFraction
+ (2, Integer.MIN_VALUE).getNumerator());
+ Assert.assertEquals(-1, Fraction.getReducedFraction
+ (1, -1).getNumerator());
}
@Test
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 06023c5..a4fdab5 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
@@ -59,7 +59,7 @@ public class SmallPrimesTest {
final int penultimatePrime = SmallPrimes.PRIMES[SmallPrimes.PRIMES.length-2];
final int result = SmallPrimes.smallTrialDivision(penultimatePrime*SmallPrimes.PRIMES_LAST, factors);
Assertions.assertEquals(1, result);
- Assertions.assertEquals(Arrays.asList(penultimatePrime, SmallPrimes.PRIMES_LAST), factors);
+ Assertions.assertEquals(factors, Arrays.asList(penultimatePrime, SmallPrimes.PRIMES_LAST));
}
@Test
@@ -83,7 +83,7 @@ public class SmallPrimesTest {
final List<Integer> factors = new ArrayList<Integer>();
final int result = SmallPrimes.boundedTrialDivision(LARGE_PRIME[0]*LARGE_PRIME[1], Integer.MAX_VALUE, factors);
Assertions.assertEquals(LARGE_PRIME[1], result);
- Assertions.assertEquals(Arrays.asList(LARGE_PRIME[0], LARGE_PRIME[1]), factors);
+ Assertions.assertEquals(factors, Arrays.asList(LARGE_PRIME[0], LARGE_PRIME[1]));
}
@Test
@@ -91,7 +91,7 @@ public class SmallPrimesTest {
final List<Integer> factors = new ArrayList<Integer>();
final int result = SmallPrimes.boundedTrialDivision(LARGE_PRIME[0]*LARGE_PRIME[0], Integer.MAX_VALUE, factors);
Assertions.assertEquals(LARGE_PRIME[0], result);
- Assertions.assertEquals(Arrays.asList(LARGE_PRIME[0], LARGE_PRIME[0]), factors);
+ Assertions.assertEquals(factors, Arrays.asList(LARGE_PRIME[0], LARGE_PRIME[0]));
}
@Test
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 37f0126..84a2e97 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
@@ -42,13 +42,13 @@ public class BrentSolverTest {
// Somewhat benign interval. The function is monotonous.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 3, 4);
- Assertions.assertEquals(result, Math.PI, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(Math.PI, result, DEFAULT_ABSOLUTE_ACCURACY);
Assertions.assertTrue(f.getCallsCount() <= 7);
// Larger and somewhat less benign interval. The function is grows first.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 1, 4);
- Assertions.assertEquals(result, Math.PI, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(Math.PI, result, DEFAULT_ABSOLUTE_ACCURACY);
Assertions.assertTrue(f.getCallsCount() <= 8);
}
@@ -73,21 +73,21 @@ public class BrentSolverTest {
// the root in the first iteration.
f = new MonitoredFunction(func);
result = solver.findRoot(f, -0.2, 0.2);
- Assertions.assertEquals(result, 0, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(0, result, DEFAULT_ABSOLUTE_ACCURACY);
Assertions.assertTrue(f.getCallsCount() <= 3);
// 1 iterations on i586 JDK 1.4.1.
// Asymmetric bracket around 0. Contains extremum.
f = new MonitoredFunction(func);
result = solver.findRoot(f, -0.1, 0.3);
- Assertions.assertEquals(result, 0, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(0, result, DEFAULT_ABSOLUTE_ACCURACY);
// 5 iterations on i586 JDK 1.4.1.
Assertions.assertTrue(f.getCallsCount() <= 7);
// Large bracket around 0. Contains two extrema.
f = new MonitoredFunction(func);
result = solver.findRoot(f, -0.3, 0.45);
- Assertions.assertEquals(result, 0, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(0, result, DEFAULT_ABSOLUTE_ACCURACY);
// 6 iterations on i586 JDK 1.4.1.
Assertions.assertTrue(f.getCallsCount() <= 8);
[commons-numbers] 13/34: Merge branch 'eax/simple-migrate-map' of
github.com:grimreaper/commons-numbers into eax/simple-migrate-map
Posted by er...@apache.org.
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 a11713ee1cb3c0a6bc59d18b65f6d05c1866b8fe
Merge: 526d93f 280563c
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Sat Jun 8 17:55:13 2019 -0700
Merge branch 'eax/simple-migrate-map' of github.com:grimreaper/commons-numbers into eax/simple-migrate-map
.../commons/numbers/core/ArithmeticUtilsTest.java | 361 +++++++++--------
.../apache/commons/numbers/core/PrecisionTest.java | 446 ++++++++++-----------
.../org/apache/commons/numbers/core/TestUtils.java | 37 +-
3 files changed, 421 insertions(+), 423 deletions(-)
[commons-numbers] 17/34: Migrate commons-numbers-complex to JUnit 5
Posted by er...@apache.org.
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 <he...@gmx.at>
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());
}
}
[commons-numbers] 19/34: BrentSolverTest: do JUnit 5
Posted by er...@apache.org.
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 6ee85788f7c2e8eaf38dc4c5ed4d17e1590351a6
Author: Eitan Adler <li...@eitanadler.com>
AuthorDate: Sun Jun 9 22:27:16 2019 -0700
BrentSolverTest: do JUnit 5
---
.../numbers/rootfinder/BrentSolverTest.java | 101 +++++++++++----------
1 file changed, 51 insertions(+), 50 deletions(-)
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 506d155..37f0126 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
@@ -14,8 +14,9 @@
package org.apache.commons.numbers.rootfinder;
import java.util.function.DoubleUnaryOperator;
-import org.junit.Assert;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
* Test cases for the {@link BrentSolver} class.
@@ -41,14 +42,14 @@ public class BrentSolverTest {
// Somewhat benign interval. The function is monotonous.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 3, 4);
- Assert.assertEquals(result, Math.PI, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() <= 7);
+ Assertions.assertEquals(result, Math.PI, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertTrue(f.getCallsCount() <= 7);
// Larger and somewhat less benign interval. The function is grows first.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 1, 4);
- Assert.assertEquals(result, Math.PI, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() <= 8);
+ Assertions.assertEquals(result, Math.PI, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertTrue(f.getCallsCount() <= 8);
}
@Test
@@ -72,67 +73,67 @@ public class BrentSolverTest {
// the root in the first iteration.
f = new MonitoredFunction(func);
result = solver.findRoot(f, -0.2, 0.2);
- Assert.assertEquals(result, 0, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() <= 3);
+ Assertions.assertEquals(result, 0, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertTrue(f.getCallsCount() <= 3);
// 1 iterations on i586 JDK 1.4.1.
// Asymmetric bracket around 0. Contains extremum.
f = new MonitoredFunction(func);
result = solver.findRoot(f, -0.1, 0.3);
- Assert.assertEquals(result, 0, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(result, 0, DEFAULT_ABSOLUTE_ACCURACY);
// 5 iterations on i586 JDK 1.4.1.
- Assert.assertTrue(f.getCallsCount() <= 7);
+ Assertions.assertTrue(f.getCallsCount() <= 7);
// Large bracket around 0. Contains two extrema.
f = new MonitoredFunction(func);
result = solver.findRoot(f, -0.3, 0.45);
- Assert.assertEquals(result, 0, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(result, 0, DEFAULT_ABSOLUTE_ACCURACY);
// 6 iterations on i586 JDK 1.4.1.
- Assert.assertTrue(f.getCallsCount() <= 8);
+ Assertions.assertTrue(f.getCallsCount() <= 8);
// Benign bracket around 0.5, function is monotonous.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.3, 0.7);
- Assert.assertEquals(0.5, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(0.5, result, DEFAULT_ABSOLUTE_ACCURACY);
// 6 iterations on i586 JDK 1.4.1.
- Assert.assertTrue(f.getCallsCount() <= 9);
+ Assertions.assertTrue(f.getCallsCount() <= 9);
// Less benign bracket around 0.5, contains one extremum.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.2, 0.6);
- Assert.assertEquals(0.5, result, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() <= 10);
+ Assertions.assertEquals(0.5, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertTrue(f.getCallsCount() <= 10);
// Large, less benign bracket around 0.5, contains both extrema.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.05, 0.95);
- Assert.assertEquals(0.5, result, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() <= 11);
+ Assertions.assertEquals(0.5, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertTrue(f.getCallsCount() <= 11);
// Relatively benign bracket around 1, function is monotonous. Fast growth for x>1
// is still a problem.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.85, 1.25);
- Assert.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() <= 11);
+ Assertions.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertTrue(f.getCallsCount() <= 11);
// Less benign bracket around 1 with extremum.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.8, 1.2);
- Assert.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() <= 11);
+ Assertions.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertTrue(f.getCallsCount() <= 11);
// Large bracket around 1. Monotonous.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.85, 1.75);
- Assert.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() <= 13);
+ Assertions.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertTrue(f.getCallsCount() <= 13);
// Large bracket around 1. Interval contains extremum.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.55, 1.45);
- Assert.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() <= 10);
+ Assertions.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertTrue(f.getCallsCount() <= 10);
}
@Test
@@ -148,17 +149,17 @@ public class BrentSolverTest {
// Very large bracket around 1 for testing fast growth behaviour.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.85, 5);
- Assert.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() <= 15);
+ 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);
- Assert.fail("Expected too many calls condition");
+ Assertions.fail("Expected too many calls condition");
} catch (IllegalStateException ex) {
// Expected.
// Ensure expected error condition.
- Assert.assertFalse(ex.getMessage().indexOf("too many calls") == -1);
+ Assertions.assertFalse(ex.getMessage().indexOf("too many calls") == -1);
}
}
@@ -171,16 +172,16 @@ public class BrentSolverTest {
// Endpoint is root.
double result = solver.findRoot(f, Math.PI, 4);
- Assert.assertEquals(Math.PI, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(Math.PI, result, DEFAULT_ABSOLUTE_ACCURACY);
result = solver.findRoot(f, 3, Math.PI);
- Assert.assertEquals(Math.PI, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(Math.PI, result, DEFAULT_ABSOLUTE_ACCURACY);
result = solver.findRoot(f, Math.PI, 3.5, 4);
- Assert.assertEquals(Math.PI, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(Math.PI, result, DEFAULT_ABSOLUTE_ACCURACY);
result = solver.findRoot(f, 3, 3.07, Math.PI);
- Assert.assertEquals(Math.PI, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(Math.PI, result, DEFAULT_ABSOLUTE_ACCURACY);
}
@Test
@@ -191,24 +192,24 @@ public class BrentSolverTest {
DEFAULT_FUNCTION_ACCURACY);
try { // Bad interval.
solver.findRoot(f, 1, -1);
- Assert.fail("Expecting bad interval condition");
+ Assertions.fail("Expecting bad interval condition");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assert.assertFalse(ex.getMessage().indexOf(" > ") == -1);
+ Assertions.assertFalse(ex.getMessage().indexOf(" > ") == -1);
}
try { // No bracketing.
solver.findRoot(f, 1, 1.5);
- Assert.fail("Expecting non-bracketing condition");
+ Assertions.fail("Expecting non-bracketing condition");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assert.assertFalse(ex.getMessage().indexOf("No bracketing") == -1);
+ Assertions.assertFalse(ex.getMessage().indexOf("No bracketing") == -1);
}
try { // No bracketing.
solver.findRoot(f, 1, 1.2, 1.5);
- Assert.fail("Expecting non-bracketing condition");
+ Assertions.fail("Expecting non-bracketing condition");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assert.assertFalse(ex.getMessage().indexOf("No bracketing") == -1);
+ Assertions.assertFalse(ex.getMessage().indexOf("No bracketing") == -1);
}
}
@@ -222,10 +223,10 @@ public class BrentSolverTest {
try {
// Invalid guess (it *is* a root, but outside of the range).
double result = solver.findRoot(func, 0.0, 7.0, 0.6);
- Assert.fail("an out of range condition was expected");
+ Assertions.fail("an out of range condition was expected");
} catch (SolverException ex) {
// Ensure expected error condition.
- Assert.assertFalse(ex.getMessage().indexOf("out of range") == -1);
+ Assertions.assertFalse(ex.getMessage().indexOf("out of range") == -1);
}
}
@@ -241,26 +242,26 @@ public class BrentSolverTest {
// No guess.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.6, 7.0);
- Assert.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
final int referenceCallsCount = f.getCallsCount();
- Assert.assertTrue(referenceCallsCount >= 13);
+ Assertions.assertTrue(referenceCallsCount >= 13);
// Bad guess.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.6, 0.61, 7.0);
- Assert.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() > referenceCallsCount);
+ Assertions.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertTrue(f.getCallsCount() > referenceCallsCount);
// Good guess.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.6, 0.9999990001, 7.0);
- Assert.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertTrue(f.getCallsCount() < referenceCallsCount);
+ Assertions.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertTrue(f.getCallsCount() < referenceCallsCount);
// Perfect guess.
f = new MonitoredFunction(func);
result = solver.findRoot(f, 0.6, 1.0, 7.0);
- Assert.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
- Assert.assertEquals(1, f.getCallsCount());
+ Assertions.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
+ Assertions.assertEquals(1, f.getCallsCount());
}
}
[commons-numbers] 31/34: Remove unnecessary parentheses in Test
annotations
Posted by er...@apache.org.
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 af0d00f2c8eb67361c90b34cae88e7c832397dfb
Author: Schamschi <he...@gmx.at>
AuthorDate: Sat Jun 15 12:26:18 2019 +0200
Remove unnecessary parentheses in Test annotations
---
.../org/apache/commons/numbers/combinatorics/FactorialDoubleTest.java | 2 +-
.../java/org/apache/commons/numbers/combinatorics/FactorialTest.java | 4 ++--
.../commons/numbers/combinatorics/LogBinomialCoefficientTest.java | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
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 7bc8ce6..19d7b76 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
@@ -50,7 +50,7 @@ public class FactorialDoubleTest {
Double.POSITIVE_INFINITY, FactorialDouble.create().value(n), 0d, n + "!");
}
- @Test()
+ @Test
public void testNonPositiveArgument() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> FactorialDouble.create().value(-1)
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 ef75ab7..17cad27 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
@@ -35,14 +35,14 @@ public class FactorialTest {
}
}
- @Test()
+ @Test
public void testPrecondition1() {
Assertions.assertThrows(IllegalArgumentException.class,
() -> Factorial.value(-1)
);
}
- @Test()
+ @Test
public 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 52c010d..8a3af5a 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
@@ -53,14 +53,14 @@ public class LogBinomialCoefficientTest {
}
}
- @Test()
+ @Test
public void testBinomialCoefficientFail1() {
Assertions.assertThrows(CombinatoricsException.class,
() -> LogBinomialCoefficient.value(4, 5)
);
}
- @Test()
+ @Test
public void testBinomialCoefficientFail2() {
Assertions.assertThrows(CombinatoricsException.class,
() -> LogBinomialCoefficient.value(-1, -2)