def test_construct_from_list(): # arrange # e.g. # 4 # 7 3 # 1 input = [4, 7, 3, None, None, 1] sut = BinaryTreeNode.construct_from_list(input) # act / assert assert sut.traverse_level_order() == [4, 7, 3, 1]
def test_construct_from_list_complex(): # arrange input = [ 4, -7, -3, None, None, -9, -3, 9, -7, -4, None, 6, None, -6, -6, None, None, 0, 6, 5, None, 9, None, None, -1, -4, None, None, None, -2 ] # act sut = BinaryTreeNode.construct_from_list(input) actual = sut.traverse_level_order() # assert expected = list(filter(lambda x: x is not None, input)) assert actual == expected