예제 #1
0
def test_things():
    s = SuffixTree()
    s.add(['./', 'dir/', 'utils.', 'max'], 1)
    s.add(['./', 'dir/', 'footils.', 'max'], 2)
    s.add(['./', 'dir/', 'footils.', 'hacks'], 3)

    assert s.get(['hacks']) == 3
    assert s.get_with_path(['footils.', 'max']) == (2, ['./', 'dir/', 'footils.', 'max'])
    with raises(SuffixNotFound):
        s.get(['quacks.', 'max'])
    with raises(SuffixAmbiguous):
        s.get(['max'])
예제 #2
0
def test_full_path():
    """Looking up a full path should not crash."""
    s = SuffixTree()
    s.add(['./', 'dir/', 'footils.', 'jacks'], 4)
    assert s.get_with_path(['./', 'dir/', 'footils.', 'jacks']) == (4, ['./', 'dir/', 'footils.', 'jacks'])