-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashmap_test.py
More file actions
43 lines (32 loc) · 1.08 KB
/
hashmap_test.py
File metadata and controls
43 lines (32 loc) · 1.08 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
import unittest
from hashmap import HashMap
class HashMapTest(unittest.TestCase):
def test_put_get(self):
hash_map = HashMap()
for key in range(1, 21):
value = key * 2
hash_map.put(key, value)
self.assertEqual(hash_map.get(key), value)
def test_put_size(self):
hash_map = HashMap()
size = 20
for key in range(1, size + 1):
value = key * 2
hash_map.put(key, value)
self.assertEqual(hash_map.size(), size)
for key in range(1, size + 1):
value = key * 2
hash_map.put(key, value)
self.assertEqual(hash_map.size(), size)
def test_put_remove(self):
hash_map = HashMap()
size = 20
for key in range(1, size + 1):
value = key * 2
hash_map.put(key, value)
self.assertEqual(hash_map.size(), size)
for key in range(1, size + 1):
hash_map.remove(key)
self.assertEqual(hash_map.size(), 0)
if __name__ == "__main__":
unittest.main()