示例#1
0
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
示例#2
0
def test_bst_create(nodes, expected):
    root = bst.create(nodes)
    assert root.val == expected
示例#3
0
def test_search_iter_fail(nodes, nonexistent):
    root = bst.create(nodes)
    assert bst.search_iter(root, nonexistent) is None
示例#4
0
def test_maximum(nodes, expected):
    root = bst.create(nodes)
    result = bst.maximum(root)
    assert result.val == expected
示例#5
0
def test_search_iter(nodes, target):
    root = bst.create(nodes)
    result = bst.search_iter(root, target)
    assert result.val == target