From afe19bb846de0827a0248e9eef8b48fec9f8ad19 Mon Sep 17 00:00:00 2001 From: Phil Steitz Date: Tue, 29 Jun 2004 06:07:10 +0000 Subject: [PATCH] Added tests for NaNs, infinite values. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141347 13f79535-47bb-0310-9956-ffa450edef68 --- .../stat/univariate/summary/ProductTest.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/test/org/apache/commons/math/stat/univariate/summary/ProductTest.java b/src/test/org/apache/commons/math/stat/univariate/summary/ProductTest.java index 4c4affcb3..b44347adc 100644 --- a/src/test/org/apache/commons/math/stat/univariate/summary/ProductTest.java +++ b/src/test/org/apache/commons/math/stat/univariate/summary/ProductTest.java @@ -23,7 +23,7 @@ import org.apache.commons.math.stat.univariate.UnivariateStatistic; /** * Test cases for the {@link UnivariateStatistic} class. - * @version $Revision: 1.12 $ $Date: 2004/06/17 21:37:05 $ + * @version $Revision: 1.13 $ $Date: 2004/06/29 06:07:10 $ */ public class ProductTest extends StorelessUnivariateStatisticAbstractTest{ @@ -59,5 +59,20 @@ public class ProductTest extends StorelessUnivariateStatisticAbstractTest{ public double expectedValue() { return this.product; } + + public void testSpecialValues() { + Product product = new Product(); + assertTrue(Double.isNaN(product.getResult())); + product.increment(1); + assertEquals(1, product.getResult(), 0); + product.increment(Double.POSITIVE_INFINITY); + assertEquals(Double.POSITIVE_INFINITY, product.getResult(), 0); + product.increment(Double.NEGATIVE_INFINITY); + assertEquals(Double.NEGATIVE_INFINITY, product.getResult(), 0); + product.increment(Double.NaN); + assertTrue(Double.isNaN(product.getResult())); + product.increment(1); + assertTrue(Double.isNaN(product.getResult())); + } }