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/summary SumLogTest.java
Date Fri, 18 Jun 2004 06:33:27 GMT
psteitz     2004/06/17 23:33:27

  Modified:    math/src/test/org/apache/commons/math/stat/univariate/summary
                        SumLogTest.java
  Log:
  Added tests for special values.
  
  Revision  Changes    Path
  1.12      +31 -1     jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/summary/SumLogTest.java
  
  Index: SumLogTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/univariate/summary/SumLogTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SumLogTest.java	17 Jun 2004 21:37:05 -0000	1.11
  +++ SumLogTest.java	18 Jun 2004 06:33:27 -0000	1.12
  @@ -55,5 +55,35 @@
       public double expectedValue() {
           return this.sumLog;
       }
  +    
  +    public void testSpecialValues() {
  +        SumOfLogs sum = new SumOfLogs();
  +        // empty
  +        assertTrue(Double.isNaN(sum.getResult()));
  +        
  +        // finite data
  +        sum.increment(1d);
  +        assertFalse(Double.isNaN(sum.getResult()));
  +        
  +        // add negative infinity
  +        sum.increment(0d);
  +        assertEquals(Double.NEGATIVE_INFINITY, sum.getResult(), 0);
  +        
  +        // add positive infinity -- should make NaN
  +        sum.increment(Double.POSITIVE_INFINITY);
  +        assertTrue(Double.isNaN(sum.getResult()));
  +        
  +        // clear
  +        sum.clear();
  +        assertTrue(Double.isNaN(sum.getResult()));
  +        
  +        // positive infinity by itself
  +        sum.increment(Double.POSITIVE_INFINITY);
  +        assertEquals(Double.POSITIVE_INFINITY, sum.getResult(), 0);
  +        
  +        // negative value -- should make NaN
  +        sum.increment(-2d);
  +        assertTrue(Double.isNaN(sum.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