def test_node_with_one_equal_child_is_min_heap(self): child_node = Node(10) node = Node(10, left=child_node, right=None) self.assertTrue(node.is_min_heap()) node = Node(10, left=None, right=child_node) self.assertTrue(node.is_min_heap())
def test_single_node_is_min_heap(self): node = Node('single') self.assertTrue(node.is_min_heap())
def test_node_with_equal_children_is_min_heap(self): left_child = Node(10) right_child = Node(10) node = Node(10, left=left_child, right=right_child) self.assertTrue(node.is_min_heap())
def test_min_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_min_heap()) node.heapify(heap_type=HEAP_TYPE.MIN) self.assertTrue(node.is_min_heap())
def test_node_with_bigger_children_is_min_heap(self): left_child = Node(11) right_child = Node(22) node = Node(1, left=left_child, right=right_child) self.assertTrue(node.is_min_heap())