You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2010/10/27 15:16:58 UTC
svn commit: r1027952 [5/5] - in /commons/proper/math/trunk/src:
main/java/org/apache/commons/math/exception/
main/java/org/apache/commons/math/exception/util/
main/java/org/apache/commons/math/linear/
main/resources/META-INF/localization/ test/java/org...
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java?rev=1027952&r1=1027951&r2=1027952&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayFieldVectorTest.java Wed Oct 27 13:16:57 2010
@@ -26,6 +26,7 @@ import org.apache.commons.math.FieldElem
import org.apache.commons.math.TestUtils;
import org.apache.commons.math.fraction.Fraction;
import org.apache.commons.math.fraction.FractionField;
+import org.apache.commons.math.exception.OutOfRangeException;
/**
* Test cases for the {@link ArrayFieldVector} class.
@@ -365,8 +366,8 @@ public class ArrayFieldVectorTest extend
assertEquals(new Fraction(5), vout5.getEntry(1));
try {
v4.getSubVector(3, 7);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
@@ -375,8 +376,8 @@ public class ArrayFieldVectorTest extend
assertEquals(new Fraction(11), v_set1.getEntry(1));
try {
v_set1.setEntry(3, new Fraction(11));
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
@@ -386,8 +387,8 @@ public class ArrayFieldVectorTest extend
assertEquals(new Fraction(7), v_set2.getEntry(6));
try {
v_set2.set(7, v1);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
@@ -408,8 +409,8 @@ public class ArrayFieldVectorTest extend
assertEquals(new Fraction(7), v_set4.getEntry(6));
try {
v_set4.setSubVector(7, v2_t);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayRealVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayRealVectorTest.java?rev=1027952&r1=1027951&r2=1027952&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayRealVectorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayRealVectorTest.java Wed Oct 27 13:16:57 2010
@@ -25,6 +25,7 @@ import org.apache.commons.math.FunctionE
import org.apache.commons.math.TestUtils;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.FastMath;
+import org.apache.commons.math.exception.OutOfRangeException;
/**
* Test cases for the {@link ArrayRealVector} class.
@@ -655,8 +656,8 @@ public class ArrayRealVectorTest extends
assertEquals("testData is 4.0 ", 5.0, vout5.getEntry(1));
try {
v4.getSubVector(3, 7);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
@@ -665,8 +666,8 @@ public class ArrayRealVectorTest extends
assertEquals("testData is 11.0 ", 11.0, v_set1.getEntry(1));
try {
v_set1.setEntry(3, 11.0);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
@@ -676,8 +677,8 @@ public class ArrayRealVectorTest extends
assertEquals("testData is 7.0 ", 7.0, v_set2.getEntry(6));
try {
v_set2.set(7, v1);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
@@ -698,8 +699,8 @@ public class ArrayRealVectorTest extends
assertEquals("testData is 7.0 ", 7.0, v_set4.getEntry(6));
try {
v_set4.setSubVector(7, v2_t);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockRealMatrixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockRealMatrixTest.java?rev=1027952&r1=1027951&r2=1027952&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockRealMatrixTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockRealMatrixTest.java Wed Oct 27 13:16:57 2010
@@ -24,6 +24,9 @@ import junit.framework.TestCase;
import org.apache.commons.math.TestUtils;
import org.apache.commons.math.util.FastMath;
import org.apache.commons.math.exception.MatrixDimensionMismatchException;
+import org.apache.commons.math.exception.OutOfRangeException;
+import org.apache.commons.math.exception.ZeroException;
+import org.apache.commons.math.exception.NumberIsTooSmallException;
/**
* Test cases for the {@link BlockRealMatrix} class.
@@ -416,14 +419,14 @@ public final class BlockRealMatrixTest e
assertClose(m.getColumn(2), testDataCol3, entryTolerance);
try {
m.getRow(10);
- fail("expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// ignored
}
try {
m.getColumn(-1);
- fail("expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// ignored
}
}
@@ -433,8 +436,8 @@ public final class BlockRealMatrixTest e
assertEquals("get entry",m.getEntry(0,1),2d,entryTolerance);
try {
m.getEntry(10, 4);
- fail ("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail ("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -494,9 +497,17 @@ public final class BlockRealMatrixTest e
if (reference != null) {
assertEquals(new BlockRealMatrix(reference), sub);
} else {
- fail("Expecting MatrixIndexException");
+ fail("Expecting OutOfRangeException or NumberIsTooSmallException or ZeroException");
}
- } catch (MatrixIndexException e) {
+ } catch (OutOfRangeException e) {
+ if (reference != null) {
+ throw e;
+ }
+ } catch (NumberIsTooSmallException e) {
+ if (reference != null) {
+ throw e;
+ }
+ } catch (ZeroException e) {
if (reference != null) {
throw e;
}
@@ -510,9 +521,17 @@ public final class BlockRealMatrixTest e
if (reference != null) {
assertEquals(new BlockRealMatrix(reference), sub);
} else {
- fail("Expecting MatrixIndexException");
+ fail("Expecting OutOfRangeException or NumberIsTooSmallExceptiono r ZeroException");
+ }
+ } catch (OutOfRangeException e) {
+ if (reference != null) {
+ throw e;
+ }
+ } catch (NumberIsTooSmallException e) {
+ if (reference != null) {
+ throw e;
}
- } catch (MatrixIndexException e) {
+ } catch (ZeroException e) {
if (reference != null) {
throw e;
}
@@ -568,9 +587,17 @@ public final class BlockRealMatrixTest e
if (reference != null) {
assertEquals(new BlockRealMatrix(reference), new BlockRealMatrix(sub));
} else {
- fail("Expecting MatrixIndexException");
+ fail("Expecting OutOfRangeException or NumberIsTooSmallException or ZeroException");
}
- } catch (MatrixIndexException e) {
+ } catch (OutOfRangeException e) {
+ if (reference != null) {
+ throw e;
+ }
+ } catch (NumberIsTooSmallException e) {
+ if (reference != null) {
+ throw e;
+ }
+ } catch (ZeroException e) {
if (reference != null) {
throw e;
}
@@ -587,9 +614,17 @@ public final class BlockRealMatrixTest e
if (reference != null) {
assertEquals(new BlockRealMatrix(reference), new BlockRealMatrix(sub));
} else {
- fail("Expecting MatrixIndexException");
+ fail("Expecting OutOfRangeException or NumberIsTooSmallException or ZeroException");
+ }
+ } catch (OutOfRangeException e) {
+ if (reference != null) {
+ throw e;
+ }
+ } catch (NumberIsTooSmallException e) {
+ if (reference != null) {
+ throw e;
}
- } catch (MatrixIndexException e) {
+ } catch (ZeroException e) {
if (reference != null) {
throw e;
}
@@ -604,14 +639,14 @@ public final class BlockRealMatrixTest e
assertEquals("Row3", mRow3, m.getRowMatrix(3));
try {
m.getRowMatrix(-1);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
m.getRowMatrix(4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -624,8 +659,8 @@ public final class BlockRealMatrixTest e
assertEquals(mRow3, m.getRowMatrix(0));
try {
m.setRowMatrix(-1, mRow3);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
@@ -663,14 +698,14 @@ public final class BlockRealMatrixTest e
assertEquals(mColumn3, m.getColumnMatrix(3));
try {
m.getColumnMatrix(-1);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
m.getColumnMatrix(4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -683,8 +718,8 @@ public final class BlockRealMatrixTest e
assertEquals(mColumn3, m.getColumnMatrix(1));
try {
m.setColumnMatrix(-1, mColumn3);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
@@ -722,14 +757,14 @@ public final class BlockRealMatrixTest e
assertEquals(mRow3, m.getRowVector(3));
try {
m.getRowVector(-1);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
m.getRowVector(4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -742,8 +777,8 @@ public final class BlockRealMatrixTest e
assertEquals(mRow3, m.getRowVector(0));
try {
m.setRowVector(-1, mRow3);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
@@ -781,14 +816,14 @@ public final class BlockRealMatrixTest e
assertEquals(mColumn3, m.getColumnVector(3));
try {
m.getColumnVector(-1);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
m.getColumnVector(4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -801,8 +836,8 @@ public final class BlockRealMatrixTest e
assertEquals(mColumn3, m.getColumnVector(1));
try {
m.setColumnVector(-1, mColumn3);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
@@ -846,14 +881,14 @@ public final class BlockRealMatrixTest e
checkArrays(subRow3[0], m.getRow(3));
try {
m.getRow(-1);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
m.getRow(4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -865,8 +900,8 @@ public final class BlockRealMatrixTest e
checkArrays(subRow3[0], m.getRow(0));
try {
m.setRow(-1, subRow3[0]);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
@@ -905,14 +940,14 @@ public final class BlockRealMatrixTest e
checkArrays(mColumn3, m.getColumn(3));
try {
m.getColumn(-1);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
m.getColumn(4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -925,8 +960,8 @@ public final class BlockRealMatrixTest e
checkArrays(mColumn3, m.getColumn(1));
try {
m.setColumn(-1, mColumn3);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
@@ -1019,21 +1054,21 @@ public final class BlockRealMatrixTest e
// dimension overflow
try {
m.setSubMatrix(testData,1,1);
- fail("expecting MatrixIndexException");
- } catch (MatrixIndexException e) {
+ fail("expecting OutOfRangeException");
+ } catch (OutOfRangeException e) {
// expected
}
// dimension underflow
try {
m.setSubMatrix(testData,-1,1);
- fail("expecting MatrixIndexException");
- } catch (MatrixIndexException e) {
+ fail("expecting OutOfRangeException");
+ } catch (OutOfRangeException e) {
// expected
}
try {
m.setSubMatrix(testData,1,-1);
- fail("expecting MatrixIndexException");
- } catch (MatrixIndexException e) {
+ fail("expecting OutOfRangeException");
+ } catch (OutOfRangeException e) {
// expected
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java?rev=1027952&r1=1027951&r2=1027952&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/MatrixUtilsTest.java Wed Oct 27 13:16:57 2010
@@ -24,6 +24,8 @@ import org.apache.commons.math.fraction.
import org.apache.commons.math.fraction.Fraction;
import org.apache.commons.math.fraction.FractionConversionException;
import org.apache.commons.math.fraction.FractionField;
+import org.apache.commons.math.exception.NullArgumentException;
+import org.apache.commons.math.exception.NotStrictlyPositiveException;
/**
* Test cases for the {@link MatrixUtils} class.
@@ -83,8 +85,8 @@ public final class MatrixUtilsTest exten
}
try {
MatrixUtils.createRealMatrix(null); // null
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ fail("Expecting NullArgumentException");
+ } catch (NullArgumentException ex) {
// expected
}
}
@@ -108,40 +110,8 @@ public final class MatrixUtilsTest exten
}
try {
MatrixUtils.createFieldMatrix((Fraction[][])null); // null
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- @Deprecated
- public void testCreateBigMatrix() {
- assertEquals(new BigMatrixImpl(testData),
- MatrixUtils.createBigMatrix(testData));
- assertEquals(new BigMatrixImpl(BigMatrixImplTest.asBigDecimal(testData), true),
- MatrixUtils.createBigMatrix(BigMatrixImplTest.asBigDecimal(testData), false));
- assertEquals(new BigMatrixImpl(BigMatrixImplTest.asBigDecimal(testData), false),
- MatrixUtils.createBigMatrix(BigMatrixImplTest.asBigDecimal(testData), true));
- assertEquals(new BigMatrixImpl(bigColMatrix),
- MatrixUtils.createBigMatrix(bigColMatrix));
- assertEquals(new BigMatrixImpl(stringColMatrix),
- MatrixUtils.createBigMatrix(stringColMatrix));
- try {
- MatrixUtils.createBigMatrix(new double[][] {{1}, {1,2}}); // ragged
- fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- try {
- MatrixUtils.createBigMatrix(new double[][] {{}, {}}); // no columns
- fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- try {
- MatrixUtils.createBigMatrix(nullMatrix); // null
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ fail("Expecting NullArgumentException");
+ } catch (NullArgumentException ex) {
// expected
}
}
@@ -151,14 +121,14 @@ public final class MatrixUtilsTest exten
new BlockRealMatrix(rowMatrix));
try {
MatrixUtils.createRowRealMatrix(new double[] {}); // empty
- fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
+ fail("Expecting NotStrictlyPositiveException");
+ } catch (NotStrictlyPositiveException ex) {
// expected
}
try {
MatrixUtils.createRowRealMatrix(null); // null
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ fail("Expecting NullArgumentException");
+ } catch (NullArgumentException ex) {
// expected
}
}
@@ -176,30 +146,8 @@ public final class MatrixUtilsTest exten
}
try {
MatrixUtils.createRowFieldMatrix((Fraction[]) null); // null
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- @Deprecated
- public void testCreateRowBigMatrix() {
- assertEquals(MatrixUtils.createRowBigMatrix(row),
- new BigMatrixImpl(rowMatrix));
- assertEquals(MatrixUtils.createRowBigMatrix(bigRow),
- new BigMatrixImpl(bigRowMatrix));
- assertEquals(MatrixUtils.createRowBigMatrix(stringRow),
- new BigMatrixImpl(stringRowMatrix));
- try {
- MatrixUtils.createRowBigMatrix(new double[] {}); // empty
- fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- try {
- MatrixUtils.createRowBigMatrix(nullDoubleArray); // null
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ fail("Expecting NullArgumentException");
+ } catch (NullArgumentException ex) {
// expected
}
}
@@ -215,8 +163,8 @@ public final class MatrixUtilsTest exten
}
try {
MatrixUtils.createColumnRealMatrix(null); // null
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ fail("Expecting NullArgumentException");
+ } catch (NullArgumentException ex) {
// expected
}
}
@@ -235,31 +183,8 @@ public final class MatrixUtilsTest exten
}
try {
MatrixUtils.createColumnFieldMatrix((Fraction[]) null); // null
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
- // expected
- }
- }
-
- @Deprecated
- public void testCreateColumnBigMatrix() {
- assertEquals(MatrixUtils.createColumnBigMatrix(col),
- new BigMatrixImpl(colMatrix));
- assertEquals(MatrixUtils.createColumnBigMatrix(bigCol),
- new BigMatrixImpl(bigColMatrix));
- assertEquals(MatrixUtils.createColumnBigMatrix(stringCol),
- new BigMatrixImpl(stringColMatrix));
-
- try {
- MatrixUtils.createColumnBigMatrix(new double[] {}); // empty
- fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- try {
- MatrixUtils.createColumnBigMatrix(nullDoubleArray); // null
- fail("Expecting NullPointerException");
- } catch (NullPointerException ex) {
+ fail("Expecting NullArgumentException");
+ } catch (NullArgumentException ex) {
// expected
}
}
@@ -370,35 +295,5 @@ public final class MatrixUtilsTest exten
}
return d;
}
-
- /**
- * Verifies that the matrix is an identity matrix
- */
- @Deprecated
- protected void checkIdentityBigMatrix(BigMatrix m) {
- for (int i = 0; i < m.getRowDimension(); i++) {
- for (int j =0; j < m.getColumnDimension(); j++) {
- if (i == j) {
- assertEquals(m.getEntry(i, j), BigMatrixImpl.ONE);
- } else {
- assertEquals(m.getEntry(i, j), BigMatrixImpl.ZERO);
- }
- }
- }
- }
-
- @Deprecated
- public void testCreateBigIdentityMatrix() {
- checkIdentityBigMatrix(MatrixUtils.createBigIdentityMatrix(3));
- checkIdentityBigMatrix(MatrixUtils.createBigIdentityMatrix(2));
- checkIdentityBigMatrix(MatrixUtils.createBigIdentityMatrix(1));
- try {
- MatrixUtils.createRealIdentityMatrix(0);
- fail("Expecting IllegalArgumentException");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- }
-
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealMatrixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealMatrixTest.java?rev=1027952&r1=1027951&r2=1027952&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealMatrixTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealMatrixTest.java Wed Oct 27 13:16:57 2010
@@ -19,6 +19,9 @@ package org.apache.commons.math.linear;
import junit.framework.TestCase;
import org.apache.commons.math.TestUtils;
+import org.apache.commons.math.exception.OutOfRangeException;
+import org.apache.commons.math.exception.ZeroException;
+import org.apache.commons.math.exception.NumberIsTooSmallException;
/**
* Test cases for the {@link OpenMapRealMatrix} class.
@@ -324,14 +327,14 @@ public final class SparseRealMatrixTest
assertClose("get col", m.getColumn(2), testDataCol3, entryTolerance);
try {
m.getRow(10);
- fail("expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// ignored
}
try {
m.getColumn(-1);
- fail("expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// ignored
}
}
@@ -341,8 +344,8 @@ public final class SparseRealMatrixTest
assertEquals("get entry", m.getEntry(0, 1), 2d, entryTolerance);
try {
m.getEntry(10, 4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -408,38 +411,38 @@ public final class SparseRealMatrixTest
try {
m.getSubMatrix(1, 0, 2, 4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting NumberIsTooSmallException");
+ } catch (NumberIsTooSmallException ex) {
// expected
}
try {
m.getSubMatrix(-1, 1, 2, 2);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
m.getSubMatrix(1, 0, 2, 2);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting NumberIsTooSmallException");
+ } catch (NumberIsTooSmallException ex) {
// expected
}
try {
m.getSubMatrix(1, 0, 2, 4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting NumberIsTooSmallException");
+ } catch (NumberIsTooSmallException ex) {
// expected
}
try {
m.getSubMatrix(new int[] {}, new int[] { 0 });
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting ZeroException");
+ } catch (ZeroException ex) {
// expected
}
try {
m.getSubMatrix(new int[] { 0 }, new int[] { 4 });
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -452,14 +455,14 @@ public final class SparseRealMatrixTest
assertEquals("Row3", mRow3, m.getRowMatrix(3));
try {
m.getRowMatrix(-1);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
m.getRowMatrix(4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -472,14 +475,14 @@ public final class SparseRealMatrixTest
assertEquals("Column3", mColumn3, m.getColumnMatrix(3));
try {
m.getColumnMatrix(-1);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
m.getColumnMatrix(4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -492,14 +495,14 @@ public final class SparseRealMatrixTest
assertEquals("Row3", mRow3, m.getRowVector(3));
try {
m.getRowVector(-1);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
m.getRowVector(4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -512,14 +515,14 @@ public final class SparseRealMatrixTest
assertEquals("Column3", mColumn3, m.getColumnVector(3));
try {
m.getColumnVector(-1);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
try {
m.getColumnVector(4);
- fail("Expecting MatrixIndexException");
- } catch (MatrixIndexException ex) {
+ fail("Expecting OutOfRangeException");
+ } catch (OutOfRangeException ex) {
// expected
}
}
@@ -582,21 +585,21 @@ public final class SparseRealMatrixTest
// dimension overflow
try {
m.setSubMatrix(testData, 1, 1);
- fail("expecting MatrixIndexException");
- } catch (MatrixIndexException e) {
+ fail("expecting OutOfRangeException");
+ } catch (OutOfRangeException e) {
// expected
}
// dimension underflow
try {
m.setSubMatrix(testData, -1, 1);
- fail("expecting MatrixIndexException");
- } catch (MatrixIndexException e) {
+ fail("expecting OutOfRangeException");
+ } catch (OutOfRangeException e) {
// expected
}
try {
m.setSubMatrix(testData, 1, -1);
- fail("expecting MatrixIndexException");
- } catch (MatrixIndexException e) {
+ fail("expecting OutOfRangeException");
+ } catch (OutOfRangeException e) {
// expected
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java?rev=1027952&r1=1027951&r2=1027952&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java Wed Oct 27 13:16:57 2010
@@ -25,6 +25,7 @@ import org.apache.commons.math.FunctionE
import org.apache.commons.math.TestUtils;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.util.FastMath;
+import org.apache.commons.math.exception.OutOfRangeException;
/**
* Test cases for the {@link OpenMapRealVector} class.
@@ -636,8 +637,8 @@ public class SparseRealVectorTest extend
assertEquals("testData is 4.0 ", 5.0, vout5.getEntry(1));
try {
v4.getSubVector(3, 7);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
@@ -646,8 +647,8 @@ public class SparseRealVectorTest extend
assertEquals("testData is 11.0 ", 11.0, v_set1.getEntry(1));
try {
v_set1.setEntry(3, 11.0);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
@@ -657,8 +658,8 @@ public class SparseRealVectorTest extend
assertEquals("testData is 7.0 ", 7.0, v_set2.getEntry(6));
try {
v_set2.setSubVector(7, v1);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
@@ -668,8 +669,8 @@ public class SparseRealVectorTest extend
try {
v_set3.getEntry(23);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}
@@ -679,8 +680,8 @@ public class SparseRealVectorTest extend
assertEquals("testData is 7.0 ", 7.0, v_set4.getEntry(6));
try {
v_set4.setSubVector(7, v2_t);
- fail("MatrixIndexException expected");
- } catch (MatrixIndexException ex) {
+ fail("OutOfRangeException expected");
+ } catch (OutOfRangeException ex) {
// expected behavior
}