Kaynağa Gözat

Merge branch 'master' of git://github.com/exercism/java into rna-transcription

Scott Ertel 8 yıl önce
ebeveyn
işleme
b2d023c852

+ 36
- 36
exercises/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java Dosyayı Görüntüle

@@ -12,10 +12,10 @@ public class LargestSeriesProductCalculatorTest {
12 12
 
13 13
     @Test
14 14
     public void testCorrectlyCalculatesLargestProductWhenSeriesLengthEqualsStringToSearchLength() {
15
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("29");
16
-        final long expectedProduct = 18;
15
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("29");
16
+        long expectedProduct = 18;
17 17
 
18
-        final long actualProduct = calculator.calculateLargestProductForSeriesLength(2);
18
+        long actualProduct = calculator.calculateLargestProductForSeriesLength(2);
19 19
 
20 20
         assertEquals(expectedProduct, actualProduct);
21 21
     }
@@ -23,10 +23,10 @@ public class LargestSeriesProductCalculatorTest {
23 23
     @Ignore("Remove to run test")
24 24
     @Test
25 25
     public void testCorrectlyCalculatesLargestProductOfLengthTwoWithNumbersInOrder() {
26
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("0123456789");
27
-        final long expectedProduct = 72;
26
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("0123456789");
27
+        long expectedProduct = 72;
28 28
 
29
-        final long actualProduct = calculator.calculateLargestProductForSeriesLength(2);
29
+        long actualProduct = calculator.calculateLargestProductForSeriesLength(2);
30 30
 
31 31
         assertEquals(expectedProduct, actualProduct);
32 32
     }
@@ -34,10 +34,10 @@ public class LargestSeriesProductCalculatorTest {
34 34
     @Ignore("Remove to run test")
35 35
     @Test
36 36
     public void testCorrectlyCalculatesLargestProductOfLengthTwoWithNumbersNotInOrder() {
37
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("576802143");
38
-        final long expectedProduct = 48;
37
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("576802143");
38
+        long expectedProduct = 48;
39 39
 
40
-        final long actualProduct = calculator.calculateLargestProductForSeriesLength(2);
40
+        long actualProduct = calculator.calculateLargestProductForSeriesLength(2);
41 41
 
42 42
         assertEquals(expectedProduct, actualProduct);
43 43
     }
@@ -45,10 +45,10 @@ public class LargestSeriesProductCalculatorTest {
45 45
     @Ignore("Remove to run test")
46 46
     @Test
47 47
     public void testCorrectlyCalculatesLargestProductOfLengthThreeWithNumbersInOrder() {
48
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("0123456789");
49
-        final long expectedProduct = 504;
48
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("0123456789");
49
+        long expectedProduct = 504;
50 50
 
51
-        final long actualProduct = calculator.calculateLargestProductForSeriesLength(3);
51
+        long actualProduct = calculator.calculateLargestProductForSeriesLength(3);
52 52
 
53 53
         assertEquals(expectedProduct, actualProduct);
54 54
     }
@@ -56,10 +56,10 @@ public class LargestSeriesProductCalculatorTest {
56 56
     @Ignore("Remove to run test")
57 57
     @Test
58 58
     public void testCorrectlyCalculatesLargestProductOfLengthThreeWithNumbersNotInOrder() {
59
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("1027839564");
60
-        final long expectedProduct = 270;
59
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("1027839564");
60
+        long expectedProduct = 270;
61 61
 
62
-        final long actualProduct = calculator.calculateLargestProductForSeriesLength(3);
62
+        long actualProduct = calculator.calculateLargestProductForSeriesLength(3);
63 63
 
64 64
         assertEquals(expectedProduct, actualProduct);
65 65
     }
@@ -67,10 +67,10 @@ public class LargestSeriesProductCalculatorTest {
67 67
     @Ignore("Remove to run test")
68 68
     @Test
69 69
     public void testCorrectlyCalculatesLargestProductOfLengthFiveWithNumbersInOrder() {
70
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("0123456789");
71
-        final long expectedProduct = 15120;
70
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("0123456789");
71
+        long expectedProduct = 15120;
72 72
 
73
-        final long actualProduct = calculator.calculateLargestProductForSeriesLength(5);
73
+        long actualProduct = calculator.calculateLargestProductForSeriesLength(5);
74 74
 
75 75
         assertEquals(expectedProduct, actualProduct);
76 76
     }
@@ -78,12 +78,12 @@ public class LargestSeriesProductCalculatorTest {
78 78
     @Ignore("Remove to run test")
79 79
     @Test
80 80
     public void testCorrectlyCalculatesLargestProductInLongStringToSearchV1() {
81
-        final LargestSeriesProductCalculator calculator
81
+        LargestSeriesProductCalculator calculator
82 82
                 = new LargestSeriesProductCalculator("73167176531330624919225119674426574742355349194934");
83 83
 
84
-        final long expectedProduct = 23520;
84
+        long expectedProduct = 23520;
85 85
 
86
-        final long actualProduct = calculator.calculateLargestProductForSeriesLength(6);
86
+        long actualProduct = calculator.calculateLargestProductForSeriesLength(6);
87 87
 
88 88
         assertEquals(expectedProduct, actualProduct);
89 89
     }
@@ -91,10 +91,10 @@ public class LargestSeriesProductCalculatorTest {
91 91
     @Ignore("Remove to run test")
92 92
     @Test
93 93
     public void testCorrectlyCalculatesLargestProductOfZeroIfAllDigitsAreZeroes() {
94
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("0000");
95
-        final long expectedProduct = 0;
94
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("0000");
95
+        long expectedProduct = 0;
96 96
 
97
-        final long actualProduct = calculator.calculateLargestProductForSeriesLength(2);
97
+        long actualProduct = calculator.calculateLargestProductForSeriesLength(2);
98 98
 
99 99
         assertEquals(expectedProduct, actualProduct);
100 100
     }
@@ -102,10 +102,10 @@ public class LargestSeriesProductCalculatorTest {
102 102
     @Ignore("Remove to run test")
103 103
     @Test
104 104
     public void testCorrectlyCalculatesLargestProductOfZeroIfAllSeriesOfGivenLengthContainZero() {
105
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("99099");
106
-        final long expectedProduct = 0;
105
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("99099");
106
+        long expectedProduct = 0;
107 107
 
108
-        final long actualProduct = calculator.calculateLargestProductForSeriesLength(3);
108
+        long actualProduct = calculator.calculateLargestProductForSeriesLength(3);
109 109
 
110 110
         assertEquals(expectedProduct, actualProduct);
111 111
     }
@@ -113,7 +113,7 @@ public class LargestSeriesProductCalculatorTest {
113 113
     @Ignore("Remove to run test")
114 114
     @Test
115 115
     public void testSeriesLengthLongerThanLengthOfStringToTestIsRejected() {
116
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("123");
116
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("123");
117 117
 
118 118
         expectedException.expect(IllegalArgumentException.class);
119 119
         expectedException.expectMessage(
@@ -125,10 +125,10 @@ public class LargestSeriesProductCalculatorTest {
125 125
     @Ignore("Remove to run test")
126 126
     @Test
127 127
     public void testCorrectlyCalculatesLargestProductOfLength0ForEmptyStringToSearch() {
128
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("");
129
-        final long expectedProduct = 1;
128
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("");
129
+        long expectedProduct = 1;
130 130
 
131
-        final long actualProduct = calculator.calculateLargestProductForSeriesLength(0);
131
+        long actualProduct = calculator.calculateLargestProductForSeriesLength(0);
132 132
 
133 133
         assertEquals(expectedProduct, actualProduct);
134 134
     }
@@ -136,10 +136,10 @@ public class LargestSeriesProductCalculatorTest {
136 136
     @Ignore("Remove to run test")
137 137
     @Test
138 138
     public void testCorrectlyCalculatesLargestProductOfLength0ForNonEmptyStringToSearch() {
139
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("123");
140
-        final long expectedProduct = 1;
139
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("123");
140
+        long expectedProduct = 1;
141 141
 
142
-        final long actualProduct = calculator.calculateLargestProductForSeriesLength(0);
142
+        long actualProduct = calculator.calculateLargestProductForSeriesLength(0);
143 143
 
144 144
         assertEquals(expectedProduct, actualProduct);
145 145
     }
@@ -147,7 +147,7 @@ public class LargestSeriesProductCalculatorTest {
147 147
     @Ignore("Remove to run test")
148 148
     @Test
149 149
     public void testEmptyStringToSearchAndSeriesOfNonZeroLengthIsRejected() {
150
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("");
150
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("");
151 151
 
152 152
         expectedException.expect(IllegalArgumentException.class);
153 153
         expectedException.expectMessage(
@@ -168,7 +168,7 @@ public class LargestSeriesProductCalculatorTest {
168 168
     @Ignore("Remove to run test")
169 169
     @Test
170 170
     public void testNegativeSeriesLengthIsRejected() {
171
-        final LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("12345");
171
+        LargestSeriesProductCalculator calculator = new LargestSeriesProductCalculator("12345");
172 172
 
173 173
         expectedException.expect(IllegalArgumentException.class);
174 174
         expectedException.expectMessage("Series length must be non-negative.");

+ 36
- 36
exercises/minesweeper/src/test/java/MinesweeperBoardTest.java Dosyayı Görüntüle

@@ -11,9 +11,9 @@ public class MinesweeperBoardTest {
11 11
 
12 12
     @Test
13 13
     public void testInputBoardWithNoRowsAndNoColumns() {
14
-        final List<String> inputBoard = Collections.emptyList();
15
-        final List<String> expectedNumberedBoard = Collections.emptyList();
16
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
14
+        List<String> inputBoard = Collections.emptyList();
15
+        List<String> expectedNumberedBoard = Collections.emptyList();
16
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
17 17
 
18 18
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
19 19
     }
@@ -21,9 +21,9 @@ public class MinesweeperBoardTest {
21 21
     @Ignore("Remove to run test")
22 22
     @Test
23 23
     public void testInputBoardWithOneRowAndNoColumns() {
24
-        final List<String> inputBoard = Collections.singletonList("");
25
-        final List<String> expectedNumberedBoard = Collections.singletonList("");
26
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
24
+        List<String> inputBoard = Collections.singletonList("");
25
+        List<String> expectedNumberedBoard = Collections.singletonList("");
26
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
27 27
 
28 28
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
29 29
     }
@@ -31,19 +31,19 @@ public class MinesweeperBoardTest {
31 31
     @Ignore("Remove to run test")
32 32
     @Test
33 33
     public void testInputBoardWithNoMines() {
34
-        final List<String> inputBoard = Arrays.asList(
34
+        List<String> inputBoard = Arrays.asList(
35 35
                 "   ",
36 36
                 "   ",
37 37
                 "   "
38 38
         );
39 39
 
40
-        final List<String> expectedNumberedBoard = Arrays.asList(
40
+        List<String> expectedNumberedBoard = Arrays.asList(
41 41
                 "   ",
42 42
                 "   ",
43 43
                 "   "
44 44
         );
45 45
 
46
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
46
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
47 47
 
48 48
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
49 49
     }
@@ -51,19 +51,19 @@ public class MinesweeperBoardTest {
51 51
     @Ignore("Remove to run test")
52 52
     @Test
53 53
     public void testInputBoardWithOnlyMines() {
54
-        final List<String> inputBoard = Arrays.asList(
54
+        List<String> inputBoard = Arrays.asList(
55 55
                 "***",
56 56
                 "***",
57 57
                 "***"
58 58
         );
59 59
 
60
-        final List<String> expectedNumberedBoard = Arrays.asList(
60
+        List<String> expectedNumberedBoard = Arrays.asList(
61 61
                 "***",
62 62
                 "***",
63 63
                 "***"
64 64
         );
65 65
 
66
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
66
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
67 67
 
68 68
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
69 69
     }
@@ -71,19 +71,19 @@ public class MinesweeperBoardTest {
71 71
     @Ignore("Remove to run test")
72 72
     @Test
73 73
     public void testInputBoardWithSingleMineAtCenter() {
74
-        final List<String> inputBoard = Arrays.asList(
74
+        List<String> inputBoard = Arrays.asList(
75 75
                 "   ",
76 76
                 " * ",
77 77
                 "   "
78 78
         );
79 79
 
80
-        final List<String> expectedNumberedBoard = Arrays.asList(
80
+        List<String> expectedNumberedBoard = Arrays.asList(
81 81
                 "111",
82 82
                 "1*1",
83 83
                 "111"
84 84
         );
85 85
 
86
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
86
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
87 87
 
88 88
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
89 89
     }
@@ -91,19 +91,19 @@ public class MinesweeperBoardTest {
91 91
     @Ignore("Remove to run test")
92 92
     @Test
93 93
     public void testInputBoardWithMinesAroundPerimeter() {
94
-        final List<String> inputBoard = Arrays.asList(
94
+        List<String> inputBoard = Arrays.asList(
95 95
                 "***",
96 96
                 "* *",
97 97
                 "***"
98 98
         );
99 99
 
100
-        final List<String> expectedNumberedBoard = Arrays.asList(
100
+        List<String> expectedNumberedBoard = Arrays.asList(
101 101
                 "***",
102 102
                 "*8*",
103 103
                 "***"
104 104
         );
105 105
 
106
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
106
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
107 107
 
108 108
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
109 109
     }
@@ -111,15 +111,15 @@ public class MinesweeperBoardTest {
111 111
     @Ignore("Remove to run test")
112 112
     @Test
113 113
     public void testInputBoardWithSingleRowAndTwoMines() {
114
-        final List<String> inputBoard = Collections.singletonList(
114
+        List<String> inputBoard = Collections.singletonList(
115 115
                 " * * "
116 116
         );
117 117
 
118
-        final List<String> expectedNumberedBoard = Collections.singletonList(
118
+        List<String> expectedNumberedBoard = Collections.singletonList(
119 119
                 "1*2*1"
120 120
         );
121 121
 
122
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
122
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
123 123
 
124 124
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
125 125
     }
@@ -127,15 +127,15 @@ public class MinesweeperBoardTest {
127 127
     @Ignore("Remove to run test")
128 128
     @Test
129 129
     public void testInputBoardWithSingleRowAndTwoMinesAtEdges() {
130
-        final List<String> inputBoard = Collections.singletonList(
130
+        List<String> inputBoard = Collections.singletonList(
131 131
                 "*   *"
132 132
         );
133 133
 
134
-        final List<String> expectedNumberedBoard = Collections.singletonList(
134
+        List<String> expectedNumberedBoard = Collections.singletonList(
135 135
                 "*1 1*"
136 136
         );
137 137
 
138
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
138
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
139 139
 
140 140
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
141 141
     }
@@ -143,7 +143,7 @@ public class MinesweeperBoardTest {
143 143
     @Ignore("Remove to run test")
144 144
     @Test
145 145
     public void testInputBoardWithSingleColumnAndTwoMines() {
146
-        final List<String> inputBoard = Arrays.asList(
146
+        List<String> inputBoard = Arrays.asList(
147 147
                 " ",
148 148
                 "*",
149 149
                 " ",
@@ -151,7 +151,7 @@ public class MinesweeperBoardTest {
151 151
                 " "
152 152
         );
153 153
 
154
-        final List<String> expectedNumberedBoard = Arrays.asList(
154
+        List<String> expectedNumberedBoard = Arrays.asList(
155 155
                 "1",
156 156
                 "*",
157 157
                 "2",
@@ -159,7 +159,7 @@ public class MinesweeperBoardTest {
159 159
                 "1"
160 160
         );
161 161
 
162
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
162
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
163 163
 
164 164
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
165 165
     }
@@ -167,7 +167,7 @@ public class MinesweeperBoardTest {
167 167
     @Ignore("Remove to run test")
168 168
     @Test
169 169
     public void testInputBoardWithSingleColumnAndTwoMinesAtEdges() {
170
-        final List<String> inputBoard = Arrays.asList(
170
+        List<String> inputBoard = Arrays.asList(
171 171
                 "*",
172 172
                 " ",
173 173
                 " ",
@@ -175,7 +175,7 @@ public class MinesweeperBoardTest {
175 175
                 "*"
176 176
         );
177 177
 
178
-        final List<String> expectedNumberedBoard = Arrays.asList(
178
+        List<String> expectedNumberedBoard = Arrays.asList(
179 179
                 "*",
180 180
                 "1",
181 181
                 " ",
@@ -183,7 +183,7 @@ public class MinesweeperBoardTest {
183 183
                 "*"
184 184
         );
185 185
 
186
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
186
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
187 187
 
188 188
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
189 189
     }
@@ -191,7 +191,7 @@ public class MinesweeperBoardTest {
191 191
     @Ignore("Remove to run test")
192 192
     @Test
193 193
     public void testInputBoardWithMinesInCross() {
194
-        final List<String> inputBoard = Arrays.asList(
194
+        List<String> inputBoard = Arrays.asList(
195 195
                 "  *  ",
196 196
                 "  *  ",
197 197
                 "*****",
@@ -199,7 +199,7 @@ public class MinesweeperBoardTest {
199 199
                 "  *  "
200 200
         );
201 201
 
202
-        final List<String> expectedNumberedBoard = Arrays.asList(
202
+        List<String> expectedNumberedBoard = Arrays.asList(
203 203
                 " 2*2 ",
204 204
                 "25*52",
205 205
                 "*****",
@@ -207,7 +207,7 @@ public class MinesweeperBoardTest {
207 207
                 " 2*2 "
208 208
         );
209 209
 
210
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
210
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
211 211
 
212 212
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
213 213
     }
@@ -215,7 +215,7 @@ public class MinesweeperBoardTest {
215 215
     @Ignore("Remove to run test")
216 216
     @Test
217 217
     public void testLargeInputBoard() {
218
-        final List<String> inputBoard = Arrays.asList(
218
+        List<String> inputBoard = Arrays.asList(
219 219
                 " *  * ",
220 220
                 "  *   ",
221 221
                 "    * ",
@@ -224,7 +224,7 @@ public class MinesweeperBoardTest {
224 224
                 "      "
225 225
         );
226 226
 
227
-        final List<String> expectedNumberedBoard = Arrays.asList(
227
+        List<String> expectedNumberedBoard = Arrays.asList(
228 228
                 "1*22*1",
229 229
                 "12*322",
230 230
                 " 123*2",
@@ -233,7 +233,7 @@ public class MinesweeperBoardTest {
233 233
                 "111111"
234 234
         );
235 235
 
236
-        final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
236
+        List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
237 237
 
238 238
         assertEquals(expectedNumberedBoard, actualNumberedBoard);
239 239
     }