-
Notifications
You must be signed in to change notification settings - Fork 19.8k
/
Copy pathOctalToDecimalTest.java
21 lines (17 loc) · 1.02 KB
/
OctalToDecimalTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.thealgorithms.conversions;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
public class OctalToDecimalTest {
@ParameterizedTest
@CsvSource({"10, 8", "7, 7", "77, 63", "123, 83", "0, 0", "777, 511", "2671, 1465", "275, 189"})
void testConvertOctalToDecimal(String inputOctal, int expectedDecimal) {
Assertions.assertEquals(expectedDecimal, OctalToDecimal.convertOctalToDecimal(inputOctal));
}
@ParameterizedTest
@CsvSource({"'', Input cannot be null or empty", "'8', Incorrect input: Expecting an octal number (digits 0-7)", "'19', Incorrect input: Expecting an octal number (digits 0-7)"})
void testIncorrectInput(String inputOctal, String expectedMessage) {
IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> OctalToDecimal.convertOctalToDecimal(inputOctal));
Assertions.assertEquals(expectedMessage, exception.getMessage());
}
}