Skip to content

Commit 7bd8659

Browse files
committed
bottle-song, bowling, change
1 parent 301df04 commit 7bd8659

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

exercises/practice/bottle-song/src/test/java/BottleSongTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import org.junit.jupiter.api.Test;
22
import org.junit.jupiter.api.Disabled;
3+
import org.junit.jupiter.api.DisplayName;
34
import org.junit.jupiter.api.BeforeEach;
45

56
import static org.assertj.core.api.Assertions.assertThat;
@@ -14,6 +15,7 @@ public void setup() {
1415
}
1516

1617
@Test
18+
@DisplayName("first generic verse")
1719
public void firstGenericVerse() {
1820
assertThat(bottleSong.recite(10, 1)).isEqualTo(
1921
"Ten green bottles hanging on the wall,\n" +
@@ -25,6 +27,7 @@ public void firstGenericVerse() {
2527

2628
@Disabled("Remove to run test")
2729
@Test
30+
@DisplayName("last generic verse")
2831
public void lastGenericVerse() {
2932
assertThat(bottleSong.recite(3, 1)).isEqualTo(
3033
"Three green bottles hanging on the wall,\n" +
@@ -36,6 +39,7 @@ public void lastGenericVerse() {
3639

3740
@Disabled("Remove to run test")
3841
@Test
42+
@DisplayName("verse with 2 bottles")
3943
public void verseWithTwoBottles() {
4044
assertThat(bottleSong.recite(2, 1)).isEqualTo(
4145
"Two green bottles hanging on the wall,\n" +
@@ -47,6 +51,7 @@ public void verseWithTwoBottles() {
4751

4852
@Disabled("Remove to run test")
4953
@Test
54+
@DisplayName("verse with 1 bottle")
5055
public void verseWithOneBottle() {
5156
assertThat(bottleSong.recite(1, 1)).isEqualTo(
5257
"One green bottle hanging on the wall,\n" +
@@ -58,6 +63,7 @@ public void verseWithOneBottle() {
5863

5964
@Disabled("Remove to run test")
6065
@Test
66+
@DisplayName("first two verses")
6167
public void firstTwoVerses() {
6268
assertThat(bottleSong.recite(10, 2)).isEqualTo(
6369
"Ten green bottles hanging on the wall,\n" +
@@ -74,6 +80,7 @@ public void firstTwoVerses() {
7480

7581
@Disabled("Remove to run test")
7682
@Test
83+
@DisplayName("last three verses")
7784
public void lastThreeVerses() {
7885
assertThat(bottleSong.recite(3, 3)).isEqualTo(
7986
"Three green bottles hanging on the wall,\n" +
@@ -95,6 +102,7 @@ public void lastThreeVerses() {
95102

96103
@Disabled("Remove to run test")
97104
@Test
105+
@DisplayName("all verses")
98106
public void allVerses() {
99107
assertThat(bottleSong.recite(10, 10))
100108
.isEqualTo(

exercises/practice/bowling/src/test/java/BowlingGameTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.DisplayName;
23
import org.junit.jupiter.api.Test;
34

45
import static org.assertj.core.api.Assertions.assertThat;
@@ -14,6 +15,7 @@ private void playGame(int[] rolls) {
1415
}
1516

1617
@Test
18+
@DisplayName("should be able to score a game with all zeros")
1719
public void shouldBeAbleToScoreAGameWithAllZeros() {
1820
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1921

@@ -23,6 +25,7 @@ public void shouldBeAbleToScoreAGameWithAllZeros() {
2325

2426
@Disabled("Remove to run test")
2527
@Test
28+
@DisplayName("should be able to score a game with no strikes or spares")
2629
public void shouldBeAbleToScoreAGameWithNoStrikesOrSpares() {
2730
int[] rolls = {3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6};
2831

@@ -32,6 +35,7 @@ public void shouldBeAbleToScoreAGameWithNoStrikesOrSpares() {
3235

3336
@Disabled("Remove to run test")
3437
@Test
38+
@DisplayName("a spare followed by zeros is worth ten points")
3539
public void aSpareFollowedByZerosIsWorthTenPoints() {
3640
int[] rolls = {6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
3741

@@ -41,6 +45,7 @@ public void aSpareFollowedByZerosIsWorthTenPoints() {
4145

4246
@Disabled("Remove to run test")
4347
@Test
48+
@DisplayName("points scored in the roll after a spare are counted twice")
4449
public void pointsScoredInTheRollAfterASpareAreCountedTwice() {
4550
int[] rolls = {6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
4651

@@ -50,6 +55,7 @@ public void pointsScoredInTheRollAfterASpareAreCountedTwice() {
5055

5156
@Disabled("Remove to run test")
5257
@Test
58+
@DisplayName("consecutive spares each get a one roll bonus")
5359
public void consecutiveSparesEachGetAOneRollBonus() {
5460
int[] rolls = {5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
5561

@@ -59,6 +65,7 @@ public void consecutiveSparesEachGetAOneRollBonus() {
5965

6066
@Disabled("Remove to run test")
6167
@Test
68+
@DisplayName("a spare in the last frame gets a one roll bonus that is counted once")
6269
public void aSpareInTheLastFrameGetsAOneRollBonusThatIsCountedOnce() {
6370
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7};
6471

@@ -68,6 +75,7 @@ public void aSpareInTheLastFrameGetsAOneRollBonusThatIsCountedOnce() {
6875

6976
@Disabled("Remove to run test")
7077
@Test
78+
@DisplayName("a strike earns ten points in a frame with a single roll")
7179
public void aStrikeEarnsTenPointsInFrameWithASingleRoll() {
7280
int[] rolls = {10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
7381

@@ -77,6 +85,7 @@ public void aStrikeEarnsTenPointsInFrameWithASingleRoll() {
7785

7886
@Disabled("Remove to run test")
7987
@Test
88+
@DisplayName("points scored in the two rolls after a strike are counted twice as a bonus")
8089
public void pointsScoredInTheTwoRollsAfterAStrikeAreCountedTwiceAsABonus() {
8190
int[] rolls = {10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
8291

@@ -86,6 +95,7 @@ public void pointsScoredInTheTwoRollsAfterAStrikeAreCountedTwiceAsABonus() {
8695

8796
@Disabled("Remove to run test")
8897
@Test
98+
@DisplayName("consecutive strikes each get the two roll bonus")
8999
public void consecutiveStrikesEachGetTheTwoRollBonus() {
90100
int[] rolls = {10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
91101

@@ -95,6 +105,7 @@ public void consecutiveStrikesEachGetTheTwoRollBonus() {
95105

96106
@Disabled("Remove to run test")
97107
@Test
108+
@DisplayName("a strike in the last frame gets a two roll bonus that is counted once")
98109
public void aStrikeInTheLastFrameGetsATwoRollBonusThatIsCountedOnce() {
99110
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1};
100111

@@ -104,6 +115,7 @@ public void aStrikeInTheLastFrameGetsATwoRollBonusThatIsCountedOnce() {
104115

105116
@Disabled("Remove to run test")
106117
@Test
118+
@DisplayName("rolling a spare with the two roll bonus does not get a bonus roll")
107119
public void rollingASpareWithTheTwoRollBonusDoesNotGetABonusRoll() {
108120
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3};
109121

@@ -113,6 +125,7 @@ public void rollingASpareWithTheTwoRollBonusDoesNotGetABonusRoll() {
113125

114126
@Disabled("Remove to run test")
115127
@Test
128+
@DisplayName("strikes with the two roll bonus do not get bonus rolls")
116129
public void strikesWithTheTwoRollBonusDoNotGetBonusRolls() {
117130
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10};
118131

@@ -122,6 +135,7 @@ public void strikesWithTheTwoRollBonusDoNotGetBonusRolls() {
122135

123136
@Disabled("Remove to run test")
124137
@Test
138+
@DisplayName("last two strikes followed by only last bonus with non strike points")
125139
public void lastTwoStrikesFollowedByOnlyLastBonusWithNonStrikePoints() {
126140
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 0, 1};
127141

@@ -131,6 +145,7 @@ public void lastTwoStrikesFollowedByOnlyLastBonusWithNonStrikePoints() {
131145

132146
@Disabled("Remove to run test")
133147
@Test
148+
@DisplayName("a strike with the one roll bonus after a spare in the last frame does not get a bonus")
134149
public void aStrikeWithTheOneRollBonusAfterASpareInTheLastFrameDoesNotGetABonus() {
135150
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10};
136151

@@ -140,6 +155,7 @@ public void aStrikeWithTheOneRollBonusAfterASpareInTheLastFrameDoesNotGetABonus(
140155

141156
@Disabled("Remove to run test")
142157
@Test
158+
@DisplayName("all strikes is a perfect game")
143159
public void allStrikesIsAPerfectGame() {
144160
int[] rolls = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
145161

@@ -149,6 +165,7 @@ public void allStrikesIsAPerfectGame() {
149165

150166
@Disabled("Remove to run test")
151167
@Test
168+
@DisplayName("rolls cannot score negative points")
152169
public void rollsCanNotScoreNegativePoints() {
153170
int[] rolls = {-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
154171

@@ -159,6 +176,7 @@ public void rollsCanNotScoreNegativePoints() {
159176

160177
@Disabled("Remove to run test")
161178
@Test
179+
@DisplayName("a roll cannot score more than 10 points")
162180
public void aRollCanNotScoreMoreThan10Points() {
163181
int[] rolls = {11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
164182

@@ -169,6 +187,7 @@ public void aRollCanNotScoreMoreThan10Points() {
169187

170188
@Disabled("Remove to run test")
171189
@Test
190+
@DisplayName("two rolls in a frame cannot score more than 10 points")
172191
public void twoRollsInAFrameCanNotScoreMoreThan10Points() {
173192
int[] rolls = {5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
174193

@@ -179,6 +198,7 @@ public void twoRollsInAFrameCanNotScoreMoreThan10Points() {
179198

180199
@Disabled("Remove to run test")
181200
@Test
201+
@DisplayName("bonus roll after a strike in the last frame cannot score more than 10 points")
182202
public void bonusRollAfterAStrikeInTheLastFrameCanNotScoreMoreThan10Points() {
183203
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 0};
184204

@@ -189,6 +209,7 @@ public void bonusRollAfterAStrikeInTheLastFrameCanNotScoreMoreThan10Points() {
189209

190210
@Disabled("Remove to run test")
191211
@Test
212+
@DisplayName("two bonus rolls after a strike in the last frame cannot score more than 10 points")
192213
public void twoBonusRollsAfterAStrikeInTheLastFrameCanNotScoreMoreThan10Points() {
193214
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5, 6};
194215

@@ -199,6 +220,7 @@ public void twoBonusRollsAfterAStrikeInTheLastFrameCanNotScoreMoreThan10Points()
199220

200221
@Disabled("Remove to run test")
201222
@Test
223+
@DisplayName("two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike")
202224
public void twoBonusRollsAfterAStrikeInTheLastFrameCanScoreMoreThan10PointsIfOneIsAStrike() {
203225
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6};
204226

@@ -209,6 +231,7 @@ public void twoBonusRollsAfterAStrikeInTheLastFrameCanScoreMoreThan10PointsIfOne
209231

210232
@Disabled("Remove to run test")
211233
@Test
234+
@DisplayName("the second bonus rolls after a strike in the last frame cannot be a strike if the first one is not a strike")
212235
public void theSecondBonusRollsAfterAStrikeInTheLastFrameCanNotBeAStrikeIfTheFirstOneIsNotAStrike() {
213236
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6, 10};
214237

@@ -219,6 +242,7 @@ public void theSecondBonusRollsAfterAStrikeInTheLastFrameCanNotBeAStrikeIfTheFir
219242

220243
@Disabled("Remove to run test")
221244
@Test
245+
@DisplayName("second bonus roll after a strike in the last frame cannot score more than 10 points")
222246
public void secondBonusRollAfterAStrikeInTheLastFrameCanNotScoreMoreThan10Points() {
223247
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 11};
224248

@@ -229,6 +253,7 @@ public void secondBonusRollAfterAStrikeInTheLastFrameCanNotScoreMoreThan10Points
229253

230254
@Disabled("Remove to run test")
231255
@Test
256+
@DisplayName("an unstarted game cannot be scored")
232257
public void anUnstartedGameCanNotBeScored() {
233258
int[] rolls = new int[0];
234259

@@ -241,6 +266,7 @@ public void anUnstartedGameCanNotBeScored() {
241266

242267
@Disabled("Remove to run test")
243268
@Test
269+
@DisplayName("an incomplete game cannot be scored")
244270
public void anIncompleteGameCanNotBeScored() {
245271
int[] rolls = {0, 0};
246272

@@ -253,6 +279,7 @@ public void anIncompleteGameCanNotBeScored() {
253279

254280
@Disabled("Remove to run test")
255281
@Test
282+
@DisplayName("cannot roll if game already has ten frames")
256283
public void canNotRollIfGameAlreadyHasTenFrames() {
257284
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
258285

@@ -263,6 +290,7 @@ public void canNotRollIfGameAlreadyHasTenFrames() {
263290

264291
@Disabled("Remove to run test")
265292
@Test
293+
@DisplayName("bonus rolls for a strike in the last frame must be rolled before score can be calculated")
266294
public void bonusRollsForAStrikeInTheLastFrameMustBeRolledBeforeScoreCanBeCalculated() {
267295
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10};
268296

@@ -275,6 +303,7 @@ public void bonusRollsForAStrikeInTheLastFrameMustBeRolledBeforeScoreCanBeCalcul
275303

276304
@Disabled("Remove to run test")
277305
@Test
306+
@DisplayName("both bonus rolls for a strike in the last frame must be rolled before score can be calculated")
278307
public void bothBonusRollsForAStrikeInTheLastFrameMustBeRolledBeforeScoreCanBeCalculated() {
279308
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10};
280309

@@ -287,6 +316,7 @@ public void bothBonusRollsForAStrikeInTheLastFrameMustBeRolledBeforeScoreCanBeCa
287316

288317
@Disabled("Remove to run test")
289318
@Test
319+
@DisplayName("bonus roll for a spare in the last frame must be rolled before score can be calculated")
290320
public void bonusRollForASpareInTheLastFrameMustBeRolledBeforeScoreCanBeCalculated() {
291321
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3};
292322

@@ -299,6 +329,7 @@ public void bonusRollForASpareInTheLastFrameMustBeRolledBeforeScoreCanBeCalculat
299329

300330
@Disabled("Remove to run test")
301331
@Test
332+
@DisplayName("cannot roll after bonus roll for spare")
302333
public void canNotRollAfterBonusRollForSpare() {
303334
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 2, 2};
304335

@@ -309,6 +340,7 @@ public void canNotRollAfterBonusRollForSpare() {
309340

310341
@Disabled("Remove to run test")
311342
@Test
343+
@DisplayName("cannot roll after bonus rolls for strike")
312344
public void canNotRollAfterBonusRollForStrike() {
313345
int[] rolls = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 3, 2, 2};
314346

0 commit comments

Comments
 (0)