Skip to content

Commit

Permalink
tournament: Sync tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderploegsma committed Mar 30, 2024
1 parent b80848f commit 0b73300
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 68 deletions.
1 change: 1 addition & 0 deletions exercises/practice/tournament/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"mirkoperillo",
"msomji",
"muzimuzhi",
"sanderploegsma",
"SleeplessByte",
"sshine",
"stkent"
Expand Down
16 changes: 13 additions & 3 deletions exercises/practice/tournament/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

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

[3aa0386f-150b-4f99-90bb-5195e7b7d3b8]
description = "ties broken alphabetically"

[f9e20931-8a65-442a-81f6-503c0205b17a]
description = "ensure points sorted numerically"
148 changes: 83 additions & 65 deletions exercises/practice/tournament/src/test/java/TournamentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,146 +15,164 @@ public void setUp() {

@Test
public void justTheHeaderIfNoInput() {
assertThat(tournament.printTable()).isEqualTo("Team | MP | W | D | L | P\n");
assertThat(tournament.printTable())
.isEqualTo("Team | MP | W | D | L | P\n");
}

@Disabled("Remove to run test")
@Test
public void aWinIsThreePointsALossIsZeroPoints() {
tournament.applyResults("Allegoric Alaskans;Blithering Badgers;win");
assertThat(tournament.printTable())
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" +
"Blithering Badgers | 1 | 0 | 0 | 1 | 0\n");
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" +
"Blithering Badgers | 1 | 0 | 0 | 1 | 0\n");
}

@Disabled("Remove to run test")
@Test
public void aWinCanAlsoBeExpressedAsALoss() {
tournament.applyResults("Blithering Badgers;Allegoric Alaskans;loss");
assertThat(tournament.printTable())
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" +
"Blithering Badgers | 1 | 0 | 0 | 1 | 0\n");
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" +
"Blithering Badgers | 1 | 0 | 0 | 1 | 0\n");
}

@Disabled("Remove to run test")
@Test
public void aDifferentTeamCanWin() {
tournament.applyResults("Blithering Badgers;Allegoric Alaskans;win");
assertThat(tournament.printTable())
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Blithering Badgers | 1 | 1 | 0 | 0 | 3\n" +
"Allegoric Alaskans | 1 | 0 | 0 | 1 | 0\n");
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Blithering Badgers | 1 | 1 | 0 | 0 | 3\n" +
"Allegoric Alaskans | 1 | 0 | 0 | 1 | 0\n");
}

@Disabled("Remove to run test")
@Test
public void aDrawIsOnePointEach() {
tournament.applyResults("Allegoric Alaskans;Blithering Badgers;draw");
assertThat(tournament.printTable())
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 1 | 0 | 1 | 0 | 1\n" +
"Blithering Badgers | 1 | 0 | 1 | 0 | 1\n");
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 1 | 0 | 1 | 0 | 1\n" +
"Blithering Badgers | 1 | 0 | 1 | 0 | 1\n");
}

@Disabled("Remove to run test")
@Test
public void thereCanBeMoreThanOneMatch() {
tournament.applyResults(
"Allegoric Alaskans;Blithering Badgers;win\n" +
"Allegoric Alaskans;Blithering Badgers;win");
"Allegoric Alaskans;Blithering Badgers;win");
assertThat(tournament.printTable())
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" +
"Blithering Badgers | 2 | 0 | 0 | 2 | 0\n");
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" +
"Blithering Badgers | 2 | 0 | 0 | 2 | 0\n");
}

@Disabled("Remove to run test")
@Test
public void thereCanBeMoreThanOneWinner() {
tournament.applyResults(
"Allegoric Alaskans;Blithering Badgers;loss\n" +
"Allegoric Alaskans;Blithering Badgers;win");
"Allegoric Alaskans;Blithering Badgers;win");
assertThat(tournament.printTable())
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 2 | 1 | 0 | 1 | 3\n" +
"Blithering Badgers | 2 | 1 | 0 | 1 | 3\n");
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 2 | 1 | 0 | 1 | 3\n" +
"Blithering Badgers | 2 | 1 | 0 | 1 | 3\n");
}

@Disabled("Remove to run test")
@Test
public void thereCanBeMoreThanTwoTeams() {
tournament.applyResults(
"Allegoric Alaskans;Blithering Badgers;win\n" +
"Blithering Badgers;Courageous Californians;win\n" +
"Courageous Californians;Allegoric Alaskans;loss");
"Blithering Badgers;Courageous Californians;win\n" +
"Courageous Californians;Allegoric Alaskans;loss");
assertThat(tournament.printTable())
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" +
"Blithering Badgers | 2 | 1 | 0 | 1 | 3\n" +
"Courageous Californians | 2 | 0 | 0 | 2 | 0\n");
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" +
"Blithering Badgers | 2 | 1 | 0 | 1 | 3\n" +
"Courageous Californians | 2 | 0 | 0 | 2 | 0\n");
}

@Disabled("Remove to run test")
@Test
public void typicalInput() {
tournament.applyResults(
"Allegoric Alaskans;Blithering Badgers;win\n" +
"Devastating Donkeys;Courageous Californians;draw\n" +
"Devastating Donkeys;Allegoric Alaskans;win\n" +
"Courageous Californians;Blithering Badgers;loss\n" +
"Blithering Badgers;Devastating Donkeys;loss\n" +
"Allegoric Alaskans;Courageous Californians;win");
"Devastating Donkeys;Courageous Californians;draw\n" +
"Devastating Donkeys;Allegoric Alaskans;win\n" +
"Courageous Californians;Blithering Badgers;loss\n" +
"Blithering Badgers;Devastating Donkeys;loss\n" +
"Allegoric Alaskans;Courageous Californians;win");
assertThat(tournament.printTable())
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Devastating Donkeys | 3 | 2 | 1 | 0 | 7\n" +
"Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" +
"Blithering Badgers | 3 | 1 | 0 | 2 | 3\n" +
"Courageous Californians | 3 | 0 | 1 | 2 | 1\n");
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Devastating Donkeys | 3 | 2 | 1 | 0 | 7\n" +
"Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" +
"Blithering Badgers | 3 | 1 | 0 | 2 | 3\n" +
"Courageous Californians | 3 | 0 | 1 | 2 | 1\n");
}

@Disabled("Remove to run test")
@Test
public void incompleteCompetition() {
tournament.applyResults(
"Allegoric Alaskans;Blithering Badgers;loss\n" +
"Devastating Donkeys;Allegoric Alaskans;loss\n" +
"Courageous Californians;Blithering Badgers;draw\n" +
"Allegoric Alaskans;Courageous Californians;win");
"Devastating Donkeys;Allegoric Alaskans;loss\n" +
"Courageous Californians;Blithering Badgers;draw\n" +
"Allegoric Alaskans;Courageous Californians;win");
assertThat(tournament.printTable())
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" +
"Blithering Badgers | 2 | 1 | 1 | 0 | 4\n" +
"Courageous Californians | 2 | 0 | 1 | 1 | 1\n" +
"Devastating Donkeys | 1 | 0 | 0 | 1 | 0\n");
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" +
"Blithering Badgers | 2 | 1 | 1 | 0 | 4\n" +
"Courageous Californians | 2 | 0 | 1 | 1 | 1\n" +
"Devastating Donkeys | 1 | 0 | 0 | 1 | 0\n");
}

@Disabled("Remove to run test")
@Test
public void tiesBrokenAlphabetically() {
tournament.applyResults(
"Courageous Californians;Devastating Donkeys;win\n" +
"Allegoric Alaskans;Blithering Badgers;win\n" +
"Devastating Donkeys;Allegoric Alaskans;loss\n" +
"Courageous Californians;Blithering Badgers;win\n" +
"Blithering Badgers;Devastating Donkeys;draw\n" +
"Allegoric Alaskans;Courageous Californians;draw");
"Allegoric Alaskans;Blithering Badgers;win\n" +
"Devastating Donkeys;Allegoric Alaskans;loss\n" +
"Courageous Californians;Blithering Badgers;win\n" +
"Blithering Badgers;Devastating Donkeys;draw\n" +
"Allegoric Alaskans;Courageous Californians;draw");
assertThat(tournament.printTable())
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 3 | 2 | 1 | 0 | 7\n" +
"Courageous Californians | 3 | 2 | 1 | 0 | 7\n" +
"Blithering Badgers | 3 | 0 | 1 | 2 | 1\n" +
"Devastating Donkeys | 3 | 0 | 1 | 2 | 1\n");
}

@Disabled("Remove to run test")
@Test
public void pointsSortedNumerically() {
tournament.applyResults(
"Devastating Donkeys;Blithering Badgers;win\n" +
"Devastating Donkeys;Blithering Badgers;win\n" +
"Devastating Donkeys;Blithering Badgers;win\n" +
"Devastating Donkeys;Blithering Badgers;win\n" +
"Blithering Badgers;Devastating Donkeys;win");
assertThat(tournament.printTable())
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Allegoric Alaskans | 3 | 2 | 1 | 0 | 7\n" +
"Courageous Californians | 3 | 2 | 1 | 0 | 7\n" +
"Blithering Badgers | 3 | 0 | 1 | 2 | 1\n" +
"Devastating Donkeys | 3 | 0 | 1 | 2 | 1\n");
.isEqualTo(
"Team | MP | W | D | L | P\n" +
"Devastating Donkeys | 5 | 4 | 0 | 1 | 12\n" +
"Blithering Badgers | 5 | 1 | 0 | 4 | 3\n"
);
}
}

0 comments on commit 0b73300

Please sign in to comment.