From c365e82d08c541a3132262ed5057094e2aa25c23 Mon Sep 17 00:00:00 2001 From: AditiJain2826 <31892168+AditiJain2826@users.noreply.github.com> Date: Fri, 7 Oct 2022 10:44:11 +0530 Subject: [PATCH] Adding testcases for Boyer Moore Algorithm (#1135) --- String/test/BoyerMoore.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 String/test/BoyerMoore.test.js diff --git a/String/test/BoyerMoore.test.js b/String/test/BoyerMoore.test.js new file mode 100644 index 000000000..0ae73dbf1 --- /dev/null +++ b/String/test/BoyerMoore.test.js @@ -0,0 +1,15 @@ +import { boyerMoore } from '../BoyerMoore' + +describe('Testing the boyer moore algorithm', () => { + it('Testing with alphabetical strings', () => { + expect(boyerMoore('THIS IS A TEST TEXT', 'TEST')).toBe(10) + expect(boyerMoore('AAIOOOAADDZXYCAADAABAABA', 'AADA')).toBe(14) + expect(boyerMoore('Hello World! This is a test case.', 'Boyer')).toBe(-1) + }) + + it('Testing with alphabets and symbols', () => { + expect(boyerMoore('AA&&@_OPOODDA##!', '@_')).toBe(4) + expect(boyerMoore('LK_||{{}}[[$($', '||')).toBe(3) + expect(boyerMoore('__||{{__+}}[[$($', '-}}')).toBe(-1) + }) +})