mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-28 23:15:17 +08:00
refactor: simplify ParseInteger
(#4376)
This commit is contained in:
@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
|
||||
*/
|
||||
public class ParseIntegerTest {
|
||||
private static final String NULL_PARAMETER_MESSAGE = "Input parameter must not be null!";
|
||||
private static final String EMPTY_PARAMETER_MESSAGE = "Input parameter must not be empty!";
|
||||
private static final String INCORRECT_FORMAT_MESSAGE = "Input parameter of incorrect format";
|
||||
|
||||
@Test
|
||||
@ -16,6 +17,12 @@ public class ParseIntegerTest {
|
||||
Assertions.assertEquals(exception.getMessage(), NULL_PARAMETER_MESSAGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyInput() {
|
||||
IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> ParseInteger.parseInt(""));
|
||||
Assertions.assertEquals(exception.getMessage(), EMPTY_PARAMETER_MESSAGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInputOfIncorrectFormat() {
|
||||
IllegalArgumentException exception = Assertions.assertThrows(NumberFormatException.class, () -> ParseInteger.parseInt("+0a123"));
|
||||
|
Reference in New Issue
Block a user