def test_postorder_traversal(nodes, expected): root = bst.create(nodes) index = 0 for node in bst.postorder(root): assert node.val == expected[index] index += 1
def test_bst_create(nodes, expected): root = bst.create(nodes) assert root.val == expected
def test_search_iter_fail(nodes, nonexistent): root = bst.create(nodes) assert bst.search_iter(root, nonexistent) is None
def test_maximum(nodes, expected): root = bst.create(nodes) result = bst.maximum(root) assert result.val == expected
def test_search_iter(nodes, target): root = bst.create(nodes) result = bst.search_iter(root, target) assert result.val == target