Adding unit tests for element not found in max-heap

This commit is contained in:
Amos Paribocci 2023-02-06 18:52:42 +01:00
parent 7fa7c5bae0
commit fb1f5dd679

View file

@ -22,12 +22,22 @@ class TestMaxHeap < Minitest::Test
assert heap.max == 4
end
def test_max_returns_nil_if_empty_heap
heap = MaxHeap.new
assert heap.max.nil?
end
def test_extract_max_returns_and_removes_maximum_heap_element
heap = MaxHeap.new([4, 1, 3])
assert heap.extract_max == 4
assert heap.to_array == [3, 1]
end
def test_extract_max_returns_nil_if_empty_heap
heap = MaxHeap.new
assert heap.extract_max.nil?
end
def test_insert_adds_element_to_appropriate_position
heap = MaxHeap.new([4, 1, 3])
heap.insert(2)