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 A1E0217D62 for ; Tue, 7 Oct 2014 14:33:20 +0000 (UTC) Received: (qmail 70470 invoked by uid 500); 7 Oct 2014 14:33:15 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 70393 invoked by uid 500); 7 Oct 2014 14:33:15 -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 70384 invoked by uid 99); 7 Oct 2014 14:33:15 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Oct 2014 14:33:15 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 247508B5AB3; Tue, 7 Oct 2014 14:33:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: luc@apache.org To: commits@commons.apache.org Message-Id: <066c89bfb1554dd19d3f12bd55ea4542@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: Added proper checking of expected exception in FastMath tests. Date: Tue, 7 Oct 2014 14:33:15 +0000 (UTC) Repository: commons-math Updated Branches: refs/heads/master deb5e5298 -> 9d14fe21a Added proper checking of expected exception in FastMath tests. Some of the new functions trigger exceptions in the data range used for tests (overflows near range end, divisions by zero). The FastMath implementation throws compatible exception in the same cases, this is now tested correctly. Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/9d14fe21 Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/9d14fe21 Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/9d14fe21 Branch: refs/heads/master Commit: 9d14fe21a4044dafc984e1626ac5f465e35179ee Parents: deb5e52 Author: Luc Maisonobe Authored: Tue Oct 7 16:32:59 2014 +0200 Committer: Luc Maisonobe Committed: Tue Oct 7 16:32:59 2014 +0200 ---------------------------------------------------------------------- .../util/FastMathStrictComparisonTest.java | 22 +++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/9d14fe21/src/test/java/org/apache/commons/math3/util/FastMathStrictComparisonTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/util/FastMathStrictComparisonTest.java b/src/test/java/org/apache/commons/math3/util/FastMathStrictComparisonTest.java index 6f0483e..0a4cef5 100644 --- a/src/test/java/org/apache/commons/math3/util/FastMathStrictComparisonTest.java +++ b/src/test/java/org/apache/commons/math3/util/FastMathStrictComparisonTest.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.apache.commons.math3.exception.MathArithmeticException; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -159,12 +160,23 @@ public class FastMathStrictComparisonTest { } private static void callMethods(Method mathMethod, Method fastMethod, - Object[] params, int[] entries) throws IllegalAccessException, - InvocationTargetException { + Object[] params, int[] entries) throws IllegalAccessException { try { - Object expected = mathMethod.invoke(mathMethod, params); - Object actual = fastMethod.invoke(mathMethod, params); - if (!expected.equals(actual)) { + Object expected; + try { + expected = mathMethod.invoke(mathMethod, params); + } catch (InvocationTargetException ite) { + expected = ite.getCause(); + } + Object actual; + try { + actual = fastMethod.invoke(mathMethod, params); + } catch (InvocationTargetException ite) { + actual = ite.getCause(); + } + if (expected instanceof ArithmeticException) { + Assert.assertEquals(MathArithmeticException.class, actual.getClass()); + } else if (!expected.equals(actual)) { reportFailedResults(mathMethod, params, expected, actual, entries); } } catch (IllegalArgumentException e) {