Exemplo n.º 1
0
def test_search_returns_appropriate_node_to_right():
    root_node = BinaryTreeNode(5)
    child_node = BinaryTreeNode(7)
    new_node = BinaryTreeNode(6)
    tree = BinaryTree(root_node)
    tree.insert_node(child_node)
    tree.insert_node(new_node)
    result = tree.search(6)
    assert result == new_node
Exemplo n.º 2
0
def test_search_returns_none_when_not_present():
    new_node = BinaryTreeNode(1)
    tree = BinaryTree(new_node)
    result = tree.search(2)
    assert result == None
Exemplo n.º 3
0
def test_search_returns_root_when_value_at_root():
    new_node = BinaryTreeNode(1)
    tree = BinaryTree(new_node)
    result = tree.search(1)
    assert result == new_node