|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+import org.junit.Test;
|
|
|
2
|
+import org.junit.runner.RunWith;
|
|
|
3
|
+import org.junit.runners.Parameterized;
|
|
|
4
|
+
|
|
|
5
|
+import java.util.Arrays;
|
|
|
6
|
+import java.util.Collection;
|
|
|
7
|
+
|
|
|
8
|
+import static org.junit.Assert.assertEquals;
|
|
|
9
|
+
|
|
|
10
|
+@RunWith(Parameterized.class)
|
|
|
11
|
+public class OctalTest {
|
|
|
12
|
+
|
|
|
13
|
+ private String input;
|
|
|
14
|
+ private int expectedOutput;
|
|
|
15
|
+
|
|
|
16
|
+ @Parameterized.Parameters
|
|
|
17
|
+ public static Collection<Object[]> data() {
|
|
|
18
|
+ return Arrays.asList(new Object[][]{
|
|
|
19
|
+ {"1", 1},
|
|
|
20
|
+ {"10", 8},
|
|
|
21
|
+ {"17", 15},
|
|
|
22
|
+ {"11", 9},
|
|
|
23
|
+ {"130", 88},
|
|
|
24
|
+ {"2047", 1063},
|
|
|
25
|
+ {"7777", 4095},
|
|
|
26
|
+ {"1234567", 342391},
|
|
|
27
|
+ {"carrot", 0},
|
|
|
28
|
+ {"8", 0},
|
|
|
29
|
+ {"9", 0},
|
|
|
30
|
+ {"6789", 0},
|
|
|
31
|
+ {"abc1z", 0},
|
|
|
32
|
+ {"011", 9}
|
|
|
33
|
+ });
|
|
|
34
|
+ }
|
|
|
35
|
+
|
|
|
36
|
+ public OctalTest(String input, int expectedOutput) {
|
|
|
37
|
+ this.input = input;
|
|
|
38
|
+ this.expectedOutput = expectedOutput;
|
|
|
39
|
+ }
|
|
|
40
|
+
|
|
|
41
|
+ @Test
|
|
|
42
|
+ public void test() {
|
|
|
43
|
+ Octal octal = new Octal(input);
|
|
|
44
|
+
|
|
|
45
|
+ assertEquals(expectedOutput, octal.getDecimal());
|
|
|
46
|
+ }
|
|
|
47
|
+}
|