Beispiel #1
0
 def test_delete(self):
     words = read_string_array('files/shells.txt')
     tst = TST()
     frequency_counter(tst, words)
     tst.delete('she')
     assert tst.get('she') is None
     assert tst.size() == 9
Beispiel #2
0
 def test_keys_with_prefix(self):
     words = read_string_array('files/shells.txt')
     tst = TST()
     frequency_counter(tst, words)
     q = list(tst.keys_with_prefix('sh'))
     assert q == ['she', 'shells', 'shore']
Beispiel #3
0
 def test_get(self):
     words = read_string_array('files/shells.txt')
     tst = TST()
     frequency_counter(tst, words)
     assert tst.get('she') == 2
Beispiel #4
0
 def test_is_empty(self):
     words = read_string_array('files/shells.txt')
     tst = TST()
     assert tst.is_empty()
     frequency_counter(tst, words)
     assert not tst.is_empty()
Beispiel #5
0
 def test_size(self):
     words = read_string_array('files/shells.txt')
     tst = TST()
     frequency_counter(tst, words)
     assert tst.size() == 10
Beispiel #6
0
 def test_longest_prefix_of(self):
     words = read_string_array('files/shells.txt')
     tst = TST()
     frequency_counter(tst, words)
     assert tst.longest_prefix_of('shell') == 'she'
     assert tst.longest_prefix_of('shellsort') == 'shells'
Beispiel #7
0
 def test_keys_that_match(self):
     words = read_string_array('files/shells.txt')
     tst = TST()
     frequency_counter(tst, words)
     q = list(tst.keys_that_match('sh.'))
     assert q == ['she']