Closed
Description
Hello,
I recently tried to run some property based tests on the algorithms provided in javascript-algorithms.
I discovered the following failing case with rabinKarp algorithm:
expect(rabinKarp("^ !/'#'pp", " !/'#'pp")).toBe(2); // output: -1
In order to find it, I used fast-check framework with the property:
// for any strings a, b and c
// rabinKarp(a + b + c, b) should be different from -1 (indeed b is a substring of a+b+c)
fc.assert(
fc.property(
fc.string(), fc.string(), fc.string(),
(a, b, c) => rabinKarp(a + b + c, b) !== -1
)
);
I was not able to have a smaller example for this precise case :/