mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-11-16 19:50:00 +01:00
Adding unit tests for element not found in max-heap
This commit is contained in:
parent
7fa7c5bae0
commit
fb1f5dd679
1 changed files with 10 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue