Skip to content

Commit

Permalink
Added missing fail statements to some MathUtils tests.
Browse files Browse the repository at this point in the history
PR# 37095
Reported by elharo at metalab dot unc dot edu


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/branches/MATH_1_1@321515 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
psteitz committed Oct 16, 2005
1 parent 0fd2b3d commit bdf15c7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/test/org/apache/commons/math/util/MathUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ public void testAddAndCheck() {
assertEquals(big, MathUtils.addAndCheck(big, 0));
try {
int res = MathUtils.addAndCheck(big, 1);
fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {}
try {
int res = MathUtils.addAndCheck(bigNeg, -1);
fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {}
}

Expand All @@ -58,9 +60,11 @@ public void testMulAndCheck() {
assertEquals(big, MathUtils.mulAndCheck(big, 1));
try {
int res = MathUtils.mulAndCheck(big, 2);
fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {}
try {
int res = MathUtils.mulAndCheck(bigNeg, 2);
fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {}
}

Expand All @@ -70,9 +74,11 @@ public void testSubAndCheck() {
assertEquals(big, MathUtils.subAndCheck(big, 0));
try {
int res = MathUtils.subAndCheck(big, -1);
fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {}
try {
int res = MathUtils.subAndCheck(bigNeg, 1);
fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {}
}

Expand All @@ -81,6 +87,7 @@ public void testSubAndCheckErrorMessage() {
int bigNeg = Integer.MIN_VALUE;
try {
int res = MathUtils.subAndCheck(big, -1);
fail("Expecting ArithmeticException");
} catch (ArithmeticException ex) {
assertEquals("overflow: subtract", ex.getMessage());
}
Expand Down

0 comments on commit bdf15c7

Please sign in to comment.