commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1348211 - in /commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear: RealVectorAbstractTest.java RealVectorTest.java
Date Fri, 08 Jun 2012 19:56:43 GMT
Author: celestin
Date: Fri Jun  8 19:56:42 2012
New Revision: 1348211

URL: http://svn.apache.org/viewvc?rev=1348211&view=rev
Log:
MATH-795: in RealVectorAbstractTest, added unit tests for
RealVector.setSubVector(int, RealVector).

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=1348211&r1=1348210&r2=1348211&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
Fri Jun  8 19:56:42 2012
@@ -337,6 +337,51 @@ public abstract class RealVectorAbstract
     }
 
     @Test
+    public void testSetSubVectorSameType() {
+        final double x = getPreferredEntryValue();
+        final double[] expected = {x, x, x, 1d, x, 2d, x, x, 3d, x, x, x, 4d, x, x, x};
+        final double[] sub = {5d, x, 6d, 7d, 8d};
+        final RealVector actual = create(expected);
+        final int index = 2;
+        actual.setSubVector(index, create(sub));
+
+        for (int i = 0; i < sub.length; i++){
+            expected[index + i] = sub[i];
+        }
+        TestUtils.assertEquals("", expected, actual, 0d);
+    }
+
+    @Test
+    public void testSetSubVectorMixedType() {
+        final double x = getPreferredEntryValue();
+        final double[] expected = {x, x, x, 1d, x, 2d, x, x, 3d, x, x, x, 4d, x, x, x};
+        final double[] sub = {5d, x, 6d, 7d, 8d};
+        final RealVector actual = create(expected);
+        final int index = 2;
+        actual.setSubVector(index, createAlien(sub));
+
+        for (int i = 0; i < sub.length; i++){
+            expected[index + i] = sub[i];
+        }
+        TestUtils.assertEquals("", expected, actual, 0d);
+    }
+
+    @Test(expected = OutOfRangeException.class)
+    public void testSetSubVectorInvalidIndex1() {
+        create(new double[10]).setSubVector(-1, create(new double[2]));
+    }
+
+    @Test(expected = OutOfRangeException.class)
+    public void testSetSubVectorInvalidIndex2() {
+        create(new double[10]).setSubVector(10, create(new double[2]));
+    }
+
+    @Test(expected = OutOfRangeException.class)
+    public void testSetSubVectorInvalidIndex3() {
+        create(new double[10]).setSubVector(9, create(new double[2]));
+    }
+
+    @Test
     public void testDataInOut() {
         final RealVector v1 = create(vec1);
         final RealVector v2 = create(vec2);

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=1348211&r1=1348210&r2=1348211&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
Fri Jun  8 19:56:42 2012
@@ -248,6 +248,41 @@ public class RealVectorTest extends Real
     }
 
     @Test
+    @Ignore("Abstract class RealVector does not implement setSubvector(int, RealVector)")
+    @Override
+    public void testSetSubVectorSameType() {
+        // Do nothing
+    }
+
+    @Test
+    @Ignore("Abstract class RealVector does not implement setSubvector(int, RealVector)")
+    @Override
+    public void testSetSubVectorMixedType() {
+        // Do nothing
+    }
+
+    @Test
+    @Ignore("Abstract class RealVector does not implement setSubvector(int, RealVector)")
+    @Override
+    public void testSetSubVectorInvalidIndex1() {
+        // Do nothing
+    }
+
+    @Test
+    @Ignore("Abstract class RealVector does not implement setSubvector(int, RealVector)")
+    @Override
+    public void testSetSubVectorInvalidIndex2() {
+        // Do nothing
+    }
+
+    @Test
+    @Ignore("Abstract class RealVector does not implement setSubvector(int, RealVector)")
+    @Override
+    public void testSetSubVectorInvalidIndex3() {
+        // Do nothing
+    }
+
+    @Test
     @Ignore
     @Override
     public void testBasicFunctions() {



Mime
View raw message