Skip to content

test: add mixed number types for LocalMaximomPoint tests #1668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
13 changes: 12 additions & 1 deletion Data-Structures/Array/test/LocalMaximomPoint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe('LocalMaximumPoint tests', () => {
})

it('test boundary maximum points - should find first maximom point from the top', () => {
// Test a mix of number types (i.e., positive/negative, numbers with decimals, fractions)
const Array = [13, 2, 3, 4, 5, 6, 12]
expect(LocalMaximomPoint(Array)).toEqual(6)
})
Expand All @@ -26,4 +25,16 @@ describe('LocalMaximumPoint tests', () => {
const Array2 = [13, 16, 5, 41, 3, 2, 1]
expect(LocalMaximomPoint(Array2)).toEqual(3)
})

it('test inner points - repeated local maxima', () => {
const Array2 = [1, 5, 5, 5, 3, 2, 1]
const result = LocalMaximomPoint(Array2)
expect([1, 2, 3]).toContain(result)
})

it('test inner points - alternating peaks and valleys', () => {
const Array2 = [1, 3, 2, 4, 3, 5, 4]
const result = LocalMaximomPoint(Array2)
expect([1, 3, 5]).toContain(result)
})
})
Loading