示例#1
0
def test_op_gt():
    a = RadixTreeSet.RadixTree('a')
    b = RadixTreeSet.RadixTree('a', 'asd3asd')
    c = RadixTreeSet.RadixTree('a', 'asd3asd', '23')
    assert (a > b) == False
    assert (b > b) == False
    assert (c > b) == True
示例#2
0
def test_op_et():
    a = RadixTreeSet.RadixTree('a')
    b = RadixTreeSet.RadixTree('a', 'asd3asd')
    c = RadixTreeSet.RadixTree('a', 'asd3asd', '23')
    assert (a == b) == False
    assert (b == b) == True
    assert (c == b) == False
示例#3
0
def test_op_lt():
    a = RadixTreeSet.RadixTree('a')
    b = RadixTreeSet.RadixTree('a', 'asd3asd')
    c = RadixTreeSet.RadixTree('a', 'asd3asd', '23')
    assert (a < b) == True
    assert (b < b) == False
    assert (c < b) == False
示例#4
0
def test_intersection_update():
    a = RadixTreeSet.RadixTree('12', '13', '_')
    b = RadixTreeSet.RadixTree('12', '123', '1234', 'a')
    c = {'12', '13', '_'}
    d = {'12', '123', '1234', 'a'}
    a.intersection_update(b)
    c.intersection_update(d)
    assert sorted(a) == sorted(c)
示例#5
0
def test_difference_update():
    a = RadixTreeSet.RadixTree('12', '13', '_')
    b = RadixTreeSet.RadixTree('12', '123', '1234', 'a')
    c = {'12', '13', '_'}
    d = {'12', '123', '1234', 'a'}
    a.difference_update(b)
    c.difference_update(d)
    assert sorted(a) == sorted(c)
示例#6
0
def test_symmetric_difference_update():
    a = RadixTreeSet.RadixTree('12', '13', '14', '15')
    b = RadixTreeSet.RadixTree('12', '13', '18', '20')
    c = {'12', '13', '14', '15'}
    d = {'12', '13', '18', '20'}
    a.symmetric_difference_update(b)
    c.symmetric_difference_update(d)
    assert sorted(a) == sorted(c)
示例#7
0
def test_discard():
    a = RadixTreeSet.RadixTree('12', '13', '_')
    b = RadixTreeSet.RadixTree('12', '123', '1234', 'a')
    c = {'12', '13', '_'}
    d = {'12', '123', '1234', 'a'}
    a.discard(b)
    c.discard(d)
    assert sorted(a) == sorted(c)
示例#8
0
def test_difference():
    a = RadixTreeSet.RadixTree('12', '13', '_')
    b = RadixTreeSet.RadixTree('12', '123', '1234', 'a')
    c = {'12', '13', '_'}
    d = {'12', '123', '1234', 'a'}
    assert sorted(a.difference(b)) == sorted(c.difference(d))
    assert sorted(b.difference(a)) == sorted(d.difference(c))
    assert sorted(a.difference(d)) == sorted(c.difference(b))
    assert sorted(d.difference(a)) == sorted(b.difference(c))
示例#9
0
def test_issuperset():
    a = RadixTreeSet.RadixTree('12', '13', '14', '15')
    b = RadixTreeSet.RadixTree('12', '13', '14')
    c = RadixTreeSet.RadixTree('112', '12', '13', '14')
    d = {'12', '13', '14', '15'}
    e = {'12', '13', '14'}
    f = {'112', '12', '13', '14'}
    assert a.issuperset(b) == d.issuperset(e)
    assert a.issuperset(c) == d.issuperset(f)
    assert b.issuperset(c) == e.issuperset(f)
示例#10
0
def test_isdisjoint():
    a = RadixTreeSet.RadixTree('12', '13', '_')
    b = RadixTreeSet.RadixTree('12', '14', '15', 'a')
    c = RadixTreeSet.RadixTree('112', '126', '15', 'c')
    d = {'12', '13', '_'}
    e = {'12', '14', '15', 'a'}
    f = {'112', '126', '15', 'c'}
    assert a.isdisjoint(b) == d.isdisjoint(e)
    assert a.isdisjoint(c) == d.isdisjoint(f)
    assert b.isdisjoint(c) == e.isdisjoint(f)
示例#11
0
def test_add():
    a = RadixTreeSet.RadixTree('a', 'asd3asd', 'dsf', '12312', '123', '1', '123')
    b = RadixTreeSet.RadixTree()
    b.add('asd3asd')
    b.add('a')
    b.add('123')
    b.add('1')
    b.add('12312')
    b.add('dsf')
    c = {'a', 'asd3asd', 'dsf', '12312', '123', '1', '123'}
    assert a.root == b.root
    assert repr(sorted(b)) == repr(sorted(c))
示例#12
0
def test_update():
    a = RadixTreeSet.RadixTree('1')
    b = RadixTreeSet.RadixTree('2')
    c = RadixTreeSet.RadixTree('13', '14')
    a_ = {'1'}
    b_ = {'2'}
    c_ = {'13', '14'}
    c__ = ['13', '14', '1000']
    a.update(b)
    a_.update(b)
    assert sorted(a) == sorted(a_)
    a.update(b_, c_, c__)
    a_.update(b, c, c__)
    assert sorted(a) == sorted(a_)
示例#13
0
def test_get_len():
    a = RadixTreeSet.RadixTree('a', 'asd3asd')
    assert a.get_len() == 2
    a.add('23')
    assert a.get_len() == 3
    a.remove('asd3asd')
    assert a.get_len() == 2
示例#14
0
def test_print_items(capsys):
    a = RadixTreeSet.RadixTree('a', 'asd3asd', 'dsf', '12312', '123', '1', '123')
    b = {'a', 'asd3asd', 'dsf', '12312', '123', '1', '123'}
    a.print_items()
    captured = capsys.readouterr()
    a_out = captured.out
    print(sorted(b))
    captured = capsys.readouterr()
    b_out = captured.out
    assert a_out == b_out
示例#15
0
def test_repr():
    a = RadixTreeSet.RadixTree('a', 'asd3asd', 'dsf', '12312', '123', '1')
    b = {'a', 'asd3asd', 'dsf', '12312', '123', '1'}
    assert repr(sorted(a)) == repr(sorted(b))
示例#16
0
def test_union_iter():
    a = RadixTreeSet.RadixTree('12', '13')
    b = RadixTreeSet.RadixTree('12', '123')
    c = {'12', '13'}
    d = {'12', '123'}
    assert sorted(a.union(b)) == sorted(c.union(d))
示例#17
0
def test_clear():
    a = RadixTreeSet.RadixTree('a', 'asd3asd', 'dsf', '12312', '123', '1', '123')
    b = RadixTreeSet.RadixTree()
    a.clear()
    assert repr(a) == repr(b)
示例#18
0
def test_copy():
    a = RadixTreeSet.RadixTree('a', 'asd3asd', 'dsf', '12312', '123', '1')
    b = a.copy()
    assert sorted(a) == sorted(b)
    b.add('dsfasdas')
    assert sorted(a) != sorted(b)
示例#19
0
def test_op_add():
    a = RadixTreeSet.RadixTree('a', 'asd3asd')
    b = RadixTreeSet.RadixTree('dsf', '12312', '123', '1', '123')
    c = RadixTreeSet.RadixTree('a', 'asd3asd', 'dsf', '12312', '123', '1', '123')
    d = a + b
    assert sorted(c) == sorted(d)
示例#20
0
def test_parents():
    a = RadixTreeSet.RadixTree('12', '13', '123', '12345', 'a', '123465', '145678')
    assert a.parents('1234') == {'12', '123'}
示例#21
0
def test_children():
    a = RadixTreeSet.RadixTree('12', '13', '123', '12345', 'a', '123465', '145678')
    assert a.children('123') == {'123', '12345', '123465'}
示例#22
0
def test_pop():
    a = RadixTreeSet.RadixTree('15')
    b = {'15'}
    assert a.pop() == b.pop()
    assert sorted(a) == sorted(b)
示例#23
0
def test_init():
    a = RadixTreeSet.RadixTree('12', '13', '123', '12345', '123465', '145678')
    b = {'12', '13', '123', '12345', '123465', '145678'}
    assert repr(sorted(a)) == repr(sorted(b))
示例#24
0
def test_len():
    a = RadixTreeSet.RadixTree('a', 'asd3asd', 'dsf', '12312', '123', '1')
    b = {'a', 'asd3asd', 'dsf', '12312', '123', '1'}
    assert len(a) == len(b)
示例#25
0
def test_intersection():
    a = RadixTreeSet.RadixTree('12', '13', '_')
    b = RadixTreeSet.RadixTree('12', '123', '1234', 'a')
    c = {'12', '13', '_'}
    d = {'12', '123', '1234', 'a'}
    assert sorted(a.intersection(b)) == sorted(c.intersection(d))
示例#26
0
def test_remove():
    a = RadixTreeSet.RadixTree('12', '13', '14', '15')
    b = {'12', '13', '14', '15'}
    a.remove('13')
    b.remove('13')
    assert sorted(a) == sorted(b)
示例#27
0
def test_extend():
    a = RadixTreeSet.RadixTree()
    b = {'a', 'asd3asd', 'dsf', '12312', '123', '1', '123'}
    a.extend(b)
    assert repr(sorted(a)) == repr(sorted(b))