commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aherb...@apache.org
Subject [commons-numbers] 04/26: Rename powFractionTestCases to powTestCases
Date Thu, 16 Apr 2020 12:18:19 GMT
This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 7fa4f4be1d2b2ab36520dbe98ef950a3b267d264
Author: Alex Herbert <aherbert@apache.org>
AuthorDate: Sun Apr 12 21:32:11 2020 +0100

    Rename powFractionTestCases to powTestCases
---
 .../commons/numbers/fraction/BigFractionTest.java    | 20 ++++++++++----------
 .../commons/numbers/fraction/CommonTestCases.java    | 16 +++++++++-------
 .../commons/numbers/fraction/FractionTest.java       | 18 +++++++++---------
 3 files changed, 28 insertions(+), 26 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 fe504d3..3a24a20 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,14 +88,6 @@ public class BigFractionTest {
             () -> BigFraction.from(2.0 * Integer.MAX_VALUE, 1.0e-5, 100000));
     }
 
-    @Test
-    public void testGoldenRatio() {
-        // the golden ratio is notoriously a difficult number for continuous fraction
-        Assertions.assertThrows(FractionException.class,
-            () -> BigFraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
-        );
-    }
-
     // MATH-179
     @Test
     public void testDoubleConstructor() throws Exception {
@@ -142,11 +134,19 @@ public class BigFractionTest {
         }
     }
 
+    @Test
+    public void testDoubleConstructorGoldenRatioThrows() {
+        // the golden ratio is notoriously a difficult number for continuous fraction
+        Assertions.assertThrows(FractionException.class,
+            () -> BigFraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
+        );
+    }
+
     // MATH-1029
     @Test
     public void testPositiveValueOverflow() {
         Assertions.assertThrows(ArithmeticException.class,
-            () -> assertFraction((long) 1e10, 1, BigFraction.from(1e10, 1000))
+            () -> BigFraction.from(1e10, 1000)
         );
     }
 
@@ -543,7 +543,7 @@ public class BigFractionTest {
 
     @Test
     public void testPow() {
-        for (CommonTestCases.BinaryIntOperatorTestCase testCase : CommonTestCases.powFractionTestCases())
{
+        for (CommonTestCases.BinaryIntOperatorTestCase testCase : CommonTestCases.powTestCases())
{
             BigFraction f1 = BigFraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
             int exponent = testCase.secondOperand;
             assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f1.pow(exponent));
diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
index efebc48..336add7 100644
--- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
+++ b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
@@ -52,6 +52,8 @@ final class CommonTestCases {
      */
     private static final List<UnaryOperatorTestCase> negateTestCasesList;
 
+    // TODO addIntTestCasesList
+
     /**
      * See {@link #addFractionTestCases()}
      */
@@ -73,9 +75,9 @@ final class CommonTestCases {
     private static final List<BinaryOperatorTestCase> subtractFractionTestCasesList;
 
     /**
-     * See {@link #powFractionTestCases()}
+     * See {@link #powTestCases()}
      */
-    private static final List<BinaryIntOperatorTestCase> powFractionTestCasesList;
+    private static final List<BinaryIntOperatorTestCase> powTestCasesList;
 
     static {
         numDenConstructorTestCasesList = collectNumDenConstructorTestCases();
@@ -87,7 +89,7 @@ final class CommonTestCases {
         divideByFractionTestCasesList = collectDivideByFractionTestCases();
         multiplyByFractionTestCasesList = collectMultiplyByFractionTestCases();
         subtractFractionTestCasesList = collectSubtractFractionTestCases();
-        powFractionTestCasesList = collectPowFractionTestCases();
+        powTestCasesList = collectPowTestCases();
     }
 
     private CommonTestCases() {}
@@ -382,10 +384,10 @@ final class CommonTestCases {
 
     /**
      * Defines test cases as described in
-     * {@link #powFractionTestCases()} and collects them into a {@code List}.
+     * {@link #powTestCases()} and collects them into a {@code List}.
      * @return a list of test cases as described above
      */
-    private static List<BinaryIntOperatorTestCase> collectPowFractionTestCases() {
+    private static List<BinaryIntOperatorTestCase> collectPowTestCases() {
         List<BinaryIntOperatorTestCase> testCases = new ArrayList<>();
 
         testCases.add(new BinaryIntOperatorTestCase(3, 7, 0, 1, 1));
@@ -537,8 +539,8 @@ final class CommonTestCases {
      *
      * @return a list of test cases as described above
      */
-    static List<BinaryIntOperatorTestCase> powFractionTestCases() {
-        return Collections.unmodifiableList(powFractionTestCasesList);
+    static List<BinaryIntOperatorTestCase> powTestCases() {
+        return Collections.unmodifiableList(powTestCasesList);
     }
 
     // CHECKSTYLE: stop VisibilityModifier
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 584c28f..fccf015 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
@@ -65,14 +65,6 @@ public class FractionTest {
         Assertions.assertThrows(ArithmeticException.class, () -> Fraction.of(1, 0));
     }
 
-    @Test
-    public void testGoldenRatio() {
-        // the golden ratio is notoriously a difficult number for continuous fraction
-        Assertions.assertThrows(ArithmeticException.class,
-            () -> Fraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
-        );
-    }
-
     // MATH-179
     @Test
     public void testDoubleConstructor() throws Exception  {
@@ -114,6 +106,14 @@ public class FractionTest {
     }
 
     @Test
+    public void testDoubleConstructorGoldenRatioThrows() {
+        // the golden ratio is notoriously a difficult number for continuous fraction
+        Assertions.assertThrows(ArithmeticException.class,
+            () -> Fraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
+        );
+    }
+
+    @Test
     public void testIntegerOverflow() {
         checkIntegerOverflow(0.75000000001455192);
         checkIntegerOverflow(1.0e10);
@@ -396,7 +396,7 @@ public class FractionTest {
 
     @Test
     public void testPow() {
-        for (CommonTestCases.BinaryIntOperatorTestCase testCase : CommonTestCases.powFractionTestCases())
{
+        for (CommonTestCases.BinaryIntOperatorTestCase testCase : CommonTestCases.powTestCases())
{
             Fraction f1 = Fraction.of(testCase.firstOperandNumerator, testCase.firstOperandDenominator);
             int exponent = testCase.secondOperand;
             assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f1.pow(exponent));


Mime
View raw message