From 85f428e82675bfd4eeb74e4b3a1cf90f8b84013b Mon Sep 17 00:00:00 2001 From: Ankush263 <86042508+Ankush263@users.noreply.github.com> Date: Mon, 13 Jun 2022 22:17:18 +0530 Subject: [PATCH] merge: Add test case to Interpolation Search Algorithm (#1045) * Add test case to Interpolation Search Algorithm * Updated Documentation in README.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> --- Search/test/InterpolationSearch.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Search/test/InterpolationSearch.test.js diff --git a/Search/test/InterpolationSearch.test.js b/Search/test/InterpolationSearch.test.js new file mode 100644 index 000000000..744a74855 --- /dev/null +++ b/Search/test/InterpolationSearch.test.js @@ -0,0 +1,15 @@ +import { interpolationSearch } from '../InterpolationSearch' + +test('interpolationSearch([2, 6, 8, 14, 122, 169], 144) => -1', () => { + const array = [2, 6, 8, 14, 122, 169] + const key = 144 + const res = interpolationSearch(array, key) + expect(res).toEqual(-1) +}) + +test('interpolationSearch([2, 6, 8, 14, 122, 169], 122) => 4', () => { + const array = [2, 6, 8, 14, 122, 169] + const key = 122 + const res = interpolationSearch(array, key) + expect(res).toEqual(4) +})