We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7fa7c5b commit fb1f5ddCopy full SHA for fb1f5dd
data_structures/heaps/max_heap_test.rb
@@ -22,12 +22,22 @@ def test_max_returns_maximum_heap_element
22
assert heap.max == 4
23
end
24
25
+ def test_max_returns_nil_if_empty_heap
26
+ heap = MaxHeap.new
27
+ assert heap.max.nil?
28
+ end
29
+
30
def test_extract_max_returns_and_removes_maximum_heap_element
31
heap = MaxHeap.new([4, 1, 3])
32
assert heap.extract_max == 4
33
assert heap.to_array == [3, 1]
34
35
36
+ def test_extract_max_returns_nil_if_empty_heap
37
38
+ assert heap.extract_max.nil?
39
40
41
def test_insert_adds_element_to_appropriate_position
42
43
heap.insert(2)
0 commit comments