2024-heraklion-testing-debu.../hands_on_solutions/local_maxima/test_local_maxima.py

37 lines
755 B
Python
Raw Normal View History

2024-08-26 13:54:13 +02:00
from local_maxima import find_maxima
def test_find_maxima():
values = [1, 3, -2, 0, 2, 1]
expected = [1, 4]
maxima = find_maxima(values)
assert maxima == expected
def test_find_maxima_edges():
values = [4, 2, 1, 3, 1, 5]
expected = [0, 3, 5]
maxima = find_maxima(values)
assert maxima == expected
def test_find_maxima_empty():
values = []
expected = []
maxima = find_maxima(values)
assert maxima == expected
def test_find_maxima_plateau():
values = [1, 2, 2, 1]
expected = [1]
maxima = find_maxima(values)
assert maxima == expected
def test_find_maxima_not_a_plateau():
values = [1, 2, 2, 3, 1]
expected = [3]
maxima = find_maxima(values)
assert maxima == expected