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:17:07 UTC
[commons-numbers] 22/34: use JUnit 5 assertions
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++;
}