|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+import org.junit.Test;
|
|
|
2
|
+import org.junit.runner.RunWith;
|
|
|
3
|
+import org.junit.runners.Parameterized;
|
|
|
4
|
+import org.junit.runners.Parameterized.Parameters;
|
|
|
5
|
+
|
|
|
6
|
+import java.util.Arrays;
|
|
|
7
|
+import java.util.Collection;
|
|
|
8
|
+
|
|
|
9
|
+import static org.junit.Assert.assertEquals;
|
|
|
10
|
+
|
|
|
11
|
+@RunWith(Parameterized.class)
|
|
|
12
|
+public class RaindropsTest {
|
|
|
13
|
+
|
|
|
14
|
+ private int input;
|
|
|
15
|
+ private String expectedOutput;
|
|
|
16
|
+
|
|
|
17
|
+ @Parameters
|
|
|
18
|
+ public static Collection<Object[]> data() {
|
|
|
19
|
+ return Arrays.asList(new Object[][]{
|
|
|
20
|
+ // Non-primes
|
|
|
21
|
+ {1, "1"},
|
|
|
22
|
+ {52, "52"},
|
|
|
23
|
+ {12121, "12121"},
|
|
|
24
|
+
|
|
|
25
|
+ // Numbers with 3 as a prime factor
|
|
|
26
|
+ {3, "Pling"},
|
|
|
27
|
+ {6, "Pling"},
|
|
|
28
|
+ {9, "Pling"},
|
|
|
29
|
+
|
|
|
30
|
+ // Numbers with 5 as a prime factor
|
|
|
31
|
+ {5, "Plang"},
|
|
|
32
|
+ {10, "Plang"},
|
|
|
33
|
+ {25, "Plang"},
|
|
|
34
|
+
|
|
|
35
|
+ // Numbers with 7 as a prime factor
|
|
|
36
|
+ {7, "Plong"},
|
|
|
37
|
+ {14, "Plong"},
|
|
|
38
|
+ {49, "Plong"},
|
|
|
39
|
+
|
|
|
40
|
+ // Numbers with multiple activating prime factors
|
|
|
41
|
+ {15, "PlingPlang"},
|
|
|
42
|
+ {21, "PlingPlong"},
|
|
|
43
|
+ {35, "PlangPlong"},
|
|
|
44
|
+ {105, "PlingPlangPlong"},
|
|
|
45
|
+ });
|
|
|
46
|
+ }
|
|
|
47
|
+
|
|
|
48
|
+ public RaindropsTest(int input, String expectedOutput) {
|
|
|
49
|
+ this.input = input;
|
|
|
50
|
+ this.expectedOutput = expectedOutput;
|
|
|
51
|
+ }
|
|
|
52
|
+
|
|
|
53
|
+ @Test
|
|
|
54
|
+ public void test() {
|
|
|
55
|
+ assertEquals(expectedOutput, Raindrops.convert(input));
|
|
|
56
|
+ }
|
|
|
57
|
+}
|