-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
/
Copy pathLocalMaximomPoint.test.js
38 lines (31 loc) · 1.21 KB
/
LocalMaximomPoint.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { LocalMaximomPoint } from '../LocalMaximomPoint'
describe('LocalMaximumPoint tests', () => {
it('test boundary maximum points - last element', () => {
const Array = [1, 2, 3, 4, 5, 6, 12]
expect(LocalMaximomPoint(Array)).toEqual(6)
})
it('test boundary maximum points - first element', () => {
const Array2 = [13, 6, 5, 4, 3, 2, 1]
expect(LocalMaximomPoint(Array2)).toEqual(0)
})
it('test boundary maximum points - should find first maximom point from the top', () => {
const Array = [13, 2, 3, 4, 5, 6, 12]
expect(LocalMaximomPoint(Array)).toEqual(6)
})
it('test inner points - second element', () => {
const Array2 = [13, 16, 5, 4, 3, 2, 1]
expect(LocalMaximomPoint(Array2)).toEqual(1)
})
it('test inner points - element some where in the middle', () => {
const Array2 = [13, 16, 5, 41, 3, 2, 1]
expect(LocalMaximomPoint(Array2)).toEqual(3)
})
it('test with positive and negative numbers', () => {
const Array2 = [-4, -3, -2, -1, -5, 4, -1]
expect(LocalMaximomPoint(Array2)).toEqual(3)
})
it('test with floating-point numbers', () => {
const Array2 = [1.5, 3.5, 2.5, 0.5, -1.5, -3.5, -2.5]
expect(LocalMaximomPoint(Array2)).toEqual(1)
})
})