forked from HU-CS201-master/chap01
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_sset.py
57 lines (49 loc) · 1.24 KB
/
test_sset.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
56
57
from sset import SSet
def test_add():
sset = SSet()
assert sset.add(1, 10) == True
assert sset.add(2, 20) == True
assert sset.add(1, 10) == False
def test_remove():
sset = SSet()
sset.add(1, 10)
sset.add(2, 20)
assert sset.remove(1) == (1,10)
assert sset.remove(1) == None
assert sset.remove(2) == (2,20)
def test_size():
sset = SSet()
assert sset.size() == 0
sset.add(1, 10)
assert sset.size() == 1
sset.add(2, 20)
assert sset.size() == 2
sset.add(2, 20)
assert sset.size() == 2
sset.remove(10)
assert sset.size() == 2
def test_keys():
sset = SSet()
assert sset.keys() == []
sset.add(1, 10)
assert sset.keys() == [1]
sset.add(2, 20)
assert sset.keys() == [1,2]
sset.remove(2)
assert sset.keys() == [1]
sset.remove(1)
assert sset.keys() == []
def test_find():
sset = SSet()
sset.add(1, 10)
sset.add(2, 20)
assert sset.find(1) == (1,10)
assert sset.size() == 2
assert sset.find(1) == (1,10)
assert sset.size() == 2
assert sset.find(2) == (2,20)
assert sset.size() == 2
assert sset.find(10) == None
assert sset.size() == 2
assert sset.find(1.5) == (2,20)
assert sset.size() == 2