commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject cvs commit: jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate StorelessUnivariateStatisticAbstractTest.java
Date Sat, 10 Jul 2004 17:14:15 GMT
psteitz     2004/07/10 10:14:15

  Modified:    math/src/test/org/apache/commons/math/stat/univariate
                        StorelessUnivariateStatisticAbstractTest.java
  Log:
  Added test for getN() and evaluate/getResult consistency test for small samples.
  
  Revision  Changes    Path
  1.16      +13 -2     jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/StorelessUnivariateStatisticAbstractTest.java
  
  Index: StorelessUnivariateStatisticAbstractTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/StorelessUnivariateStatisticAbstractTest.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- StorelessUnivariateStatisticAbstractTest.java	7 Jul 2004 12:50:50 -0000	1.15
  +++ StorelessUnivariateStatisticAbstractTest.java	10 Jul 2004 17:14:15 -0000	1.16
  @@ -28,6 +28,9 @@
       public StorelessUnivariateStatisticAbstractTest(String name) {
           super(name);
       }
  +    
  +    /** Small sample arrays */
  +    protected double[][] smallSamples = {{}, {1}, {1,2}, {1,2,3}, {1,2,3,4}};
   
       /** Return a new instance of the statistic */
       public abstract UnivariateStatistic getUnivariateStatistic();
  @@ -48,11 +51,12 @@
           }
   
           assertEquals(expectedValue(), statistic.getResult(), getTolerance());
  -        //TODO:  add test for getN() once type is fixed
  +        assertEquals(testArray.length, statistic.getN());
   
           statistic.clear();
   
           assertTrue(Double.isNaN(statistic.getResult()));
  +        assertEquals(0, statistic.getN());
   
       }
   
  @@ -145,6 +149,13 @@
           StorelessUnivariateStatistic stat = (StorelessUnivariateStatistic) getUnivariateStatistic();
           stat.incrementAll(testArray);
           assertEquals(stat.getResult(), stat.evaluate(testArray), getTolerance());
  +        for (int i = 0; i < smallSamples.length; i++) {
  +            stat.clear();
  +            for (int j =0; j < smallSamples[i].length; j++) {
  +                stat.increment(smallSamples[i][j]);
  +            }
  +            TestUtils.assertEquals(stat.getResult(), stat.evaluate(smallSamples[i]), getTolerance());
  +        }
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message