backported :r1003543,1003545,1003569,1003584 from trunk to branch 2.X

Add missing fail() calls for expected exceptions


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_X@1003899 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2010-10-02 22:06:55 +00:00
parent b857985c79
commit 76ab9055aa
8 changed files with 19 additions and 5 deletions

View File

@ -42,12 +42,14 @@ public class UnivariateRealSolverUtilsTest extends TestCase {
public void testSolveBadParameters() throws MathException {
try { // bad endpoints
UnivariateRealSolverUtils.solve(sin,0.0, 4.0, 4.0);
UnivariateRealSolverUtils.solve(sin, -0.1, 4.0, 4.0);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// expected
}
try { // bad accuracy
UnivariateRealSolverUtils.solve(sin, 0.0, 4.0, 0.0);
// fail("Expecting IllegalArgumentException"); // TODO needs rework since convergence behaviour was changed
} catch (IllegalArgumentException ex) {
// expected
}

View File

@ -66,21 +66,25 @@ public class BigFractionTest extends TestCase {
assertFraction(1055531162664967l, 70368744177664l, new BigFraction(15.0000000000001));
try {
new BigFraction(null, BigInteger.ONE);
fail("Expecting NullArgumentException");
} catch (NullArgumentException npe) {
// expected
}
try {
new BigFraction(BigInteger.ONE, null);
fail("Expecting NullArgumentException");
} catch (NullArgumentException npe) {
// expected
}
try {
new BigFraction(BigInteger.ONE, BigInteger.ZERO);
fail("Expecting ArithmeticException");
} catch (ArithmeticException npe) {
// expected
}
try {
new BigFraction(2.0 * Integer.MAX_VALUE, 1.0e-5, 100000);
fail("Expecting FractionConversionException");
} catch (FractionConversionException fce) {
// expected
}
@ -232,7 +236,7 @@ public class BigFractionTest extends TestCase {
for (double v : new double[] { Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}) {
try {
new BigFraction(v);
fail("expected exception");
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException iae) {
// expected
}

View File

@ -164,6 +164,7 @@ public class RotationTest
{ 0.0, 1.0, 0.0 },
{ 1.0, 0.0, 0.0 }
}, 1.0e-7);
fail("Expecting NotARotationMatrixException");
} catch (NotARotationMatrixException nrme) {
// expected behavior
} catch (Exception e) {
@ -176,6 +177,7 @@ public class RotationTest
{ 0.821760, -0.184320, 0.539200 },
{ -0.354816, 0.574912, 0.737280 }
}, 1.0e-7);
fail("Expecting NotARotationMatrixException");
} catch (NotARotationMatrixException nrme) {
// expected behavior
} catch (Exception e) {
@ -188,6 +190,7 @@ public class RotationTest
{ -0.4, 0.6, 0.7 },
{ 0.8, -0.2, 0.5 }
}, 1.0e-15);
fail("Expecting NotARotationMatrixException");
} catch (NotARotationMatrixException nrme) {
// expected behavior
} catch (Exception e) {

View File

@ -73,6 +73,7 @@ public class LUDecompositionImplTest extends TestCase {
public void testNonSquare() {
try {
new LUDecompositionImpl(MatrixUtils.createRealMatrix(new double[3][2]));
fail("Expecting InvalidMatrixException");
} catch (InvalidMatrixException ime) {
// expected behavior
} catch (Exception e) {

View File

@ -285,6 +285,7 @@ public final class MatrixUtilsTest extends TestCase {
checkIdentityMatrix(MatrixUtils.createRealIdentityMatrix(1));
try {
MatrixUtils.createRealIdentityMatrix(0);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// expected
}
@ -311,6 +312,7 @@ public final class MatrixUtilsTest extends TestCase {
checkIdentityFieldMatrix(MatrixUtils.createFieldIdentityMatrix(FractionField.getInstance(), 1));
try {
MatrixUtils.createRealIdentityMatrix(0);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// expected
}
@ -392,6 +394,7 @@ public final class MatrixUtilsTest extends TestCase {
checkIdentityBigMatrix(MatrixUtils.createBigIdentityMatrix(1));
try {
MatrixUtils.createRealIdentityMatrix(0);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// expected
}

View File

@ -333,6 +333,7 @@ public abstract class RealVectorFormatAbstractTest extends TestCase {
public void testParseNoComponents() {
try {
realVectorFormat.parseObject("{ }");
fail("Expecting ParseException");
} catch (ParseException pe) {
// expected behavior
} catch (Exception e) {

View File

@ -160,10 +160,9 @@ public class ContinuousOutputModelTest
otherCm.handleStep(buildInterpolator(t0, y0, t1), true);
cm.append(otherCm);
} catch(IllegalArgumentException iae) {
//expected behavior
return true;
return true; // there was an allowable error
}
return false;
return false; // no allowable error
}
private StepInterpolator buildInterpolator(double t0, double[] y0, double t1) {

View File

@ -173,6 +173,7 @@ public class MultivariateSummaryStatisticsTest extends TestCase {
public void testDimension() {
try {
createMultivariateSummaryStatistics(2, true).addValue(new double[3]);
fail("Expecting DimensionMismatchException");
} catch (DimensionMismatchException dme) {
// expected behavior
} catch (Exception e) {