forked from HU-CS201-master/chap01
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_uset.py
55 lines (47 loc) · 1.18 KB
/
test_uset.py
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
53
54
55
from uset import USet
def test_add():
uset = USet()
assert uset.add(1, 10) == True
assert uset.add(2, 20) == True
assert uset.add(1, 10) == False
def test_remove():
uset = USet()
uset.add(1, 10)
uset.add(2, 20)
assert uset.remove(1) == (1,10)
assert uset.remove(1) == None
assert uset.remove(2) == (2,20)
def test_size():
uset = USet()
assert uset.size() == 0
uset.add(1, 10)
assert uset.size() == 1
uset.add(2, 20)
assert uset.size() == 2
uset.add(2, 20)
assert uset.size() == 2
uset.remove(10)
assert uset.size() == 2
def test_keys():
uset = USet()
assert uset.keys() == []
uset.add(1, 10)
assert uset.keys() == [1]
uset.add(2, 20)
assert uset.keys() == [1,2]
uset.remove(2)
assert uset.keys() == [1]
uset.remove(1)
assert uset.keys() == []
def test_find():
uset = USet()
uset.add(1, 10)
uset.add(2, 20)
assert uset.find(1) == (1,10)
assert uset.size() == 2
assert uset.find(1) == (1,10)
assert uset.size() == 2
assert uset.find(2) == (2,20)
assert uset.size() == 2
assert uset.find(10) == None
assert uset.size() == 2