Skip to content

Commit f5be6b2

Browse files
Ankush263github-actions
and
github-actions
authored
merge: Add test case to Fibonacci Search Algorithm (#1042)
* Add test case to Fibonacci Search Algorithm * Updated Documentation in README.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent 15c2096 commit f5be6b2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Search/test/FibonacciSearch.test.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { fibonacciSearch } from '../FibonacciSearch'
2+
3+
test('fibonacciSearch([10, 22, 35, 40, 45, 50, 80, 82, 85, 90, 100], 90, arr.length) => 9', () => {
4+
const arr = [10, 22, 35, 40, 45, 50, 80, 82, 85, 90, 100]
5+
const target = 90
6+
const res = fibonacciSearch(arr, target, arr.length)
7+
expect(res).toEqual(9)
8+
})
9+
10+
test('fibonacciSearch([1, 11, 55, 56, 78, 82, 104], 104, arr.length) => 6', () => {
11+
const arr = [1, 11, 55, 56, 78, 82, 104]
12+
const target = 104
13+
const res = fibonacciSearch(arr, target, arr.length)
14+
expect(res).toEqual(6)
15+
})
16+
17+
test('fibonacciSearch([40, 45, 50, 80, 82, 85, 90, 100]. 190, arr.length) => -1', () => {
18+
const arr = [40, 45, 50, 80, 82, 85, 90, 100]
19+
const target = 190
20+
const res = fibonacciSearch(arr, target, arr.length)
21+
expect(res).toEqual(-1)
22+
})

0 commit comments

Comments
 (0)