From fac65b868c549d28b786568636bbc8362d2a78f2 Mon Sep 17 00:00:00 2001 From: Casey Scarborough Date: Sat, 23 Apr 2016 13:46:21 -0400 Subject: [PATCH] LANG-1220: Add tests for missed branches in DateUtils --- .../commons/lang3/time/DateUtilsTest.java | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java index 271043230..0b80ab633 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java @@ -170,10 +170,20 @@ public class DateUtilsTest { } @Test(expected = IllegalArgumentException.class) - public void testIsDameDay_DateNullNull() throws Exception { + public void testIsSameDay_DateNullNull() throws Exception { DateUtils.isSameDay((Date) null, (Date) null); } + @Test(expected = IllegalArgumentException.class) + public void testIsSameDay_DateNullNotNull() throws Exception { + DateUtils.isSameDay((Date) null, new Date()); + } + + @Test(expected = IllegalArgumentException.class) + public void testIsSameDay_DateNotNullNull() throws Exception { + DateUtils.isSameDay(new Date(), (Date) null); + } + //----------------------------------------------------------------------- @Test public void testIsSameDay_Cal() { @@ -193,6 +203,16 @@ public class DateUtilsTest { DateUtils.isSameDay((Calendar) null, (Calendar) null); } + @Test(expected = IllegalArgumentException.class) + public void testIsSameDay_CalNullNotNull() throws Exception { + DateUtils.isSameDay((Calendar) null, Calendar.getInstance()); + } + + @Test(expected = IllegalArgumentException.class) + public void testIsSameDay_CalNotNullNull() throws Exception { + DateUtils.isSameDay(Calendar.getInstance(), (Calendar) null); + } + //----------------------------------------------------------------------- @Test public void testIsSameInstant_Date() { @@ -212,6 +232,16 @@ public class DateUtilsTest { DateUtils.isSameInstant((Date) null, (Date) null); } + @Test(expected = IllegalArgumentException.class) + public void testIsSameInstant_DateNullNotNull() throws Exception { + DateUtils.isSameInstant((Date) null, new Date()); + } + + @Test(expected = IllegalArgumentException.class) + public void testIsSameInstant_DateNotNullNull() throws Exception { + DateUtils.isSameInstant(new Date(), (Date) null); + } + //----------------------------------------------------------------------- @Test public void testIsSameInstant_Cal() { @@ -232,6 +262,16 @@ public class DateUtilsTest { DateUtils.isSameInstant((Calendar) null, (Calendar) null); } + @Test(expected = IllegalArgumentException.class) + public void testIsSameInstant_CalNullNotNull() throws Exception { + DateUtils.isSameInstant((Calendar) null, Calendar.getInstance()); + } + + @Test(expected = IllegalArgumentException.class) + public void testIsSameInstant_CalNotNullNull() throws Exception { + DateUtils.isSameInstant(Calendar.getInstance(), (Calendar) null); + } + //----------------------------------------------------------------------- @Test public void testIsSameLocalTime_Cal() { @@ -260,6 +300,16 @@ public class DateUtilsTest { DateUtils.isSameLocalTime((Calendar) null, (Calendar) null); } + @Test(expected = IllegalArgumentException.class) + public void testIsSameLocalTime_CalNullNotNull() throws Exception { + DateUtils.isSameLocalTime((Calendar) null, Calendar.getInstance()); + } + + @Test(expected = IllegalArgumentException.class) + public void testIsSameLocalTime_CalNotNullNull() throws Exception { + DateUtils.isSameLocalTime(Calendar.getInstance(), (Calendar) null); + } + //----------------------------------------------------------------------- @Test public void testParseDate() throws Exception {