Skip to content

Commit 1ad0518

Browse files
tournament: Sync tests
1 parent b80848f commit 1ad0518

File tree

3 files changed

+96
-68
lines changed

3 files changed

+96
-68
lines changed

exercises/practice/tournament/.meta/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"mirkoperillo",
1313
"msomji",
1414
"muzimuzhi",
15+
"sanderploegsma",
1516
"SleeplessByte",
1617
"sshine",
1718
"stkent"

exercises/practice/tournament/.meta/tests.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[67e9fab1-07c1-49cf-9159-bc8671cc7c9c]
613
description = "just the header if no input"
@@ -34,3 +41,6 @@ description = "incomplete competition (not all pairs have played)"
3441

3542
[3aa0386f-150b-4f99-90bb-5195e7b7d3b8]
3643
description = "ties broken alphabetically"
44+
45+
[f9e20931-8a65-442a-81f6-503c0205b17a]
46+
description = "ensure points sorted numerically"

exercises/practice/tournament/src/test/java/TournamentTest.java

Lines changed: 82 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -15,146 +15,163 @@ public void setUp() {
1515

1616
@Test
1717
public void justTheHeaderIfNoInput() {
18-
assertThat(tournament.printTable()).isEqualTo("Team | MP | W | D | L | P\n");
18+
assertThat(tournament.printTable())
19+
.isEqualTo("Team | MP | W | D | L | P\n");
1920
}
2021

2122
@Disabled("Remove to run test")
2223
@Test
2324
public void aWinIsThreePointsALossIsZeroPoints() {
2425
tournament.applyResults("Allegoric Alaskans;Blithering Badgers;win");
2526
assertThat(tournament.printTable())
26-
.isEqualTo(
27-
"Team | MP | W | D | L | P\n" +
28-
"Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" +
29-
"Blithering Badgers | 1 | 0 | 0 | 1 | 0\n");
27+
.isEqualTo(
28+
"Team | MP | W | D | L | P\n" +
29+
"Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" +
30+
"Blithering Badgers | 1 | 0 | 0 | 1 | 0\n");
3031
}
3132

3233
@Disabled("Remove to run test")
3334
@Test
3435
public void aWinCanAlsoBeExpressedAsALoss() {
3536
tournament.applyResults("Blithering Badgers;Allegoric Alaskans;loss");
3637
assertThat(tournament.printTable())
37-
.isEqualTo(
38-
"Team | MP | W | D | L | P\n" +
39-
"Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" +
40-
"Blithering Badgers | 1 | 0 | 0 | 1 | 0\n");
38+
.isEqualTo(
39+
"Team | MP | W | D | L | P\n" +
40+
"Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" +
41+
"Blithering Badgers | 1 | 0 | 0 | 1 | 0\n");
4142
}
4243

4344
@Disabled("Remove to run test")
4445
@Test
4546
public void aDifferentTeamCanWin() {
4647
tournament.applyResults("Blithering Badgers;Allegoric Alaskans;win");
4748
assertThat(tournament.printTable())
48-
.isEqualTo(
49-
"Team | MP | W | D | L | P\n" +
50-
"Blithering Badgers | 1 | 1 | 0 | 0 | 3\n" +
51-
"Allegoric Alaskans | 1 | 0 | 0 | 1 | 0\n");
49+
.isEqualTo(
50+
"Team | MP | W | D | L | P\n" +
51+
"Blithering Badgers | 1 | 1 | 0 | 0 | 3\n" +
52+
"Allegoric Alaskans | 1 | 0 | 0 | 1 | 0\n");
5253
}
5354

5455
@Disabled("Remove to run test")
5556
@Test
5657
public void aDrawIsOnePointEach() {
5758
tournament.applyResults("Allegoric Alaskans;Blithering Badgers;draw");
5859
assertThat(tournament.printTable())
59-
.isEqualTo(
60-
"Team | MP | W | D | L | P\n" +
61-
"Allegoric Alaskans | 1 | 0 | 1 | 0 | 1\n" +
62-
"Blithering Badgers | 1 | 0 | 1 | 0 | 1\n");
60+
.isEqualTo(
61+
"Team | MP | W | D | L | P\n" +
62+
"Allegoric Alaskans | 1 | 0 | 1 | 0 | 1\n" +
63+
"Blithering Badgers | 1 | 0 | 1 | 0 | 1\n");
6364
}
6465

6566
@Disabled("Remove to run test")
6667
@Test
6768
public void thereCanBeMoreThanOneMatch() {
6869
tournament.applyResults(
6970
"Allegoric Alaskans;Blithering Badgers;win\n" +
70-
"Allegoric Alaskans;Blithering Badgers;win");
71+
"Allegoric Alaskans;Blithering Badgers;win");
7172
assertThat(tournament.printTable())
72-
.isEqualTo(
73-
"Team | MP | W | D | L | P\n" +
74-
"Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" +
75-
"Blithering Badgers | 2 | 0 | 0 | 2 | 0\n");
73+
.isEqualTo(
74+
"Team | MP | W | D | L | P\n" +
75+
"Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" +
76+
"Blithering Badgers | 2 | 0 | 0 | 2 | 0\n");
7677
}
7778

7879
@Disabled("Remove to run test")
7980
@Test
8081
public void thereCanBeMoreThanOneWinner() {
8182
tournament.applyResults(
8283
"Allegoric Alaskans;Blithering Badgers;loss\n" +
83-
"Allegoric Alaskans;Blithering Badgers;win");
84+
"Allegoric Alaskans;Blithering Badgers;win");
8485
assertThat(tournament.printTable())
85-
.isEqualTo(
86-
"Team | MP | W | D | L | P\n" +
87-
"Allegoric Alaskans | 2 | 1 | 0 | 1 | 3\n" +
88-
"Blithering Badgers | 2 | 1 | 0 | 1 | 3\n");
86+
.isEqualTo(
87+
"Team | MP | W | D | L | P\n" +
88+
"Allegoric Alaskans | 2 | 1 | 0 | 1 | 3\n" +
89+
"Blithering Badgers | 2 | 1 | 0 | 1 | 3\n");
8990
}
9091

9192
@Disabled("Remove to run test")
9293
@Test
9394
public void thereCanBeMoreThanTwoTeams() {
9495
tournament.applyResults(
9596
"Allegoric Alaskans;Blithering Badgers;win\n" +
96-
"Blithering Badgers;Courageous Californians;win\n" +
97-
"Courageous Californians;Allegoric Alaskans;loss");
97+
"Blithering Badgers;Courageous Californians;win\n" +
98+
"Courageous Californians;Allegoric Alaskans;loss");
9899
assertThat(tournament.printTable())
99-
.isEqualTo(
100-
"Team | MP | W | D | L | P\n" +
101-
"Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" +
102-
"Blithering Badgers | 2 | 1 | 0 | 1 | 3\n" +
103-
"Courageous Californians | 2 | 0 | 0 | 2 | 0\n");
100+
.isEqualTo(
101+
"Team | MP | W | D | L | P\n" +
102+
"Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" +
103+
"Blithering Badgers | 2 | 1 | 0 | 1 | 3\n" +
104+
"Courageous Californians | 2 | 0 | 0 | 2 | 0\n");
104105
}
105106

106107
@Disabled("Remove to run test")
107108
@Test
108109
public void typicalInput() {
109110
tournament.applyResults(
110111
"Allegoric Alaskans;Blithering Badgers;win\n" +
111-
"Devastating Donkeys;Courageous Californians;draw\n" +
112-
"Devastating Donkeys;Allegoric Alaskans;win\n" +
113-
"Courageous Californians;Blithering Badgers;loss\n" +
114-
"Blithering Badgers;Devastating Donkeys;loss\n" +
115-
"Allegoric Alaskans;Courageous Californians;win");
112+
"Devastating Donkeys;Courageous Californians;draw\n" +
113+
"Devastating Donkeys;Allegoric Alaskans;win\n" +
114+
"Courageous Californians;Blithering Badgers;loss\n" +
115+
"Blithering Badgers;Devastating Donkeys;loss\n" +
116+
"Allegoric Alaskans;Courageous Californians;win");
116117
assertThat(tournament.printTable())
117-
.isEqualTo(
118-
"Team | MP | W | D | L | P\n" +
119-
"Devastating Donkeys | 3 | 2 | 1 | 0 | 7\n" +
120-
"Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" +
121-
"Blithering Badgers | 3 | 1 | 0 | 2 | 3\n" +
122-
"Courageous Californians | 3 | 0 | 1 | 2 | 1\n");
118+
.isEqualTo(
119+
"Team | MP | W | D | L | P\n" +
120+
"Devastating Donkeys | 3 | 2 | 1 | 0 | 7\n" +
121+
"Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" +
122+
"Blithering Badgers | 3 | 1 | 0 | 2 | 3\n" +
123+
"Courageous Californians | 3 | 0 | 1 | 2 | 1\n");
123124
}
124125

125126
@Disabled("Remove to run test")
126127
@Test
127128
public void incompleteCompetition() {
128129
tournament.applyResults(
129130
"Allegoric Alaskans;Blithering Badgers;loss\n" +
130-
"Devastating Donkeys;Allegoric Alaskans;loss\n" +
131-
"Courageous Californians;Blithering Badgers;draw\n" +
132-
"Allegoric Alaskans;Courageous Californians;win");
131+
"Devastating Donkeys;Allegoric Alaskans;loss\n" +
132+
"Courageous Californians;Blithering Badgers;draw\n" +
133+
"Allegoric Alaskans;Courageous Californians;win");
133134
assertThat(tournament.printTable())
134-
.isEqualTo(
135-
"Team | MP | W | D | L | P\n" +
136-
"Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" +
137-
"Blithering Badgers | 2 | 1 | 1 | 0 | 4\n" +
138-
"Courageous Californians | 2 | 0 | 1 | 1 | 1\n" +
139-
"Devastating Donkeys | 1 | 0 | 0 | 1 | 0\n");
135+
.isEqualTo(
136+
"Team | MP | W | D | L | P\n" +
137+
"Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" +
138+
"Blithering Badgers | 2 | 1 | 1 | 0 | 4\n" +
139+
"Courageous Californians | 2 | 0 | 1 | 1 | 1\n" +
140+
"Devastating Donkeys | 1 | 0 | 0 | 1 | 0\n");
140141
}
141142

142143
@Disabled("Remove to run test")
143144
@Test
144145
public void tiesBrokenAlphabetically() {
145146
tournament.applyResults(
146147
"Courageous Californians;Devastating Donkeys;win\n" +
147-
"Allegoric Alaskans;Blithering Badgers;win\n" +
148-
"Devastating Donkeys;Allegoric Alaskans;loss\n" +
149-
"Courageous Californians;Blithering Badgers;win\n" +
150-
"Blithering Badgers;Devastating Donkeys;draw\n" +
151-
"Allegoric Alaskans;Courageous Californians;draw");
148+
"Allegoric Alaskans;Blithering Badgers;win\n" +
149+
"Devastating Donkeys;Allegoric Alaskans;loss\n" +
150+
"Courageous Californians;Blithering Badgers;win\n" +
151+
"Blithering Badgers;Devastating Donkeys;draw\n" +
152+
"Allegoric Alaskans;Courageous Californians;draw");
153+
assertThat(tournament.printTable())
154+
.isEqualTo(
155+
"Team | MP | W | D | L | P\n" +
156+
"Allegoric Alaskans | 3 | 2 | 1 | 0 | 7\n" +
157+
"Courageous Californians | 3 | 2 | 1 | 0 | 7\n" +
158+
"Blithering Badgers | 3 | 0 | 1 | 2 | 1\n" +
159+
"Devastating Donkeys | 3 | 0 | 1 | 2 | 1\n");
160+
}
161+
162+
@Disabled("Remove to run test")
163+
@Test
164+
public void pointsSortedNumerically() {
165+
tournament.applyResults(
166+
"Devastating Donkeys;Blithering Badgers;win\n" +
167+
"Devastating Donkeys;Blithering Badgers;win\n" +
168+
"Devastating Donkeys;Blithering Badgers;win\n" +
169+
"Devastating Donkeys;Blithering Badgers;win\n" +
170+
"Blithering Badgers;Devastating Donkeys;win");
152171
assertThat(tournament.printTable())
153-
.isEqualTo(
154-
"Team | MP | W | D | L | P\n" +
155-
"Allegoric Alaskans | 3 | 2 | 1 | 0 | 7\n" +
156-
"Courageous Californians | 3 | 2 | 1 | 0 | 7\n" +
157-
"Blithering Badgers | 3 | 0 | 1 | 2 | 1\n" +
158-
"Devastating Donkeys | 3 | 0 | 1 | 2 | 1\n");
172+
.isEqualTo(
173+
"Team | MP | W | D | L | P\n" +
174+
"Devastating Donkeys | 5 | 4 | 0 | 1 | 12\n" +
175+
"Blithering Badgers | 5 | 1 | 0 | 4 | 3\n");
159176
}
160177
}

0 commit comments

Comments
 (0)