Esempio n. 1
0
 def test_prefix_exists(self):
     trie = Trie()
     trie.add('foob', 1)
     trie.add('fooba', 2)
     trie.add('foobb', 3)
     trie.add('foobar', 4)
     trie.add('foobaz', 5)
     values = list(trie.values_for_prefix('foo'))
     assert len(values) == 5
     for i in range(1, 6):
         assert i in values
Esempio n. 2
0
 def test_whole_key_as_prefix(self):
     trie = Trie()
     trie.add('foobar', 1)
     assert trie.has_prefix('foobar')
Esempio n. 3
0
 def test_key_exists(self):
     trie = Trie()
     trie.add('foobar', 1)
     trie.add('foobar', 2)
     assert trie.values('foobar') == [1, 2]
Esempio n. 4
0
 def test_prefix_exists(self):
     trie = Trie()
     trie.add('foobar', 1)
     assert trie.has_prefix('foo')
Esempio n. 5
0
 def test_key_exists(self):
     trie = Trie()
     trie.add('foo', 1)
     assert trie.has('foo')
Esempio n. 6
0
 def test_multiple_with_same_key_prefix(self):
     trie = Trie()
     trie.add('foo', 1)
     trie.add('foobar', 2)
     assert_has_key(trie, 'foo', 1)
     assert_has_key(trie, 'foobar', 2)
Esempio n. 7
0
 def test_multiple_with_different_keys(self):
     trie = Trie()
     trie.add('foo', 1)
     trie.add('bar', 2)
     assert_has_key(trie, 'foo', 1)
     assert_has_key(trie, 'bar', 2)
Esempio n. 8
0
 def test_single(self):
     trie = Trie()
     trie.add('foo', 1)
     assert_has_key(trie, 'foo', 1)