def test_node_with_one_equal_child_is_max_heap(self): child_node = Node(10) node = Node(10, left=child_node, right=None) self.assertTrue(node.is_max_heap()) node = Node(10, left=None, right=child_node) self.assertTrue(node.is_max_heap())
def test_node_with_smaller_children_is_max_heap(self): left_child = Node(1) right_child = Node(2) node = Node(10, left=left_child, right=right_child) self.assertTrue(node.is_max_heap())
def test_single_node_is_max_heap(self): node = Node('single') self.assertTrue(node.is_max_heap())
def test_max_heapify(self): n_value, l_value, r_value = 10, 20, 5 node = Node(n_value, left=Node(l_value), right=Node(r_value)) self.assertFalse(node.is_max_heap()) node.heapify(heap_type=HEAP_TYPE.MAX) self.assertTrue(node.is_max_heap())