def test_pre_order():
    tree = BinarySearchTree()
    tree.add('A')
    tree.add('B')
    tree.add('C')
    actual = tree.pre_order()
    excepted = ['A', 'B', 'C']
    assert actual == excepted
示例#2
0
def test_pre_order():
    fruits = BinarySearchTree()
    fruits.add('bananas')
    fruits.add('apples')
    fruits.add('carrots')
    fruits.add('mango')
    fruits.add('pear')
    fruits.add('cake')
    fruits.add('cookies')
    fruits.add('beer')
    fruits.add('whiskey')
    expected = [
        'bananas', 'apples', 'beer', 'cake', 'carrots', 'cookies', 'mango',
        'pear', 'whiskey'
    ]
    actual = fruits.pre_order()
    assert expected == actual