From 6a3a4b8697cd79a5a0c769d5eb3239c0d2507aad Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Mon, 23 Jul 2018 18:00:54 +0300 Subject: [PATCH] Add new test cases for KMP algorithm. --- .../knuth-morris-pratt/__test__/knuthMorrisPratt.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/algorithms/string/knuth-morris-pratt/__test__/knuthMorrisPratt.test.js b/src/algorithms/string/knuth-morris-pratt/__test__/knuthMorrisPratt.test.js index 5b47e72a..42e6f81c 100644 --- a/src/algorithms/string/knuth-morris-pratt/__test__/knuthMorrisPratt.test.js +++ b/src/algorithms/string/knuth-morris-pratt/__test__/knuthMorrisPratt.test.js @@ -2,6 +2,9 @@ import knuthMorrisPratt from '../knuthMorrisPratt'; describe('knuthMorrisPratt', () => { 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', 'bcgl')).toBe(3); expect(knuthMorrisPratt('abcxabcdabxabcdabcdabcy', 'abcdabcy')).toBe(15);