Skip to content

Commit 6a3a4b8

Browse files
committed
Add new test cases for KMP algorithm.
1 parent 76c172b commit 6a3a4b8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/algorithms/string/knuth-morris-pratt/__test__/knuthMorrisPratt.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import knuthMorrisPratt from '../knuthMorrisPratt';
22

33
describe('knuthMorrisPratt', () => {
44
it('should find word position in given text', () => {
5+
expect(knuthMorrisPratt('', '')).toBe(-1);
6+
expect(knuthMorrisPratt('a', '')).toBe(-1);
7+
expect(knuthMorrisPratt('a', 'a')).toBe(0);
58
expect(knuthMorrisPratt('abcbcglx', 'abca')).toBe(-1);
69
expect(knuthMorrisPratt('abcbcglx', 'bcgl')).toBe(3);
710
expect(knuthMorrisPratt('abcxabcdabxabcdabcdabcy', 'abcdabcy')).toBe(15);

0 commit comments

Comments
 (0)