From bedea0067efaa806f2222184ffa2b3b35cdb3173 Mon Sep 17 00:00:00 2001 From: Phil Steitz Date: Thu, 18 Jul 2013 20:55:46 +0000 Subject: [PATCH] Added test to confirm null contract. JIRA: MATH-1007. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1504656 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/commons/math3/stat/StatUtilsTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/org/apache/commons/math3/stat/StatUtilsTest.java b/src/test/java/org/apache/commons/math3/stat/StatUtilsTest.java index 0ef432239..7d75e0a80 100644 --- a/src/test/java/org/apache/commons/math3/stat/StatUtilsTest.java +++ b/src/test/java/org/apache/commons/math3/stat/StatUtilsTest.java @@ -543,6 +543,14 @@ public final class StatUtilsTest { final double[] nansOnly = {Double.NaN, Double.NaN}; final double[] modeNansOnly = StatUtils.mode(nansOnly); Assert.assertEquals(0, modeNansOnly.length); + + final double[] nullArray = null; + try { + StatUtils.mode(nullArray); + Assert.fail("Expecting MathIllegalArgumentException"); + } catch (MathIllegalArgumentException ex) { + // Expected + } } }