commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1346467 - in /commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear: ArrayRealVectorTest.java RealVectorAbstractTest.java
Date Tue, 05 Jun 2012 17:01:57 GMT
Author: celestin
Date: Tue Jun  5 17:01:57 2012
New Revision: 1346467

URL: http://svn.apache.org/viewvc?rev=1346467&view=rev
Log:
MATH-795: factored out testMinMax().

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

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/ArrayRealVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/ArrayRealVectorTest.java?rev=1346467&r1=1346466&r2=1346467&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/ArrayRealVectorTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/ArrayRealVectorTest.java
Tue Jun  5 17:01:57 2012
@@ -507,30 +507,6 @@ public class ArrayRealVectorTest extends
     }
 
     @Test
-    public void testMinMax()  {
-        ArrayRealVector v1 = new ArrayRealVector(new double[] { 0, -6, 4, 12, 7 });
-        Assert.assertEquals(1,  v1.getMinIndex());
-        Assert.assertEquals(-6, v1.getMinValue(), 1.0e-12);
-        Assert.assertEquals(3,  v1.getMaxIndex());
-        Assert.assertEquals(12, v1.getMaxValue(), 1.0e-12);
-        ArrayRealVector v2 = new ArrayRealVector(new double[] { Double.NaN, 3, Double.NaN,
-2 });
-        Assert.assertEquals(3,  v2.getMinIndex());
-        Assert.assertEquals(-2, v2.getMinValue(), 1.0e-12);
-        Assert.assertEquals(1,  v2.getMaxIndex());
-        Assert.assertEquals(3, v2.getMaxValue(), 1.0e-12);
-        ArrayRealVector v3 = new ArrayRealVector(new double[] { Double.NaN, Double.NaN });
-        Assert.assertEquals(-1,  v3.getMinIndex());
-        Assert.assertTrue(Double.isNaN(v3.getMinValue()));
-        Assert.assertEquals(-1,  v3.getMaxIndex());
-        Assert.assertTrue(Double.isNaN(v3.getMaxValue()));
-        ArrayRealVector v4 = new ArrayRealVector(new double[0]);
-        Assert.assertEquals(-1,  v4.getMinIndex());
-        Assert.assertTrue(Double.isNaN(v4.getMinValue()));
-        Assert.assertEquals(-1,  v4.getMaxIndex());
-        Assert.assertTrue(Double.isNaN(v4.getMaxValue()));
-    }
-
-    @Test
     public void testCosine() {
         final ArrayRealVector v = new ArrayRealVector(new double[] {1, 0, 0});
 

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=1346467&r1=1346466&r2=1346467&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
Tue Jun  5 17:01:57 2012
@@ -752,7 +752,6 @@ public abstract class RealVectorAbstract
         Assert.assertEquals(v,TestUtils.serializeAndRecover(v));
     }
 
-
     @Test
     public void testAddToEntry() {
         final double[] v = new double[] { 1, 2, 3 };
@@ -766,6 +765,30 @@ public abstract class RealVectorAbstract
         }
     }
 
+    @Test
+    public void testMinMax() {
+        final RealVector v1 = create(new double[] {0, -6, 4, 12, 7});
+        Assert.assertEquals(1, v1.getMinIndex());
+        Assert.assertEquals(-6, v1.getMinValue(), 1.0e-12);
+        Assert.assertEquals(3, v1.getMaxIndex());
+        Assert.assertEquals(12, v1.getMaxValue(), 1.0e-12);
+        final RealVector v2 = create(new double[] {Double.NaN, 3, Double.NaN, -2});
+        Assert.assertEquals(3, v2.getMinIndex());
+        Assert.assertEquals(-2, v2.getMinValue(), 1.0e-12);
+        Assert.assertEquals(1, v2.getMaxIndex());
+        Assert.assertEquals(3, v2.getMaxValue(), 1.0e-12);
+        final RealVector v3 = create(new double[] {Double.NaN, Double.NaN});
+        Assert.assertEquals(-1, v3.getMinIndex());
+        Assert.assertTrue(Double.isNaN(v3.getMinValue()));
+        Assert.assertEquals(-1, v3.getMaxIndex());
+        Assert.assertTrue(Double.isNaN(v3.getMaxValue()));
+        final RealVector v4 = create(new double[0]);
+        Assert.assertEquals(-1, v4.getMinIndex());
+        Assert.assertTrue(Double.isNaN(v4.getMinValue()));
+        Assert.assertEquals(-1, v4.getMaxIndex());
+        Assert.assertTrue(Double.isNaN(v4.getMaxValue()));
+    }
+
     /*
      * TESTS OF THE VISITOR PATTERN
      */



Mime
View raw message