Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8EF5D7B93 for ; Tue, 20 Sep 2011 19:21:21 +0000 (UTC) Received: (qmail 17722 invoked by uid 500); 20 Sep 2011 19:21:21 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 17659 invoked by uid 500); 20 Sep 2011 19:21:21 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 17651 invoked by uid 99); 20 Sep 2011 19:21:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2011 19:21:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2011 19:21:20 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1F7E123888FE for ; Tue, 20 Sep 2011 19:21:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1173313 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java Date: Tue, 20 Sep 2011 19:21:00 -0000 To: commits@commons.apache.org From: psteitz@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20110920192100.1F7E123888FE@eris.apache.org> Author: psteitz Date: Tue Sep 20 19:20:59 2011 New Revision: 1173313 URL: http://svn.apache.org/viewvc?rev=1173313&view=rev Log: Added test for consistency of cumulativeProbability(double,double) and cumulativeProbability(double). Contributed by Christian Winter. Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java?rev=1173313&r1=1173312&r2=1173313&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java Tue Sep 20 19:20:59 2011 @@ -20,6 +20,7 @@ package org.apache.commons.math.distribu import org.apache.commons.math.TestUtils; import org.apache.commons.math.util.FastMath; import org.apache.commons.math.exception.MathIllegalArgumentException; +import org.apache.commons.math.exception.NumberIsTooLargeException; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -144,12 +145,30 @@ public abstract class ContinuousDistribu * using current test instance data */ protected void verifyCumulativeProbabilities() throws Exception { + // verify cumulativeProbability(double) for (int i = 0; i < cumulativeTestPoints.length; i++) { TestUtils.assertEquals("Incorrect cumulative probability value returned for " + cumulativeTestPoints[i], cumulativeTestValues[i], distribution.cumulativeProbability(cumulativeTestPoints[i]), getTolerance()); } + // verify cumulativeProbability(double, double) + for (int i = 0; i < cumulativeTestPoints.length; i++) { + for (int j = 0; j < cumulativeTestPoints.length; j++) { + if (cumulativeTestPoints[i] <= cumulativeTestPoints[j]) { + TestUtils.assertEquals(cumulativeTestValues[j] - cumulativeTestValues[i], + distribution.cumulativeProbability(cumulativeTestPoints[i], cumulativeTestPoints[j]), + getTolerance()); + } else { + try { + distribution.cumulativeProbability(cumulativeTestPoints[i], cumulativeTestPoints[j]); + } catch (NumberIsTooLargeException e) { + continue; + } + Assert.fail("distribution.cumulativeProbability(double, double) should have thrown an exception that second argument is too large"); + } + } + } } /**