You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ps...@apache.org on 2005/10/16 00:33:19 UTC

svn commit: r321510 - in /jakarta/commons/proper/math/branches/MATH_1_1/src: java/org/apache/commons/math/util/MathUtils.java test/org/apache/commons/math/util/MathUtilsTest.java

Author: psteitz
Date: Sat Oct 15 15:33:14 2005
New Revision: 321510

URL: http://svn.apache.org/viewcvs?rev=321510&view=rev
Log:
Fixed incorrect error message in MathUtils.subAndCheck
PR# 37093
Reported by elharo at metalab dot unc dot edu

Modified:
    jakarta/commons/proper/math/branches/MATH_1_1/src/java/org/apache/commons/math/util/MathUtils.java
    jakarta/commons/proper/math/branches/MATH_1_1/src/test/org/apache/commons/math/util/MathUtilsTest.java

Modified: jakarta/commons/proper/math/branches/MATH_1_1/src/java/org/apache/commons/math/util/MathUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/branches/MATH_1_1/src/java/org/apache/commons/math/util/MathUtils.java?rev=321510&r1=321509&r2=321510&view=diff
==============================================================================
--- jakarta/commons/proper/math/branches/MATH_1_1/src/java/org/apache/commons/math/util/MathUtils.java (original)
+++ jakarta/commons/proper/math/branches/MATH_1_1/src/java/org/apache/commons/math/util/MathUtils.java Sat Oct 15 15:33:14 2005
@@ -733,7 +733,7 @@
     public static int subAndCheck(int x, int y) {
         long s = (long)x - (long)y;
         if (s < Integer.MIN_VALUE || s > Integer.MAX_VALUE) {
-            throw new ArithmeticException("overflow: add");
+            throw new ArithmeticException("overflow: subtract");
         }
         return (int)s;
     }

Modified: jakarta/commons/proper/math/branches/MATH_1_1/src/test/org/apache/commons/math/util/MathUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/branches/MATH_1_1/src/test/org/apache/commons/math/util/MathUtilsTest.java?rev=321510&r1=321509&r2=321510&view=diff
==============================================================================
--- jakarta/commons/proper/math/branches/MATH_1_1/src/test/org/apache/commons/math/util/MathUtilsTest.java (original)
+++ jakarta/commons/proper/math/branches/MATH_1_1/src/test/org/apache/commons/math/util/MathUtilsTest.java Sat Oct 15 15:33:14 2005
@@ -76,6 +76,16 @@
         } catch (ArithmeticException ex) {}
     }
     
+    public void testSubAndCheckErrorMessage() {
+        int big = Integer.MAX_VALUE;
+        int bigNeg = Integer.MIN_VALUE;
+        try {
+            int res = MathUtils.subAndCheck(big, -1);
+        } catch (ArithmeticException ex) {
+            assertEquals("overflow: subtract", ex.getMessage());
+        }
+    }
+    
     public void testBinomialCoefficient() {
         long[] bcoef5 = {1,5,10,10,5,1};
         long[] bcoef6 = {1,6,15,20,15,6,1};



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org