Skip to content
Closed
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
19 changes: 12 additions & 7 deletions src/test/java/com/thealgorithms/strings/AhoCorasickTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,21 @@ void testPatternAtEnd() {
}

/**
* Test searching for patterns with multiple occurrences in the input text.
* The expected sizes are 1 and 1, and the expected positions are 2 and 3
* for the patterns "AT" and "T" respectively.
*/
* Test searching for patterns with multiple occurrences in the input text.
* The expected positions are 2 and 4 for "AT", and 3 and 5 for "T".
*/
@Test
void testMultipleOccurrencesOfPattern() {
// Define patterns with multiple occurrences in the text
final var searchText = "GCATATCG";
final var searchPatterns = new String[] {"AT", "T"};
final var expected = Map.of("AT", new ArrayList<>(List.of(2)), "T", new ArrayList<>(List.of(3)));
assertEquals(expected, AhoCorasick.search(text, searchPatterns));

final var expected =
Map.of(
"AT", new ArrayList<>(List.of(2, 4)),
"T", new ArrayList<>(List.of(3, 5))
);

assertEquals(expected, AhoCorasick.search(searchText, searchPatterns));
}

/**
Expand Down
Loading