1 16 package org.apache.commons.math.stat.descriptive.summary; 17 18 import junit.framework.Test; 19 import junit.framework.TestSuite; 20 21 import org.apache.commons.math.stat.descriptive.StorelessUnivariateStatisticAbstractTest; 22 import org.apache.commons.math.stat.descriptive.UnivariateStatistic; 23 24 28 public class ProductTest extends StorelessUnivariateStatisticAbstractTest{ 29 30 protected Product stat; 31 32 35 public ProductTest(String name) { 36 super(name); 37 } 38 39 public static Test suite() { 40 TestSuite suite = new TestSuite(ProductTest.class); 41 suite.setName("Product Tests"); 42 return suite; 43 } 44 45 48 public UnivariateStatistic getUnivariateStatistic() { 49 return new Product(); 50 } 51 52 public double getTolerance() { 53 return 10E8; } 55 56 59 public double expectedValue() { 60 return this.product; 61 } 62 63 public void testSpecialValues() { 64 Product product = new Product(); 65 assertTrue(Double.isNaN(product.getResult())); 66 product.increment(1); 67 assertEquals(1, product.getResult(), 0); 68 product.increment(Double.POSITIVE_INFINITY); 69 assertEquals(Double.POSITIVE_INFINITY, product.getResult(), 0); 70 product.increment(Double.NEGATIVE_INFINITY); 71 assertEquals(Double.NEGATIVE_INFINITY, product.getResult(), 0); 72 product.increment(Double.NaN); 73 assertTrue(Double.isNaN(product.getResult())); 74 product.increment(1); 75 assertTrue(Double.isNaN(product.getResult())); 76 } 77 78 } 79 | Popular Tags |