def test_build_heap_max(self): heap = [5, 1, 2, 4, 0, 8, 7, 1, 10] binary_heap.build_max_heap(heap) expected = [10, 5, 8, 4, 0, 2, 7, 1, 1] self.assertEqual(heap, expected)
def test_max_heap_insert(self): max_value = 50 heap = [random.randint(1, max_value) for x in range(10)] new_item = random.randint(1, max_value) expected = heap + [new_item] binary_heap.build_max_heap( expected ) # print(heap, new_item) binary_heap.build_max_heap(heap) binary_heap.max_heap_insert(heap, new_item) self.assertEqual(heap, expected)