mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-12-19 06:58:15 +08:00
Add KMP string searching algorithm
This commit is contained in:
15
String/test/KMPPatternSearching.test.js
Normal file
15
String/test/KMPPatternSearching.test.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { KMPSearch } from '../KMPPatternSearching'
|
||||
|
||||
describe('KMP Matcher', () => {
|
||||
it('TC1: expects to return matching indices for pattern in text', () => {
|
||||
const text = 'ABC ABCDAB ABCDABCDABDE'
|
||||
const pattern = 'ABCDABD'
|
||||
expect(KMPSearch(text, pattern)).toStrictEqual([15])
|
||||
})
|
||||
|
||||
it('TC2: expects to return matching indices for pattern in text', () => {
|
||||
const text = 'ABC ABCDABD ABCDABCDABDE'
|
||||
const pattern = 'ABCDABD'
|
||||
expect(KMPSearch(text, pattern)).toStrictEqual([4, 16])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user