commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1005028 [2/2] - 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/ site/xdoc/ te...
Date Wed, 06 Oct 2010 13:30:04 GMT
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java?rev=1005028&r1=1005027&r2=1005028&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java
Wed Oct  6 13:30:03 2010
@@ -22,6 +22,11 @@ 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.MatrixDimensionMismatchException;
+import org.apache.commons.math.exception.NoDataException;
+import org.apache.commons.math.exception.OutOfRangeException;
+import org.apache.commons.math.exception.NumberIsTooSmallException;
+import org.apache.commons.math.exception.NotStrictlyPositiveException;
+import org.apache.commons.math.exception.NullArgumentException;
 
 /**
  * Test cases for the {@link Array2DRowFieldMatrix} class.
@@ -285,25 +290,25 @@ public final class FieldMatrixImplTest e
         TestUtils.assertEquals(m.getColumn(2), testDataCol3);
         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
         }
     }
 
     public void testGetEntry() {
         FieldMatrix<Fraction> m = new Array2DRowFieldMatrix<Fraction>(testData);
-        assertEquals("get entry",m.getEntry(0,1),new Fraction(2));
+        assertEquals("get entry", m.getEntry(0,1), new Fraction(2));
         try {
             m.getEntry(10, 4);
-            fail ("Expecting MatrixIndexException");
-        } catch (MatrixIndexException ex) {
+            fail ("Expecting OutOfRangeException");
+        } catch (OutOfRangeException ex) {
             // expected
         }
     }
@@ -380,9 +385,22 @@ public final class FieldMatrixImplTest e
             if (reference != null) {
                 assertEquals(new Array2DRowFieldMatrix<Fraction>(reference), sub);
             } else {
-                fail("Expecting MatrixIndexException");
+                fail("Expecting OutOfRangeException or NotStrictlyPositiveException"
+                     + " or NumberIsTooSmallException or NoDataException");
             }
-        } catch (MatrixIndexException e) {
+        } catch (OutOfRangeException e) {
+            if (reference != null) {
+                throw e;
+            }
+        } catch (NotStrictlyPositiveException e) {
+            if (reference != null) {
+                throw e;
+            }
+        } catch (NumberIsTooSmallException e) {
+            if (reference != null) {
+                throw e;
+            }
+        } catch (NoDataException e) {
             if (reference != null) {
                 throw e;
             }
@@ -396,9 +414,22 @@ public final class FieldMatrixImplTest e
             if (reference != null) {
                 assertEquals(new Array2DRowFieldMatrix<Fraction>(reference), sub);
             } else {
-                fail("Expecting MatrixIndexException");
+                fail("Expecting OutOfRangeException or NotStrictlyPositiveException"
+                     + " or NumberIsTooSmallException or NoDataException");
+            }
+        } catch (OutOfRangeException e) {
+            if (reference != null) {
+                throw e;
+            }
+        } catch (NotStrictlyPositiveException e) {
+            if (reference != null) {
+                throw e;
             }
-        } catch (MatrixIndexException e) {
+        } catch (NumberIsTooSmallException e) {
+            if (reference != null) {
+                throw e;
+            }
+        } catch (NoDataException e) {
             if (reference != null) {
                 throw e;
             }
@@ -435,9 +466,17 @@ public final class FieldMatrixImplTest e
             if (reference != null) {
                 assertEquals(new Array2DRowFieldMatrix<Fraction>(reference), new Array2DRowFieldMatrix<Fraction>(sub));
             } else {
-                fail("Expecting MatrixIndexException");
+                fail("Expecting OutOfRangeException or NumberIsTooSmallException or NoDataException");
+            }
+        } catch (OutOfRangeException e) {
+            if (reference != null) {
+                throw e;
             }
-        } catch (MatrixIndexException e) {
+        } catch (NumberIsTooSmallException e) {
+            if (reference != null) {
+                throw e;
+            }
+        } catch (NoDataException e) {
             if (reference != null) {
                 throw e;
             }
@@ -454,9 +493,17 @@ public final class FieldMatrixImplTest e
             if (reference != null) {
                 assertEquals(new Array2DRowFieldMatrix<Fraction>(reference), new Array2DRowFieldMatrix<Fraction>(sub));
             } else {
-                fail("Expecting MatrixIndexException");
+                fail("Expecting OutOfRangeException or NumberIsTooSmallException or NoDataException");
+            }
+        } catch (OutOfRangeException e) {
+            if (reference != null) {
+                throw e;
+            }
+        } catch (NumberIsTooSmallException e) {
+            if (reference != null) {
+                throw e;
             }
-        } catch (MatrixIndexException e) {
+        } catch (NoDataException e) {
             if (reference != null) {
                 throw e;
             }
@@ -473,14 +520,14 @@ public final class FieldMatrixImplTest e
                 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
         }
     }
@@ -493,8 +540,8 @@ public final class FieldMatrixImplTest 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 {
@@ -515,14 +562,14 @@ public final class FieldMatrixImplTest e
                 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
         }
     }
@@ -535,8 +582,8 @@ public final class FieldMatrixImplTest 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 {
@@ -555,14 +602,14 @@ public final class FieldMatrixImplTest e
         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
         }
     }
@@ -575,8 +622,8 @@ public final class FieldMatrixImplTest 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 {
@@ -595,14 +642,14 @@ public final class FieldMatrixImplTest e
         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
         }
     }
@@ -615,8 +662,8 @@ public final class FieldMatrixImplTest 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 {
@@ -641,14 +688,14 @@ public final class FieldMatrixImplTest 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
         }
     }
@@ -660,8 +707,8 @@ public final class FieldMatrixImplTest 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 {
@@ -680,14 +727,14 @@ public final class FieldMatrixImplTest 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
         }
     }
@@ -700,8 +747,8 @@ public final class FieldMatrixImplTest 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 {
@@ -779,29 +826,29 @@ public final class FieldMatrixImplTest 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
         }
 
         // null
         try {
-            m.setSubMatrix(null,1,1);
-            fail("expecting NullPointerException");
-        } catch (NullPointerException e) {
+            m.setSubMatrix(null, 1, 1);
+            fail("expecting NullArgumentException");
+        } catch (NullArgumentException e) {
             // expected
         }
         Array2DRowFieldMatrix<Fraction> m2 = new Array2DRowFieldMatrix<Fraction>(FractionField.getInstance());

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java?rev=1005028&r1=1005027&r2=1005028&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java
Wed Oct  6 13:30:03 2010
@@ -22,6 +22,10 @@ import org.apache.commons.math.Field;
 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.NoDataException;
+import org.apache.commons.math.exception.OutOfRangeException;
+import org.apache.commons.math.exception.NumberIsTooSmallException;
+import org.apache.commons.math.exception.NullArgumentException;
 
 /**
  * Test cases for the {@link SparseFieldMatrix} class.
@@ -336,14 +340,14 @@ public class SparseFieldMatrixTest exten
         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
         }
     }
@@ -353,8 +357,8 @@ public class SparseFieldMatrixTest exten
         assertEquals("get entry", m.getEntry(0, 1).doubleValue(), 2d, entryTolerance);
         try {
             m.getEntry(10, 4);
-            fail("Expecting MatrixIndexException");
-        } catch (MatrixIndexException ex) {
+            fail("Expecting OutOfRangeException");
+        } catch (OutOfRangeException ex) {
             // expected
         }
     }
@@ -420,38 +424,38 @@ public class SparseFieldMatrixTest exten
 
         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 NoDataException");
+        } catch (NoDataException ex) {
             // expected
         }
         try {
             m.getSubMatrix(new int[] { 0 }, new int[] { 4 });
-            fail("Expecting MatrixIndexException");
-        } catch (MatrixIndexException ex) {
+            fail("Expecting OutOfRangeException");
+        } catch (OutOfRangeException ex) {
             // expected
         }
     }
@@ -464,14 +468,14 @@ public class SparseFieldMatrixTest exten
         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
         }
     }
@@ -484,14 +488,14 @@ public class SparseFieldMatrixTest exten
         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
         }
     }
@@ -504,14 +508,14 @@ public class SparseFieldMatrixTest exten
         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
         }
     }
@@ -524,14 +528,14 @@ public class SparseFieldMatrixTest exten
         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
         }
     }
@@ -596,29 +600,29 @@ public class SparseFieldMatrixTest exten
         // 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
         }
 
         // null
         try {
             m.setSubMatrix(null, 1, 1);
-            fail("expecting NullPointerException");
-        } catch (NullPointerException e) {
+            fail("expecting NullArgumentException");
+        } catch (NullArgumentException e) {
             // expected
         }
         try {



Mime
View raw message