Skip to content

Commit 5b37d3b

Browse files
committed
test: add test for exponential search
1 parent 1861a87 commit 5b37d3b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { exponentialSearch } from '../exponential_search';
2+
3+
describe('Exponential search', () => {
4+
test.each([
5+
[[1, 2, 3, 4, 5], 3, 2],
6+
[[10, 20, 30, 40, 50], 35, null],
7+
[[10, 20, 30, 40, 50], 10, 0],
8+
[[10, 20, 30, 40, 50], 50, 4],
9+
[[10, 20, 30, 40, 50], 60, null],
10+
[[], 10, null],
11+
[[1, 2, 3, 4, 5], 1, 0],
12+
[[1, 2, 3, 4, 5], 5, 4]
13+
])(
14+
'of %o, searching for %o, expected %i',
15+
(array: number[], target: number, expected: number | null) => {
16+
expect(exponentialSearch(array, target)).toBe(expected);
17+
}
18+
);
19+
});

0 commit comments

Comments
 (0)