def test_tree_preorder(): bt = BinaryTree() bt.root = Node(6) bt.root.right = Node(5) bt.root.left = Node(-1) bt.root.right.left = Node(7) bt.root.left.left = Node(10) bt.root.right.right = Node(3) assert bt.preOrder() == [6, -1, 10, 5, 7, 3]
def test_tree_single_left_right(): bt = BinaryTree() bt.root = Node(7) bt.root.left = Node(3) bt.root.right = Node(2) assert bt.root.value == 7 assert bt.root.left.value == 3 assert bt.root.right.value == 2 assert bt.preOrder() == [7, 3, 2]