mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-19 10:05:41 +08:00

* Create find_relative_maximum_point_count.js print number of relative maximum points in array runs in O(n) * rename file to match requested casing * add inline comments and greater documentation * fix wrong reference to algorithm explanation * remove live code and fix function misnaming * add multiple cases tests * add last line as empty line * git pull * style changes * move tests to test folder * chore: fix spelling * fix package-lock * revert to old lock file * chore: add line feed Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com>
44 lines
1.8 KiB
JavaScript
44 lines
1.8 KiB
JavaScript
import { NumberOfLocalMaximumPoints } from '../NumberOfLocalMaximumPoints'
|
|
|
|
describe('LocalMaximomPoint tests', () => {
|
|
it('test boundry maximom points - last element', () => {
|
|
const Array = [1, 2, 3, 4, 5, 6, 12]
|
|
expect(NumberOfLocalMaximumPoints(Array)).toEqual(1)
|
|
})
|
|
|
|
it('test boundry maximom points - first element', () => {
|
|
const Array = [13, 6, 5, 4, 3, 2, 1]
|
|
expect(NumberOfLocalMaximumPoints(Array)).toEqual(1)
|
|
})
|
|
|
|
it('test boundry maximom points - both boundries have maximum points', () => {
|
|
// Test a mix of number types (i.e., positive/negative, numbers with decimals, fractions)
|
|
const Array = [13, 2, 3, 4, 5, 6, 12]
|
|
expect(NumberOfLocalMaximumPoints(Array)).toEqual(2)
|
|
})
|
|
|
|
it('multiple maximom points in the middle', () => {
|
|
// Test a mix of number types (i.e., positive/negative, numbers with decimals, fractions)
|
|
const Array = [1, 3, 2, 5, 6, 9, 2, 7, 12, 1, 0]
|
|
expect(NumberOfLocalMaximumPoints(Array)).toEqual(3)
|
|
})
|
|
|
|
it('multiple maximom points in the middle with one at end', () => {
|
|
// Test a mix of number types (i.e., positive/negative, numbers with decimals, fractions)
|
|
const Array = [1, 3, 2, 5, 6, 9, 2, 7, 12, 1, 10]
|
|
expect(NumberOfLocalMaximumPoints(Array)).toEqual(4)
|
|
})
|
|
|
|
it('multiple maximom points in the middle with one at start', () => {
|
|
// Test a mix of number types (i.e., positive/negative, numbers with decimals, fractions)
|
|
const Array = [10, 3, 2, 5, 6, 9, 2, 7, 12, 1, 0]
|
|
expect(NumberOfLocalMaximumPoints(Array)).toEqual(3)
|
|
})
|
|
|
|
it('multiple maximom points in the middle with two more at both ends', () => {
|
|
// Test a mix of number types (i.e., positive/negative, numbers with decimals, fractions)
|
|
const Array = [10, 3, 11, 5, 6, 9, 2, 7, 12, 1, 10]
|
|
expect(NumberOfLocalMaximumPoints(Array)).toEqual(5)
|
|
})
|
|
})
|