-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
52 lines (40 loc) · 1.69 KB
/
tests.py
File metadata and controls
52 lines (40 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import unittest
from trie_search import read_word, get_trie_from_list, add_frequency_map, find_matches
class TestHelperMethods(unittest.TestCase):
def test_frequency_map(self):
'''tests the add_frequency_map function.
Verify that when an item is added to the map, its count is adjusted correctly.'''
mylist = {}
#empty list
self.assertEqual(mylist.get('a'), None)
#single add
add_frequency_map(mylist,'a')
add_frequency_map(mylist,'a')
add_frequency_map(mylist,'b')
self.assertEqual(mylist.get('a'), 2)
self.assertEqual(mylist.get('b'), 1)
#multi add
add_frequency_map(mylist,'a',2)
add_frequency_map(mylist,'b',9)
self.assertEqual(mylist.get('a'), 4)
self.assertEqual(mylist.get('b'), 10)
#subtract
add_frequency_map(mylist,'a',-1)
self.assertEqual(mylist.get('a'), 3)
def get_trie_from_list(self):
'''tests the add_frequency_map function.
Verify that a trie is correctly built when different types of lists are received.'''
pass
def test_read_word(self):
#todo: test case for very large files (load test performance)
#todo: test case for empty files
#todo: test case for non-text files
pass
def test_find_matches(self):
#todo: test case for very large input with large number of matches (performance)
#todo: test case for input with no matches (empty case)
#todo: test case for an input where all words are match-able
#todo: test case where all words are the same (weird edge case)
pass
if __name__ == '__main__':
unittest.main()