def test_print_three_nodes_even(): x = BinaryNode() x.value = 10 x.left_node = BinaryNode() x.left_node.value = 5 x.right_node = BinaryNode() x.right_node.value = 15 print x.to_string() assert x.to_string( ) == "Value: 10\nLeft node->Value: 5\nRight node->Value: 15"
def test_print_two_nodes_left(): x = BinaryNode() x.value = 10 x.left_node = BinaryNode() x.left_node.value = 5 print x.to_string() assert x.to_string() == "Value: 10\nLeft node->Value: 5"
def test_print_two_nodes_right(): x = BinaryNode() x.value = 10 x.right_node = BinaryNode() x.right_node.value = 15 print x.to_string() assert x.to_string() == "Value: 10\nRight node->Value: 15"
def test_print_four_nodes(): x = BinaryNode() x.value = 10 x.left_node = BinaryNode() x.left_node.value = 5 x.right_node = BinaryNode() x.right_node.value = 15 x.left_node.left_node = BinaryNode() x.left_node.left_node.value = 1 print x.to_string() assert x.to_string( ) == "Value: 10\nLeft node->Value: 5\nLeft node->Value: 1\nRight node->Value: 15"
def test_print_single_node(): x = BinaryNode() x.value = 10 assert x.to_string() == "Value: 10"