def test_mirror(self): tree = mirror(binary_search_tree()) self.assertIsNotNone(tree) self.assertTrue(equals(tree, binary_search_tree_mirrored()))
def test_equals(self): self.assertTrue(equals(binary_search_tree(), binary_search_tree())) self.assertFalse( equals(binary_search_tree(), invalid_binary_search_tree()))
def test_sortedArrayToBST(self): tree = sortedArrayToBST([25, 50, 75, 100, 125, 150, 175]) self.assertTrue(equals(tree, binary_search_tree()))
def test_clone(self): tree = binary_search_tree() othr = clone(tree) self.assertTrue(equals(tree, othr)) self.assertFalse(id(tree) == id(othr))
def test_deleteInPlace(self): tree = deleteInPlace(binary_search_tree(), 50) self.assertFalse(contains(tree, 50)) tree = deleteInPlace(binary_search_tree(), 51) self.assertTrue(equals(tree, binary_search_tree()))
def test_insertAndCopy(self): tree = binary_search_tree() othr = insertAndCopy(tree, 45) self.assertFalse(equals(tree, othr)) self.assertTrue(contains(othr, 45))