mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-27 07:31:17 +08:00
Add new test cases for KMP algorithm.
This commit is contained in:
parent
76c172b20b
commit
6a3a4b8697
@ -2,6 +2,9 @@ import knuthMorrisPratt from '../knuthMorrisPratt';
|
|||||||
|
|
||||||
describe('knuthMorrisPratt', () => {
|
describe('knuthMorrisPratt', () => {
|
||||||
it('should find word position in given text', () => {
|
it('should find word position in given text', () => {
|
||||||
|
expect(knuthMorrisPratt('', '')).toBe(-1);
|
||||||
|
expect(knuthMorrisPratt('a', '')).toBe(-1);
|
||||||
|
expect(knuthMorrisPratt('a', 'a')).toBe(0);
|
||||||
expect(knuthMorrisPratt('abcbcglx', 'abca')).toBe(-1);
|
expect(knuthMorrisPratt('abcbcglx', 'abca')).toBe(-1);
|
||||||
expect(knuthMorrisPratt('abcbcglx', 'bcgl')).toBe(3);
|
expect(knuthMorrisPratt('abcbcglx', 'bcgl')).toBe(3);
|
||||||
expect(knuthMorrisPratt('abcxabcdabxabcdabcdabcy', 'abcdabcy')).toBe(15);
|
expect(knuthMorrisPratt('abcxabcdabxabcdabcdabcy', 'abcdabcy')).toBe(15);
|
||||||
|
Loading…
Reference in New Issue
Block a user