|
|
@@ -1,17 +1,17 @@
|
|
1
|
1
|
import org.junit.Test;
|
|
2
|
|
-import org.junit.Ignore;
|
|
3
|
2
|
import org.junit.runner.RunWith;
|
|
4
|
3
|
import org.junit.runners.Parameterized;
|
|
5
|
4
|
import org.junit.runners.Parameterized.Parameters;
|
|
6
|
5
|
|
|
7
|
6
|
import java.util.Arrays;
|
|
8
|
7
|
import java.util.Collection;
|
|
|
8
|
+import java.util.Collections;
|
|
9
|
9
|
import java.util.List;
|
|
10
|
10
|
|
|
11
|
11
|
import static org.junit.Assert.assertEquals;
|
|
12
|
12
|
|
|
13
|
13
|
@RunWith(Parameterized.class)
|
|
14
|
|
-public class PrimeFactorsTest {
|
|
|
14
|
+public class PrimeFactorsCalculatorTest {
|
|
15
|
15
|
|
|
16
|
16
|
private long input;
|
|
17
|
17
|
private List<Long> expectedOutput;
|
|
|
@@ -19,9 +19,9 @@ public class PrimeFactorsTest {
|
|
19
|
19
|
@Parameters(name="Prime factors of {0} = {1}")
|
|
20
|
20
|
public static Collection<Object[]> data() {
|
|
21
|
21
|
return Arrays.asList(new Object[][]{
|
|
22
|
|
- {1L, Arrays.asList()},
|
|
23
|
|
- {2L, Arrays.asList(2L)},
|
|
24
|
|
- {3L, Arrays.asList(3L)},
|
|
|
22
|
+ {1L, Collections.emptyList()},
|
|
|
23
|
+ {2L, Collections.singletonList(2L)},
|
|
|
24
|
+ {3L, Collections.singletonList(3L)},
|
|
25
|
25
|
{4L, Arrays.asList(2L, 2L)},
|
|
26
|
26
|
{6L, Arrays.asList(2L, 3L)},
|
|
27
|
27
|
{8L, Arrays.asList(2L, 2L, 2L)},
|
|
|
@@ -33,14 +33,14 @@ public class PrimeFactorsTest {
|
|
33
|
33
|
});
|
|
34
|
34
|
}
|
|
35
|
35
|
|
|
36
|
|
- public PrimeFactorsTest(long input, List<Long> expectedOutput) {
|
|
|
36
|
+ public PrimeFactorsCalculatorTest(long input, List<Long> expectedOutput) {
|
|
37
|
37
|
this.input = input;
|
|
38
|
38
|
this.expectedOutput = expectedOutput;
|
|
39
|
39
|
}
|
|
40
|
40
|
|
|
41
|
|
-
|
|
42
|
41
|
@Test
|
|
43
|
42
|
public void test() {
|
|
44
|
|
- assertEquals(expectedOutput, PrimeFactors.getForNumber(input));
|
|
|
43
|
+ assertEquals(expectedOutput, new PrimeFactorsCalculator().calculatePrimeFactorsOf(input));
|
|
45
|
44
|
}
|
|
|
45
|
+
|
|
46
|
46
|
}
|