- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathOctalToHexadecimalTest.java
23 lines (19 loc) · 1.05 KB
/
OctalToHexadecimalTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
packagecom.thealgorithms.conversions;
importorg.junit.jupiter.api.Assertions;
importorg.junit.jupiter.params.ParameterizedTest;
importorg.junit.jupiter.params.provider.CsvSource;
publicclassOctalToHexadecimalTest {
@ParameterizedTest
@CsvSource({"0, 0", "7, 7", "10, 8", "17, F", "20, 10", "777, 1FF", "1234, 29C", "752, 1EA", "536, 15E"})
voidtestCorrectInputs(StringinputOctal, StringexpectedHex) {
intdecimal = OctalToHexadecimal.octalToDecimal(inputOctal);
Stringhex = OctalToHexadecimal.decimalToHexadecimal(decimal);
Assertions.assertEquals(expectedHex, hex);
}
@ParameterizedTest
@CsvSource({"'', Input cannot be null or empty", "'8', Incorrect octal digit: 8", "'19', Incorrect octal digit: 9"})
voidtestIncorrectInputs(StringinputOctal, StringexpectedMessage) {
IllegalArgumentExceptionexception = Assertions.assertThrows(IllegalArgumentException.class, () -> OctalToHexadecimal.octalToDecimal(inputOctal));
Assertions.assertEquals(expectedMessage, exception.getMessage());
}
}