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/moment GeometricMeanTest.java
Date Fri, 18 Jun 2004 07:04:20 GMT
psteitz     2004/06/18 00:04:20

  Modified:    math/src/test/org/apache/commons/math/stat/univariate/moment
                        GeometricMeanTest.java
  Log:
  Added tests for special values.
  
  Revision  Changes    Path
  1.11      +31 -1     jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/moment/GeometricMeanTest.java
  
  Index: GeometricMeanTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/moment/GeometricMeanTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- GeometricMeanTest.java	17 Jun 2004 21:37:05 -0000	1.10
  +++ GeometricMeanTest.java	18 Jun 2004 07:04:20 -0000	1.11
  @@ -55,5 +55,35 @@
       public double expectedValue() {
           return this.geoMean;
       }
  +    
  +    public void testSpecialValues() {
  +        GeometricMean mean = new GeometricMean();
  +        // empty
  +        assertTrue(Double.isNaN(mean.getResult()));
  +        
  +        // finite data
  +        mean.increment(1d);
  +        assertFalse(Double.isNaN(mean.getResult()));
  +        
  +        // add 0 -- makes log sum blow to minus infinity, should make 0
  +        mean.increment(0d);
  +        assertEquals(0d, mean.getResult(), 0);
  +        
  +        // add positive infinity - note the minus infinity above
  +        mean.increment(Double.POSITIVE_INFINITY);
  +        assertTrue(Double.isNaN(mean.getResult()));
  +        
  +        // clear
  +        mean.clear();
  +        assertTrue(Double.isNaN(mean.getResult()));
  +        
  +        // positive infinity by itself
  +        mean.increment(Double.POSITIVE_INFINITY);
  +        assertEquals(Double.POSITIVE_INFINITY, mean.getResult(), 0);
  +        
  +        // negative value -- should make NaN
  +        mean.increment(-2d);
  +        assertTrue(Double.isNaN(mean.getResult()));
  +    }
   
   }
  
  
  

---------------------------------------------------------------------
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