mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
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>
This commit is contained in:
15
Search/test/InterpolationSearch.test.js
Normal file
15
Search/test/InterpolationSearch.test.js
Normal file
@ -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)
|
||||
})
|
Reference in New Issue
Block a user