From 75b967beaa16f61bd30cc30932be90391645ac92 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Mon, 20 Jul 2009 16:14:34 +0000 Subject: [PATCH] Improving code coverage by testing exceptions and empty constructor git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@795895 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/lang/math/IEEE754rUtilsTest.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/test/org/apache/commons/lang/math/IEEE754rUtilsTest.java b/src/test/org/apache/commons/lang/math/IEEE754rUtilsTest.java index 0f2a66d37..89495f4c1 100644 --- a/src/test/org/apache/commons/lang/math/IEEE754rUtilsTest.java +++ b/src/test/org/apache/commons/lang/math/IEEE754rUtilsTest.java @@ -49,5 +49,52 @@ public class IEEE754rUtilsTest extends TestCase { assertEquals(1.2f, IEEE754rUtils.min(bF), 0.01); assertEquals(42.0f, IEEE754rUtils.max(bF), 0.01); } + + public void testEnforceExceptions() { + try { + IEEE754rUtils.min( (float[]) null); + fail("IllegalArgumentException expected for null input"); + } catch(IllegalArgumentException iae) { /* expected */ } + + try { + IEEE754rUtils.min(new float[0]); + fail("IllegalArgumentException expected for empty input"); + } catch(IllegalArgumentException iae) { /* expected */ } + + try { + IEEE754rUtils.max( (float[]) null); + fail("IllegalArgumentException expected for null input"); + } catch(IllegalArgumentException iae) { /* expected */ } + + try { + IEEE754rUtils.max(new float[0]); + fail("IllegalArgumentException expected for empty input"); + } catch(IllegalArgumentException iae) { /* expected */ } + + try { + IEEE754rUtils.min( (double[]) null); + fail("IllegalArgumentException expected for null input"); + } catch(IllegalArgumentException iae) { /* expected */ } + + try { + IEEE754rUtils.min(new double[0]); + fail("IllegalArgumentException expected for empty input"); + } catch(IllegalArgumentException iae) { /* expected */ } + + try { + IEEE754rUtils.max( (double[]) null); + fail("IllegalArgumentException expected for null input"); + } catch(IllegalArgumentException iae) { /* expected */ } + + try { + IEEE754rUtils.max(new double[0]); + fail("IllegalArgumentException expected for empty input"); + } catch(IllegalArgumentException iae) { /* expected */ } + + } + + public void testConstructorExists() { + new IEEE754rUtils(); + } }