mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-07-05 08:26:14 +08:00
Avoid using toBeTruthy() and toBeFalsy() because of type coercion.
This commit is contained in:
@ -2,33 +2,33 @@ import regularExpressionMatching from '../regularExpressionMatching';
|
||||
|
||||
describe('regularExpressionMatching', () => {
|
||||
it('should match regular expressions in a string', () => {
|
||||
expect(regularExpressionMatching('', '')).toBeTruthy();
|
||||
expect(regularExpressionMatching('a', 'a')).toBeTruthy();
|
||||
expect(regularExpressionMatching('aa', 'aa')).toBeTruthy();
|
||||
expect(regularExpressionMatching('aab', 'aab')).toBeTruthy();
|
||||
expect(regularExpressionMatching('aab', 'aa.')).toBeTruthy();
|
||||
expect(regularExpressionMatching('aab', '.a.')).toBeTruthy();
|
||||
expect(regularExpressionMatching('aab', '...')).toBeTruthy();
|
||||
expect(regularExpressionMatching('a', 'a*')).toBeTruthy();
|
||||
expect(regularExpressionMatching('aaa', 'a*')).toBeTruthy();
|
||||
expect(regularExpressionMatching('aaab', 'a*b')).toBeTruthy();
|
||||
expect(regularExpressionMatching('aaabb', 'a*b*')).toBeTruthy();
|
||||
expect(regularExpressionMatching('aaabb', 'a*b*c*')).toBeTruthy();
|
||||
expect(regularExpressionMatching('', 'a*')).toBeTruthy();
|
||||
expect(regularExpressionMatching('xaabyc', 'xa*b.c')).toBeTruthy();
|
||||
expect(regularExpressionMatching('aab', 'c*a*b*')).toBeTruthy();
|
||||
expect(regularExpressionMatching('mississippi', 'mis*is*.p*.')).toBeTruthy();
|
||||
expect(regularExpressionMatching('ab', '.*')).toBeTruthy();
|
||||
expect(regularExpressionMatching('', '')).toBe(true);
|
||||
expect(regularExpressionMatching('a', 'a')).toBe(true);
|
||||
expect(regularExpressionMatching('aa', 'aa')).toBe(true);
|
||||
expect(regularExpressionMatching('aab', 'aab')).toBe(true);
|
||||
expect(regularExpressionMatching('aab', 'aa.')).toBe(true);
|
||||
expect(regularExpressionMatching('aab', '.a.')).toBe(true);
|
||||
expect(regularExpressionMatching('aab', '...')).toBe(true);
|
||||
expect(regularExpressionMatching('a', 'a*')).toBe(true);
|
||||
expect(regularExpressionMatching('aaa', 'a*')).toBe(true);
|
||||
expect(regularExpressionMatching('aaab', 'a*b')).toBe(true);
|
||||
expect(regularExpressionMatching('aaabb', 'a*b*')).toBe(true);
|
||||
expect(regularExpressionMatching('aaabb', 'a*b*c*')).toBe(true);
|
||||
expect(regularExpressionMatching('', 'a*')).toBe(true);
|
||||
expect(regularExpressionMatching('xaabyc', 'xa*b.c')).toBe(true);
|
||||
expect(regularExpressionMatching('aab', 'c*a*b*')).toBe(true);
|
||||
expect(regularExpressionMatching('mississippi', 'mis*is*.p*.')).toBe(true);
|
||||
expect(regularExpressionMatching('ab', '.*')).toBe(true);
|
||||
|
||||
expect(regularExpressionMatching('', 'a')).toBeFalsy();
|
||||
expect(regularExpressionMatching('a', '')).toBeFalsy();
|
||||
expect(regularExpressionMatching('aab', 'aa')).toBeFalsy();
|
||||
expect(regularExpressionMatching('aab', 'baa')).toBeFalsy();
|
||||
expect(regularExpressionMatching('aabc', '...')).toBeFalsy();
|
||||
expect(regularExpressionMatching('aaabbdd', 'a*b*c*')).toBeFalsy();
|
||||
expect(regularExpressionMatching('mississippi', 'mis*is*p*.')).toBeFalsy();
|
||||
expect(regularExpressionMatching('ab', 'a*')).toBeFalsy();
|
||||
expect(regularExpressionMatching('abba', 'a*b*.c')).toBeFalsy();
|
||||
expect(regularExpressionMatching('abba', '.*c')).toBeFalsy();
|
||||
expect(regularExpressionMatching('', 'a')).toBe(false);
|
||||
expect(regularExpressionMatching('a', '')).toBe(false);
|
||||
expect(regularExpressionMatching('aab', 'aa')).toBe(false);
|
||||
expect(regularExpressionMatching('aab', 'baa')).toBe(false);
|
||||
expect(regularExpressionMatching('aabc', '...')).toBe(false);
|
||||
expect(regularExpressionMatching('aaabbdd', 'a*b*c*')).toBe(false);
|
||||
expect(regularExpressionMatching('mississippi', 'mis*is*p*.')).toBe(false);
|
||||
expect(regularExpressionMatching('ab', 'a*')).toBe(false);
|
||||
expect(regularExpressionMatching('abba', 'a*b*.c')).toBe(false);
|
||||
expect(regularExpressionMatching('abba', '.*c')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user