Fraction: Add tests for Integer.MIN_VALUE in intValue()

The intValue cannot be done by simple integer divide arithmetic:

numerator / denominator

This will return Integer.MIN_VALUE for the fraction Integer.MIN_VALUE /
-1. The correct result is Integer.MAX_VALUE (as the fraction is
positive).

integer divide arithmetic can be used in longValue().
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 e9b7199..8a23872 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
@@ -444,7 +444,7 @@
      * Returns the {@code float} value closest to this fraction.
      * This calculates the fraction as numerator divided by denominator.
      *
-     * @return the fraction as {@code float}.
+     * @return the fraction as a {@code float}.
      */
     @Override
     public float floatValue() {
@@ -458,6 +458,8 @@
      */
     @Override
     public int intValue() {
+        // Note: numerator / denominator fails for Integer.MIN_VALUE / -1.
+        // Casting the double value handles this case.
         return (int) doubleValue();
     }
 
@@ -468,7 +470,7 @@
      */
     @Override
     public long longValue() {
-        return (long) doubleValue();
+        return (long) numerator / denominator;
     }
 
     /**
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 798d6fb..80628fa 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
@@ -244,6 +244,11 @@
         Assertions.assertEquals(-1, Fraction.of(-3, 2).intValue());
         Assertions.assertEquals(-1, Fraction.of(3, -2).intValue());
 
+        Assertions.assertEquals(0, Fraction.of(1, Integer.MIN_VALUE).intValue());
+        Assertions.assertEquals(0, Fraction.of(-1, Integer.MIN_VALUE).intValue());
+        Assertions.assertEquals(Integer.MIN_VALUE, Fraction.of(Integer.MIN_VALUE, 1).intValue());
+        Assertions.assertEquals(Integer.MAX_VALUE, Fraction.of(Integer.MIN_VALUE, -1).intValue());
+
         Assertions.assertEquals(0, ZERO_P.intValue());
         Assertions.assertEquals(0, ZERO_N.intValue());
     }
@@ -260,6 +265,11 @@
         Assertions.assertEquals(-1L, Fraction.of(-3, 2).longValue());
         Assertions.assertEquals(-1L, Fraction.of(3, -2).longValue());
 
+        Assertions.assertEquals(0, Fraction.of(1, Integer.MIN_VALUE).longValue());
+        Assertions.assertEquals(0, Fraction.of(-1, Integer.MIN_VALUE).longValue());
+        Assertions.assertEquals(Integer.MIN_VALUE, Fraction.of(Integer.MIN_VALUE, 1).longValue());
+        Assertions.assertEquals(Integer.MAX_VALUE + 1L, Fraction.of(Integer.MIN_VALUE, -1).longValue());
+
         Assertions.assertEquals(0L, ZERO_P.longValue());
         Assertions.assertEquals(0L, ZERO_N.longValue());
     }