Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 21.3k
Expand file tree
/
Copy pathBinaryToOctalTest.java
More file actions
Latest commit
24 lines (19 loc) · 1.02 KB
/
Copy pathBinaryToOctalTest.java
File metadata and controls
24 lines (19 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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;
publicclassBinaryToOctalTest {
@ParameterizedTest
@CsvSource({"0, 0", "1, 1", "10, 2", "111, 7", "1000, 10", "1111, 17", "110101, 65", "1010101, 125", "110110011, 663", "111111111, 777", "10010110, 226", "1011101, 135"})
voidtestConvertBinaryToOctal(intbinary, StringexpectedOctal) {
assertEquals(expectedOctal, BinaryToOctal.convertBinaryToOctal(binary));
}
@Test
voidtestIncorrectInput() {
assertThrows(IllegalArgumentException.class, () -> BinaryToOctal.convertBinaryToOctal(1234));
assertThrows(IllegalArgumentException.class, () -> BinaryToOctal.convertBinaryToOctal(102));
assertThrows(IllegalArgumentException.class, () -> BinaryToOctal.convertBinaryToOctal(-1010));
}
}