Author: celestin
Date: Thu Jun  7 05:22:52 2012
New Revision: 1347395

URL: http://svn.apache.org/viewvc?rev=1347395&view=rev
Log:
MATH-795:
  - added in RealVectorAbstractTest tests for RealVector.getEntry()
preconditions,
  - modified exceptions thrown in RealVectorTest.TestVectorImpl accordingly.

Modified:
    
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorAbstractTest.java
    
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorTest.java

Modified: 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorAbstractTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorAbstractTest.java?rev=1347395&r1=1347394&r2=1347395&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorAbstractTest.java
 (original)
+++ 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorAbstractTest.java
 Thu Jun  7 05:22:52 2012
@@ -154,6 +154,16 @@ public abstract class RealVectorAbstract
         }
     }
 
+    @Test(expected=OutOfRangeException.class)
+    public void testGetEntryInvalidIndex1() {
+        create(data1).getEntry(-1);
+    }
+
+    @Test(expected=OutOfRangeException.class)
+    public void testGetEntryInvalidIndex2() {
+        create(data1).getEntry(data1.length);
+    }
+
     private void doTestAppendVector(final String message, final RealVector v1,
         final RealVector v2, final double delta) {
 

Modified: 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorTest.java?rev=1347395&r1=1347394&r2=1347395&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorTest.java
 (original)
+++ 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/RealVectorTest.java
 Thu Jun  7 05:22:52 2012
@@ -22,6 +22,8 @@ import org.junit.Test;
 import org.junit.Assert;
 import org.apache.commons.math3.analysis.UnivariateFunction;
 import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.OutOfRangeException;
+import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.linear.RealVector.Entry;
 import org.apache.commons.math3.util.MathArrays;
 
@@ -125,12 +127,22 @@ public class RealVectorTest extends Real
 
         @Override
         public double getEntry(int index) {
-            return values[index];
+            try {
+                return values[index];
+            } catch (IndexOutOfBoundsException e) {
+                throw new OutOfRangeException(LocalizedFormats.INDEX, index, 0,
+                    getDimension() - 1);
+            }
         }
 
         @Override
         public void setEntry(int index, double value) {
-            values[index] = value;
+            try {
+                values[index] = value;
+            } catch (IndexOutOfBoundsException e) {
+                throw new OutOfRangeException(LocalizedFormats.INDEX, index, 0,
+                    getDimension() - 1);
+            }
         }
 
         @Override


Reply via email to