Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/inference/TestUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/inference/TestUtilsTest.java?rev=1044186&r1=1044185&r2=1044186&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/inference/TestUtilsTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/inference/TestUtilsTest.java Fri Dec 10 00:50:50 2010 @@ -19,15 +19,16 @@ package org.apache.commons.math.stat.inf import java.util.ArrayList; import java.util.List; +import org.apache.commons.math.exception.MathIllegalArgumentException; +import org.apache.commons.math.stat.descriptive.SummaryStatistics; + import junit.framework.TestCase; -import org.apache.commons.math.stat.descriptive.SummaryStatistics; /** * Test cases for the TestUtils class. * * @version $Revision$ $Date$ */ - public class TestUtilsTest extends TestCase { public TestUtilsTest(String name) { @@ -55,8 +56,8 @@ public class TestUtilsTest extends TestC try { TestUtils.chiSquareTest(expected1, observed1, 95); - fail("alpha out of range, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("alpha out of range, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } @@ -64,8 +65,8 @@ public class TestUtilsTest extends TestC double[] tooShortEx = { 1 }; try { TestUtils.chiSquare(tooShortEx, tooShortObs); - fail("arguments too short, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("arguments too short, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } @@ -74,8 +75,8 @@ public class TestUtilsTest extends TestC double[] unMatchedEx = { 1, 1, 2 }; try { TestUtils.chiSquare(unMatchedEx, unMatchedObs); - fail("arrays have different lengths, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("arrays have different lengths, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } @@ -83,8 +84,8 @@ public class TestUtilsTest extends TestC expected[0] = 0; try { TestUtils.chiSquareTest(expected, observed, .01); - fail("bad expected count, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("bad expected count, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } @@ -93,8 +94,8 @@ public class TestUtilsTest extends TestC observed[0] = -1; try { TestUtils.chiSquareTest(expected, observed, .01); - fail("bad expected count, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("bad expected count, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } @@ -119,8 +120,8 @@ public class TestUtilsTest extends TestC long[][] counts3 = { {40, 22, 43}, {91, 21, 28}, {60, 10}}; try { TestUtils.chiSquare(counts3); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // expected } @@ -128,15 +129,15 @@ public class TestUtilsTest extends TestC long[][] counts4 = {{40, 22, 43}}; try { TestUtils.chiSquare(counts4); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // expected } long[][] counts5 = {{40}, {40}, {30}, {10}}; try { TestUtils.chiSquare(counts5); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // expected } @@ -144,16 +145,16 @@ public class TestUtilsTest extends TestC long[][] counts6 = {{10, -2}, {30, 40}, {60, 90} }; try { TestUtils.chiSquare(counts6); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // expected } // bad alpha try { TestUtils.chiSquareTest(counts, 0); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // expected } } @@ -211,55 +212,55 @@ public class TestUtilsTest extends TestC try { TestUtils.t(mu, (double[]) null); - fail("arguments too short, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("arguments too short, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.t(mu, (SummaryStatistics) null); - fail("arguments too short, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("arguments too short, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.t(mu, emptyObs); - fail("arguments too short, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("arguments too short, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.t(mu, emptyStats); - fail("arguments too short, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("arguments too short, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.t(mu, tooShortObs); - fail("insufficient data to compute t statistic, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("insufficient data to compute t statistic, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.tTest(mu, tooShortObs); - fail("insufficient data to perform t test, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("insufficient data to perform t test, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.t(mu, (SummaryStatistics) null); - fail("insufficient data to compute t statistic, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("insufficient data to compute t statistic, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.tTest(mu, (SummaryStatistics) null); - fail("insufficient data to perform t test, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("insufficient data to perform t test, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } } @@ -287,15 +288,15 @@ public class TestUtilsTest extends TestC try { TestUtils.tTest(0d, oneSidedP, 95); - fail("alpha out of range, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("alpha out of range, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.tTest(0d, oneSidedPStats, 95); - fail("alpha out of range, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("alpha out of range, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } @@ -333,57 +334,57 @@ public class TestUtilsTest extends TestC try { TestUtils.tTest(sample1, sample2, .95); - fail("alpha out of range, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("alpha out of range, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.tTest(sampleStats1, sampleStats2, .95); - fail("alpha out of range, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("alpha out of range, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.tTest(sample1, tooShortObs, .01); - fail("insufficient data, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("insufficient data, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.tTest(sampleStats1, (SummaryStatistics) null, .01); - fail("insufficient data, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("insufficient data, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.tTest(sample1, tooShortObs); - fail("insufficient data, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("insufficient data, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.tTest(sampleStats1, (SummaryStatistics) null); - fail("insufficient data, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("insufficient data, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.t(sample1, tooShortObs); - fail("insufficient data, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("insufficient data, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } try { TestUtils.t(sampleStats1, (SummaryStatistics) null); - fail("insufficient data, IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) { + fail("insufficient data, MathIllegalArgumentException expected"); + } catch (MathIllegalArgumentException ex) { // expected } }
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/SimpleRegressionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/SimpleRegressionTest.java?rev=1044186&r1=1044185&r2=1044186&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/SimpleRegressionTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/SimpleRegressionTest.java Fri Dec 10 00:50:50 2010 @@ -18,6 +18,8 @@ package org.apache.commons.math.stat.reg import java.util.Random; +import org.apache.commons.math.exception.MathIllegalArgumentException; + import junit.framework.TestCase; /** @@ -222,8 +224,8 @@ public final class SimpleRegressionTest try { regression.getSlopeConfidenceInterval(1); - fail("expecting IllegalArgumentException for alpha = 1"); - } catch (IllegalArgumentException ex) { + fail("expecting MathIllegalArgumentException for alpha = 1"); + } catch (MathIllegalArgumentException ex) { // ignored } Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java?rev=1044186&r1=1044185&r2=1044186&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java Fri Dec 10 00:50:50 2010 @@ -24,6 +24,9 @@ import junit.framework.TestCase; import org.apache.commons.math.TestUtils; import org.apache.commons.math.exception.NonMonotonousSequenceException; +import org.apache.commons.math.exception.MathIllegalArgumentException; +import org.apache.commons.math.exception.MathArithmeticException; +import org.apache.commons.math.exception.MathRuntimeException; import org.apache.commons.math.random.RandomDataImpl; /** @@ -43,7 +46,7 @@ public final class MathUtilsTest extends /** * Exact (caching) recursive implementation to test against */ - private long binomialCoefficient(int n, int k) throws ArithmeticException { + private long binomialCoefficient(int n, int k) throws MathArithmeticException { if (binomialCache.size() > n) { Long cachedResult = binomialCache.get(n).get(Integer.valueOf(k)); if (cachedResult != null) { @@ -67,7 +70,7 @@ public final class MathUtilsTest extends binomialCoefficient(n - 1, k)); } if (result == -1) { - throw new ArithmeticException( + throw new MathArithmeticException( "error computing binomial coefficient"); } for (int i = binomialCache.size(); i < n + 1; i++) { @@ -101,13 +104,13 @@ public final class MathUtilsTest extends assertEquals(big, MathUtils.addAndCheck(big, 0)); try { MathUtils.addAndCheck(big, 1); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { } try { MathUtils.addAndCheck(bigNeg, -1); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { } } @@ -131,8 +134,8 @@ public final class MathUtilsTest extends private void testAddAndCheckLongFailure(long a, long b) { try { MathUtils.addAndCheck(a, b); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { // success } } @@ -195,12 +198,12 @@ public final class MathUtilsTest extends boolean didThrow = false; try { ourResult = MathUtils.binomialCoefficient(n, k); - } catch (ArithmeticException ex) { + } catch (MathArithmeticException ex) { didThrow = true; } try { exactResult = binomialCoefficient(n, k); - } catch (ArithmeticException ex) { + } catch (MathArithmeticException ex) { shouldThrow = true; } assertEquals(n + " choose " + k, exactResult, ourResult); @@ -227,8 +230,8 @@ public final class MathUtilsTest extends // This one should throw try { MathUtils.binomialCoefficient(700, 300); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { // Expected } @@ -244,54 +247,54 @@ public final class MathUtilsTest extends public void testBinomialCoefficientFail() { try { MathUtils.binomialCoefficient(4, 5); - fail("expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // ignored } try { MathUtils.binomialCoefficientDouble(4, 5); - fail("expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // ignored } try { MathUtils.binomialCoefficientLog(4, 5); - fail("expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // ignored } try { MathUtils.binomialCoefficient(-1, -2); - fail("expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // ignored } try { MathUtils.binomialCoefficientDouble(-1, -2); - fail("expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // ignored } try { MathUtils.binomialCoefficientLog(-1, -2); - fail("expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // ignored } try { MathUtils.binomialCoefficient(67, 30); - fail("expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { // ignored } try { MathUtils.binomialCoefficient(67, 34); - fail("expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { // ignored } double x = MathUtils.binomialCoefficientDouble(1030, 515); @@ -498,26 +501,26 @@ public final class MathUtilsTest extends public void testFactorialFail() { try { MathUtils.factorial(-1); - fail("expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // ignored } try { MathUtils.factorialDouble(-1); - fail("expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // ignored } try { MathUtils.factorialLog(-1); - fail("expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { // ignored } try { MathUtils.factorial(21); - fail("expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { // ignored } assertTrue("expecting infinite factorial value", Double.isInfinite(MathUtils.factorialDouble(171))); @@ -553,22 +556,22 @@ public final class MathUtilsTest extends try { // gcd(Integer.MIN_VALUE, 0) > Integer.MAX_VALUE MathUtils.gcd(Integer.MIN_VALUE, 0); - fail("expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } try { // gcd(0, Integer.MIN_VALUE) > Integer.MAX_VALUE MathUtils.gcd(0, Integer.MIN_VALUE); - fail("expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } try { // gcd(Integer.MIN_VALUE, Integer.MIN_VALUE) > Integer.MAX_VALUE MathUtils.gcd(Integer.MIN_VALUE, Integer.MIN_VALUE); - fail("expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } } @@ -605,22 +608,22 @@ public final class MathUtilsTest extends try { // gcd(Long.MIN_VALUE, 0) > Long.MAX_VALUE MathUtils.gcd(Long.MIN_VALUE, 0); - fail("expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } try { // gcd(0, Long.MIN_VALUE) > Long.MAX_VALUE MathUtils.gcd(0, Long.MIN_VALUE); - fail("expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } try { // gcd(Long.MIN_VALUE, Long.MIN_VALUE) > Long.MAX_VALUE MathUtils.gcd(Long.MIN_VALUE, Long.MIN_VALUE); - fail("expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } } @@ -781,23 +784,23 @@ public final class MathUtilsTest extends try { // lcm == abs(MIN_VALUE) cannot be represented as a nonnegative int MathUtils.lcm(Integer.MIN_VALUE, 1); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } try { // lcm == abs(MIN_VALUE) cannot be represented as a nonnegative int MathUtils.lcm(Integer.MIN_VALUE, 1<<20); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } try { MathUtils.lcm(Integer.MAX_VALUE, Integer.MAX_VALUE - 1); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } } @@ -829,16 +832,16 @@ public final class MathUtilsTest extends try { // lcm == abs(MIN_VALUE) cannot be represented as a nonnegative int MathUtils.lcm(Long.MIN_VALUE, 1); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } try { // lcm == abs(MIN_VALUE) cannot be represented as a nonnegative int MathUtils.lcm(Long.MIN_VALUE, 1<<20); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } @@ -846,8 +849,8 @@ public final class MathUtilsTest extends MathUtils.lcm((long)Integer.MAX_VALUE, Integer.MAX_VALUE - 1)); try { MathUtils.lcm(Long.MAX_VALUE, Long.MAX_VALUE - 1); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException expected) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException expected) { // expected } } @@ -868,13 +871,13 @@ public final class MathUtilsTest extends assertEquals(big, MathUtils.mulAndCheck(big, 1)); try { MathUtils.mulAndCheck(big, 2); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { } try { MathUtils.mulAndCheck(bigNeg, 2); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { } } @@ -902,8 +905,8 @@ public final class MathUtilsTest extends private void testMulAndCheckLongFailure(long a, long b) { try { MathUtils.mulAndCheck(a, b); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { // success } } @@ -1025,31 +1028,31 @@ public final class MathUtilsTest extends MathUtils.normalizeArray(testValues3, 1), Double.MIN_VALUE); - // Zero sum -> ArithmeticException + // Zero sum -> MathArithmeticException double[] zeroSum = new double[] {-1, 1}; try { MathUtils.normalizeArray(zeroSum, 1); - fail("expecting ArithmeticException"); - } catch (ArithmeticException ex) {} + fail("expecting MathArithmeticException"); + } catch (MathArithmeticException ex) {} - // Infinite elements -> ArithmeticException + // Infinite elements -> MathArithmeticException double[] hasInf = new double[] {1, 2, 1, Double.NEGATIVE_INFINITY}; try { MathUtils.normalizeArray(hasInf, 1); - fail("expecting ArithmeticException"); - } catch (ArithmeticException ex) {} + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) {} - // Infinite target -> IllegalArgumentException + // Infinite target -> MathIllegalArgumentException try { MathUtils.normalizeArray(testValues1, Double.POSITIVE_INFINITY); - fail("expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) {} + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) {} - // NaN target -> IllegalArgumentException + // NaN target -> MathIllegalArgumentException try { MathUtils.normalizeArray(testValues1, Double.NaN); - fail("expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) {} + fail("expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) {} } @@ -1133,7 +1136,7 @@ public final class MathUtilsTest extends try { MathUtils.round(1.234, 2, BigDecimal.ROUND_UNNECESSARY); fail(); - } catch (ArithmeticException ex) { + } catch (MathRuntimeException ex) { // XXX Loosing semantics? // success } @@ -1147,7 +1150,7 @@ public final class MathUtilsTest extends try { MathUtils.round(1.234, 2, 1923); fail(); - } catch (IllegalArgumentException ex) { + } catch (MathRuntimeException ex) { // XXX Loosing semantics? // success } @@ -1232,7 +1235,7 @@ public final class MathUtilsTest extends try { MathUtils.round(1.234f, 2, BigDecimal.ROUND_UNNECESSARY); fail(); - } catch (ArithmeticException ex) { + } catch (MathArithmeticException ex) { // success } @@ -1246,7 +1249,7 @@ public final class MathUtilsTest extends try { MathUtils.round(1.234f, 2, 1923); fail(); - } catch (IllegalArgumentException ex) { + } catch (MathIllegalArgumentException ex) { // success } @@ -1315,13 +1318,13 @@ public final class MathUtilsTest extends assertEquals(-1, MathUtils.subAndCheck(bigNeg, -big)); try { MathUtils.subAndCheck(big, -1); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { } try { MathUtils.subAndCheck(bigNeg, 1); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { } } @@ -1329,8 +1332,8 @@ public final class MathUtilsTest extends int big = Integer.MAX_VALUE; try { MathUtils.subAndCheck(big, -1); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { assertTrue(ex.getMessage().length() > 1); } } @@ -1353,8 +1356,8 @@ public final class MathUtilsTest extends private void testSubAndCheckLongFailure(long a, long b) { try { MathUtils.subAndCheck(a, b); - fail("Expecting ArithmeticException"); - } catch (ArithmeticException ex) { + fail("Expecting MathArithmeticException"); + } catch (MathArithmeticException ex) { // success } @@ -1366,8 +1369,8 @@ public final class MathUtilsTest extends assertEquals(1, MathUtils.pow(21, 0)); try { MathUtils.pow(21, -7); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException e) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException e) { // expected behavior } @@ -1375,8 +1378,8 @@ public final class MathUtilsTest extends assertEquals(1, MathUtils.pow(21, 0l)); try { MathUtils.pow(21, -7l); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException e) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException e) { // expected behavior } @@ -1384,8 +1387,8 @@ public final class MathUtilsTest extends assertEquals(1l, MathUtils.pow(21l, 0)); try { MathUtils.pow(21l, -7); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException e) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException e) { // expected behavior } @@ -1393,8 +1396,8 @@ public final class MathUtilsTest extends assertEquals(1l, MathUtils.pow(21l, 0l)); try { MathUtils.pow(21l, -7l); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException e) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException e) { // expected behavior } @@ -1403,8 +1406,8 @@ public final class MathUtilsTest extends assertEquals(BigInteger.ONE, MathUtils.pow(twentyOne, 0)); try { MathUtils.pow(twentyOne, -7); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException e) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException e) { // expected behavior } @@ -1412,8 +1415,8 @@ public final class MathUtilsTest extends assertEquals(BigInteger.ONE, MathUtils.pow(twentyOne, 0l)); try { MathUtils.pow(twentyOne, -7l); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException e) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException e) { // expected behavior } @@ -1421,8 +1424,8 @@ public final class MathUtilsTest extends assertEquals(BigInteger.ONE, MathUtils.pow(twentyOne, BigInteger.ZERO)); try { MathUtils.pow(twentyOne, BigInteger.valueOf(-7l)); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException e) { + fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException e) { // expected behavior }
