From 0b7330006b720ec48a7f83d52df7c9ac41ebc1f7 Mon Sep 17 00:00:00 2001 From: Sander Ploegsma Date: Sat, 30 Mar 2024 22:39:29 +0100 Subject: [PATCH] tournament: Sync tests --- .../practice/tournament/.meta/config.json | 1 + .../practice/tournament/.meta/tests.toml | 16 +- .../src/test/java/TournamentTest.java | 148 ++++++++++-------- 3 files changed, 97 insertions(+), 68 deletions(-) diff --git a/exercises/practice/tournament/.meta/config.json b/exercises/practice/tournament/.meta/config.json index 1e44c0f9e..906c49eeb 100644 --- a/exercises/practice/tournament/.meta/config.json +++ b/exercises/practice/tournament/.meta/config.json @@ -12,6 +12,7 @@ "mirkoperillo", "msomji", "muzimuzhi", + "sanderploegsma", "SleeplessByte", "sshine", "stkent" diff --git a/exercises/practice/tournament/.meta/tests.toml b/exercises/practice/tournament/.meta/tests.toml index 598677086..0e33c87fc 100644 --- a/exercises/practice/tournament/.meta/tests.toml +++ b/exercises/practice/tournament/.meta/tests.toml @@ -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" @@ -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" diff --git a/exercises/practice/tournament/src/test/java/TournamentTest.java b/exercises/practice/tournament/src/test/java/TournamentTest.java index 872847516..51da4460f 100644 --- a/exercises/practice/tournament/src/test/java/TournamentTest.java +++ b/exercises/practice/tournament/src/test/java/TournamentTest.java @@ -15,7 +15,8 @@ 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") @@ -23,10 +24,10 @@ public void justTheHeaderIfNoInput() { 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") @@ -34,10 +35,10 @@ public void aWinIsThreePointsALossIsZeroPoints() { 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") @@ -45,10 +46,10 @@ public void aWinCanAlsoBeExpressedAsALoss() { 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") @@ -56,10 +57,10 @@ public void aDifferentTeamCanWin() { 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") @@ -67,12 +68,12 @@ public void aDrawIsOnePointEach() { 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") @@ -80,12 +81,12 @@ public void thereCanBeMoreThanOneMatch() { 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") @@ -93,14 +94,14 @@ public void thereCanBeMoreThanOneWinner() { 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") @@ -108,18 +109,18 @@ public void thereCanBeMoreThanTwoTeams() { 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") @@ -127,16 +128,16 @@ public void typicalInput() { 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") @@ -144,17 +145,34 @@ public void incompleteCompetition() { 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" + ); } }