- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathDecimalToAnyBaseTest.java
23 lines (18 loc) · 925 Bytes
/
DecimalToAnyBaseTest.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;
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
importstaticorg.junit.jupiter.api.Assertions.assertThrows;
importorg.junit.jupiter.api.Test;
importorg.junit.jupiter.params.ParameterizedTest;
importorg.junit.jupiter.params.provider.CsvSource;
publicclassDecimalToAnyBaseTest {
@ParameterizedTest
@CsvSource({"0, 2, 0", "0, 16, 0", "0, 36, 0", "10, 2, 1010", "255, 16, FF", "100, 8, 144", "42, 2, 101010", "1234, 16, 4D2", "1234, 36, YA"})
voidtestConvertToAnyBase(intdecimal, intbase, Stringexpected) {
assertEquals(expected, DecimalToAnyBase.convertToAnyBase(decimal, base));
}
@Test
voidtestBaseOutOfRange() {
assertThrows(IllegalArgumentException.class, () -> DecimalToAnyBase.convertToAnyBase(10, 1));
assertThrows(IllegalArgumentException.class, () -> DecimalToAnyBase.convertToAnyBase(10, 37));
}
}