update lab8 exception test
This commit is contained in:
1 file changed
+3
-21
@@ -134,30 +134,12 @@ class DateTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testConstructor() {
|
void testConstructorException() {
|
||||||
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() {
|
|
||||||
int day = 33;
|
int day = 33;
|
||||||
int month = 8;
|
int month = 8;
|
||||||
int year = 1999;
|
int year = 1999;
|
||||||
|
|
||||||
try {
|
assertThrows(IllegalArgumentException.class,
|
||||||
Date _date = new Date(day, month, year);
|
() -> { new Date(day, month, year); });
|
||||||
fail("Date created with invalid date");
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
assertEquals(true, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user