Skip to content

Commit a9bb0b9

Browse files
Enhanced-unit-tests
1 parent 59a2d0f commit a9bb0b9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/test/java/com/thealgorithms/conversions/TimeConverterTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ void testInvalidUnits(String from, String to) {
4343
assertThrows(IllegalArgumentException.class, () -> TimeConverter.convertTime(10, from, to));
4444
}
4545

46+
@Test
47+
@DisplayName("Null unit throws exception")
48+
void testNullUnit() {
49+
assertThrows(IllegalArgumentException.class, () -> TimeConverter.convertTime(10, null, "seconds"));
50+
51+
assertThrows(IllegalArgumentException.class, () -> TimeConverter.convertTime(10, "minutes", null));
52+
53+
assertThrows(IllegalArgumentException.class, () -> TimeConverter.convertTime(10, null, null));
54+
}
55+
4656
static Stream<org.junit.jupiter.params.provider.Arguments> roundTripCases() {
4757
return Stream.of(org.junit.jupiter.params.provider.Arguments.of(1.0, "hours", "minutes"), org.junit.jupiter.params.provider.Arguments.of(2.5, "days", "hours"), org.junit.jupiter.params.provider.Arguments.of(1000, "seconds", "minutes"));
4858
}

0 commit comments

Comments
 (0)