commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [commons-numbers] branch master updated: Unit tests.
Date Sat, 02 Nov 2019 23:49:40 GMT
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


The following commit(s) were added to refs/heads/master by this push:
     new a643546  Unit tests.
a643546 is described below

commit a643546293b4bd87de03f7e3798dde2372cc4e08
Author: Gilles Sadowski <gilles@harfang.homelinux.org>
AuthorDate: Sun Nov 3 00:49:07 2019 +0100

    Unit tests.
---
 .../apache/commons/numbers/fraction/BigFractionTest.java | 16 +++++++++-------
 .../apache/commons/numbers/fraction/FractionTest.java    |  8 +++++++-
 2 files changed, 16 insertions(+), 8 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 c6a5eaf..82ee513 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
@@ -158,11 +158,11 @@ public class BigFractionTest {
 
     @Test
     public void testCompareTo() {
-        BigFraction a = BigFraction.of(1, 2);
-        BigFraction b = BigFraction.of(1, 3);
-        BigFraction c = BigFraction.of(1, 2);
-        BigFraction d = BigFraction.of(-1, 2);
-        BigFraction e = BigFraction.of(1, -2);
+        final BigFraction a = BigFraction.of(1, 2);
+        final BigFraction b = BigFraction.of(1, 3);
+        final BigFraction c = BigFraction.of(1, 2);
+        final BigFraction d = BigFraction.of(-1, 2);
+        final BigFraction e = BigFraction.of(1, -2);
 
         Assertions.assertEquals(0, a.compareTo(a));
         Assertions.assertEquals(0, a.compareTo(c));
@@ -174,11 +174,13 @@ public class BigFractionTest {
         Assertions.assertEquals(1, a.compareTo(e));
         Assertions.assertEquals(0, d.compareTo(e));
 
+        Assertions.assertEquals(0, BigFraction.of(0, 3).compareTo(BigFraction.of(0, -2)));
+
         // 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);
+        final BigFraction pi1 = BigFraction.of(1068966896, 340262731);
+        final BigFraction pi2 = BigFraction.of( 411557987, 131002976);
         Assertions.assertEquals(-1, pi1.compareTo(pi2));
         Assertions.assertEquals(1, pi2.compareTo(pi1));
         Assertions.assertEquals(0.0, pi1.doubleValue() - pi2.doubleValue(), 1.0e-20);
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 6d7c27a..33ca53e 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
@@ -523,7 +523,10 @@ public class FractionTest {
             "01 / -02",
             "15 / 16",
             "-2 / 3",
-            "8 / 7"
+            "8 / 7",
+            "5",
+            "-3",
+            "-3"
         };
         Fraction[] fractions = {
             Fraction.of(1, 2),
@@ -537,6 +540,9 @@ public class FractionTest {
             Fraction.of(15, 16),
             Fraction.of(-2, 3),
             Fraction.of(8, 7),
+            Fraction.of(5, 1),
+            Fraction.of(-3, 1),
+            Fraction.of(3, -1),
         };
         int inc = 0;
         for (Fraction fraction : fractions) {


Mime
View raw message