Skip to content

Commit d15bce4

Browse files
Improve Aho-Corasick multiple occurrence test
1 parent 6ec6339 commit d15bce4

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/test/java/com/thealgorithms/strings/AhoCorasickTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,21 @@ void testPatternAtEnd() {
9595
}
9696

9797
/**
98-
* Test searching for patterns with multiple occurrences in the input text.
99-
* The expected sizes are 1 and 1, and the expected positions are 2 and 3
100-
* for the patterns "AT" and "T" respectively.
101-
*/
98+
* Test searching for patterns with multiple occurrences in the input text.
99+
* The expected positions are 2 and 4 for "AT", and 3 and 5 for "T".
100+
*/
102101
@Test
103102
void testMultipleOccurrencesOfPattern() {
104-
// Define patterns with multiple occurrences in the text
103+
final var searchText = "GCATATCG";
105104
final var searchPatterns = new String[] {"AT", "T"};
106-
final var expected = Map.of("AT", new ArrayList<>(List.of(2)), "T", new ArrayList<>(List.of(3)));
107-
assertEquals(expected, AhoCorasick.search(text, searchPatterns));
105+
106+
final var expected =
107+
Map.of(
108+
"AT", new ArrayList<>(List.of(2, 4)),
109+
"T", new ArrayList<>(List.of(3, 5))
110+
);
111+
112+
assertEquals(expected, AhoCorasick.search(searchText, searchPatterns));
108113
}
109114

110115
/**

0 commit comments

Comments
 (0)