forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKMPTest.java
More file actions
21 lines (18 loc) · 835 Bytes
/
KMPTest.java
File metadata and controls
21 lines (18 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.thealgorithms.strings;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import org.junit.jupiter.api.Test;
public class KMPTest {
@Test
public void testKMPMatcher() {
assertEquals(List.of(0, 1), KMP.kmpMatcher("AAAAABAAABA", "AAAA"));
assertEquals(List.of(0, 2), KMP.kmpMatcher("ABCABC", "ABC"));
assertEquals(List.of(10), KMP.kmpMatcher("ABABDABACDABABCABAB", "ABABCABAB"));
assertEquals(List.of(), KMP.kmpMatcher("ABCDE", "FGH"));
assertEquals(List.of(), KMP.kmpMatcher("A", "AA"));
assertEquals(List.of(0, 1, 2), KMP.kmpMatcher("AAA", "A"));
assertEquals(List.of(0), KMP.kmpMatcher("A", "A"));
assertEquals(List.of(), KMP.kmpMatcher("", "A"));
assertEquals(List.of(), KMP.kmpMatcher("A", ""));
}
}