|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+import org.junit.Before;
|
|
1
|
2
|
import org.junit.Ignore;
|
|
2
|
3
|
import org.junit.Test;
|
|
3
|
4
|
|
|
|
@@ -9,7 +10,13 @@ import java.util.stream.Collectors;
|
|
9
|
10
|
|
|
10
|
11
|
import static junit.framework.TestCase.*;
|
|
11
|
12
|
|
|
12
|
|
-public class PalindromesTest {
|
|
|
13
|
+public class PalindromeCalculatorTest {
|
|
|
14
|
+ private PalindromeCalculator palindromeCalculator;
|
|
|
15
|
+
|
|
|
16
|
+ @Before
|
|
|
17
|
+ public void setup() {
|
|
|
18
|
+ palindromeCalculator = new PalindromeCalculator();
|
|
|
19
|
+ }
|
|
13
|
20
|
|
|
14
|
21
|
@Test
|
|
15
|
22
|
public void largestPalindromeFromSingleDigitFactors() {
|
|
|
@@ -21,7 +28,7 @@ public class PalindromesTest {
|
|
21
|
28
|
);
|
|
22
|
29
|
final long expectedValue = 9l;
|
|
23
|
30
|
|
|
24
|
|
- final SortedMap<Long, List<List<Integer>>> palindromes = Palindromes.getPalindromeProductsWithFactors(1, 9);
|
|
|
31
|
+ final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1, 9);
|
|
25
|
32
|
|
|
26
|
33
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.lastKey());
|
|
27
|
34
|
}
|
|
|
@@ -36,7 +43,7 @@ public class PalindromesTest {
|
|
36
|
43
|
);
|
|
37
|
44
|
final long expectedValue = 9009l;
|
|
38
|
45
|
|
|
39
|
|
- final SortedMap<Long, List<List<Integer>>> palindromes = Palindromes.getPalindromeProductsWithFactors(10, 99);
|
|
|
46
|
+ final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(10, 99);
|
|
40
|
47
|
|
|
41
|
48
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.lastKey());
|
|
42
|
49
|
}
|
|
|
@@ -51,7 +58,7 @@ public class PalindromesTest {
|
|
51
|
58
|
);
|
|
52
|
59
|
final long expectedValue = 121l;
|
|
53
|
60
|
|
|
54
|
|
- final SortedMap<Long, List<List<Integer>>> palindromes = Palindromes.getPalindromeProductsWithFactors(10, 99);
|
|
|
61
|
+ final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(10, 99);
|
|
55
|
62
|
|
|
56
|
63
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
|
|
57
|
64
|
}
|
|
|
@@ -66,7 +73,7 @@ public class PalindromesTest {
|
|
66
|
73
|
);
|
|
67
|
74
|
final long expectedValue = 906609l;
|
|
68
|
75
|
|
|
69
|
|
- final SortedMap<Long, List<List<Integer>>> palindromes = Palindromes.getPalindromeProductsWithFactors(100, 999);
|
|
|
76
|
+ final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(100, 999);
|
|
70
|
77
|
|
|
71
|
78
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.lastKey());
|
|
72
|
79
|
}
|
|
|
@@ -81,7 +88,7 @@ public class PalindromesTest {
|
|
81
|
88
|
);
|
|
82
|
89
|
final long expectedValue = 10201l;
|
|
83
|
90
|
|
|
84
|
|
- final SortedMap<Long, List<List<Integer>>> palindromes = Palindromes.getPalindromeProductsWithFactors(100, 999);
|
|
|
91
|
+ final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(100, 999);
|
|
85
|
92
|
|
|
86
|
93
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
|
|
87
|
94
|
}
|