Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync tests for practice exercise word search #2628

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions exercises/practice/word-search/.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.

[b4057815-0d01-41f0-9119-6a91f54b2a0a]
description = "Should accept an initial game grid and a target search word"
Expand Down Expand Up @@ -61,3 +68,15 @@ description = "Should locate words written top right to bottom left"

[695531db-69eb-463f-8bad-8de3bf5ef198]
description = "Should fail to locate a word that is not in the puzzle"

[fda5b937-6774-4a52-8f89-f64ed833b175]
description = "Should fail to locate words that are not on horizontal, vertical, or diagonal lines"

[5b6198eb-2847-4e2f-8efe-65045df16bd3]
description = "Should not concatenate different lines to find a horizontal word"

[eba44139-a34f-4a92-98e1-bd5f259e5769]
description = "Should not wrap around horizontally to find a word"

[cd1f0fa8-76af-4167-b105-935f78364dac]
description = "Should not wrap around vertically to find a word"
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public void testLocatesDifferentWordWrittenLeftToRightInTenLineGrid() {
@Test
public void testShouldLocateMultipleWords() {
Map<String, Optional<WordLocation>> expectedLocations = new HashMap<>();
expectedLocations.put("fortran", Optional.of(new WordLocation(new Pair(1, 7), new Pair(7, 7))));
expectedLocations.put("fortran", Optional.of(new WordLocation(new Pair(1, 7), new Pair(7, 7))));
expectedLocations.put("clojure", Optional.of(new WordLocation(new Pair(1, 10), new Pair(7, 10))));

Set<String> searchWords = expectedLocations.keySet();
Expand Down Expand Up @@ -512,5 +512,82 @@ public void testFailsToLocateAWordsThatIsNotInThePuzzle() {

assertThat(actualLocations).isEqualTo(expectedLocations);
}

@Ignore("Remove to run test")
@Test
public void testFailToLocateWordsThatAreNotOnHorizontalVerticalOrDiagonalLines() {
Map<String, Optional<WordLocation>> expectedLocations = new HashMap<>();
expectedLocations.put("aef", Optional.empty());
expectedLocations.put("ced", Optional.empty());
expectedLocations.put("abf", Optional.empty());
expectedLocations.put("cbd", Optional.empty());

Set<String> searchWords = expectedLocations.keySet();

Map<String, Optional<WordLocation>> actualLocations = wordSearcher.search(
searchWords,
new char[][]{
{'j', 'e', 'f'},
{'c', 'a', 'm'}});

assertThat(actualLocations).isEqualTo(expectedLocations);
}

@Ignore("Remove to run test")
@Test
public void testNotConcatenateDifferentLinesToFindAHorizontalWord() {
Map<String, Optional<WordLocation>> expectedLocations = new HashMap<>();
expectedLocations.put("elixir", Optional.empty());

Set<String> searchWords = expectedLocations.keySet();

Map<String, Optional<WordLocation>> actualLocations = wordSearcher.search(
searchWords,
new char[][]{
{'a', 'b', 'c', 'e', 'l', 'i'},
{'x', 'i', 'r', 'd', 'f', 'g'}});

assertThat(actualLocations).isEqualTo(expectedLocations);
}

@Ignore("Remove to run test")
@Test
public void testNotWrapAroundHorizontallyToFindAWord() {
Map<String, Optional<WordLocation>> expectedLocations = new HashMap<>();
expectedLocations.put("lisp", Optional.empty());

Set<String> searchWords = expectedLocations.keySet();

Map<String, Optional<WordLocation>> actualLocations = wordSearcher.search(
searchWords,
new char[][]{
{'s', 'i', 'l', 'a', 'b', 'c', 'd', 'e', 'f', 'p'}
}
);

assertThat(actualLocations).isEqualTo(expectedLocations);
}

@Ignore("Remove to run test")
@Test
public void testNotWrapAroundVerticallyToFindAWord() {
Map<String, Optional<WordLocation>> expectedLocations = new HashMap<>();
expectedLocations.put("rust", Optional.empty());

Set<String> searchWords = expectedLocations.keySet();

Map<String, Optional<WordLocation>> actualLocations = wordSearcher.search(
searchWords,
new char[][]{
{'s'},
{'u'},
{'r'},
{'a'},
{'b'},
{'c'},
{'t'}});

assertThat(actualLocations).isEqualTo(expectedLocations);
}

}