commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1206668 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/UnivariateStatisticAbstractTest.java
Date Sun, 27 Nov 2011 06:00:27 GMT
Author: psteitz
Date: Sun Nov 27 06:00:27 2011
New Revision: 1206668

URL: http://svn.apache.org/viewvc?rev=1206668&view=rev
Log:
Added test to verify that all statistics evaluate on array segments correctly.  JIRA: MATH-704.

Modified:
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/UnivariateStatisticAbstractTest.java

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/UnivariateStatisticAbstractTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/UnivariateStatisticAbstractTest.java?rev=1206668&r1=1206667&r2=1206668&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/UnivariateStatisticAbstractTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/UnivariateStatisticAbstractTest.java
Sun Nov 27 06:00:27 2011
@@ -17,6 +17,7 @@ s * Unless required by applicable law or
 package org.apache.commons.math.stat.descriptive;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 
@@ -99,6 +100,17 @@ public abstract class UnivariateStatisti
             getUnivariateStatistic().evaluate(testArray),
             getTolerance());
     }
+    
+    @Test
+    public void testEvaluateArraySegment() {
+        final UnivariateStatistic stat = getUnivariateStatistic();
+        final double[] arrayZero = Arrays.copyOfRange(testArray, 0, 5);
+        Assert.assertEquals(stat.evaluate(arrayZero), stat.evaluate(testArray, 0, 5), 0);
+        final double[] arrayOne = Arrays.copyOfRange(testArray, 5, 10);
+        Assert.assertEquals(stat.evaluate(arrayOne), stat.evaluate(testArray, 5, 5), 0);
+        final double[] arrayEnd = Arrays.copyOfRange(testArray, testArray.length - 5, testArray.length);
+        Assert.assertEquals(stat.evaluate(arrayEnd), stat.evaluate(testArray, testArray.length
- 5, 5), 0);
+    }
 
     @Test
     public void testCopy() throws Exception {



Mime
View raw message