mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-02-04 04:23:32 +08:00
fix: handle Null Dereference in RomanToInteger (#5461)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.thealgorithms.conversions;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -10,5 +11,13 @@ public class RomanToIntegerTest {
|
||||
public void testRomanToInteger() {
|
||||
assertEquals(1994, RomanToInteger.romanToInt("MCMXCIV"));
|
||||
assertEquals(58, RomanToInteger.romanToInt("LVIII"));
|
||||
assertEquals(1804, RomanToInteger.romanToInt("MDCCCIV"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRomanToIntegerThrows() {
|
||||
assertThrows(IllegalArgumentException.class, () -> RomanToInteger.romanToInt("Z"));
|
||||
assertThrows(IllegalArgumentException.class, () -> RomanToInteger.romanToInt("MZI"));
|
||||
assertThrows(IllegalArgumentException.class, () -> RomanToInteger.romanToInt("MMMO"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user