-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.js
26 lines (25 loc) · 971 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import * as assert from 'assert';
import * as fc from 'fast-check';
import { longestCommonSubstr } from './implem';
describe('longest common substr', () => {
it('should find the same substring lengths whatever the order of the inputs', () =>
fc.assert(
fc.property(fc.string(), fc.string(), (s1, s2) => {
assert.equal(longestCommonSubstr(s1, s2).length, longestCommonSubstr(s2, s1).length);
})
));
it('should include the substr in both strings', () =>
fc.assert(
fc.property(fc.string(), fc.string(), (s1, s2) => {
const longest = longestCommonSubstr(s1, s2);
assert.ok(s1.includes(longest));
assert.ok(s2.includes(longest));
})
));
it('should detect the longest common', () =>
fc.assert(
fc.property(fc.string(), fc.string(), fc.string(), (s, prefix, suffix) => {
assert.equal(longestCommonSubstr(prefix + s + suffix, s), s);
})
));
});