From b4fe40eabcf8656ee8b3f5a66d2f9622cdba9b6b Mon Sep 17 00:00:00 2001 From: SowinskiBraeden Date: Wed, 12 Mar 2025 19:56:32 -0700 Subject: [PATCH] update lab8 exception test --- test/ca/bcit/comp1510/lab08/DateTest.java | 24 +++-------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/test/ca/bcit/comp1510/lab08/DateTest.java b/test/ca/bcit/comp1510/lab08/DateTest.java index 71ce3f7..79078a0 100644 --- a/test/ca/bcit/comp1510/lab08/DateTest.java +++ b/test/ca/bcit/comp1510/lab08/DateTest.java @@ -134,30 +134,12 @@ class DateTest { } @Test - void testConstructor() { - int day = 26; - int month = 4; - int year = 2005; - - try { - Date _date = new Date(day, month, year); - assertEquals(true, true); - } catch (IllegalArgumentException e) { - fail("IllegalArgumentException on valid date creation"); - } - } - - @Test - void testConstructor1() { + void testConstructorException() { int day = 33; int month = 8; int year = 1999; - try { - Date _date = new Date(day, month, year); - fail("Date created with invalid date"); - } catch (IllegalArgumentException e) { - assertEquals(true, true); - } + assertThrows(IllegalArgumentException.class, + () -> { new Date(day, month, year); }); } }