-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathstart.py
More file actions
55 lines (52 loc) · 994 Bytes
/
start.py
File metadata and controls
55 lines (52 loc) · 994 Bytes
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
"""
>>> q = Queue()
>>> q.empty()
True
>>> q.push_back(1)
>>> q.empty()
False
>>> q.pop_front()
1
>>> q.empty()
True
>>> q.push_back(2)
>>> q.push_back(3)
>>> q.push_back(4)
>>> q.empty()
False
>>> q.pop_front()
2
>>> q.pop_front()
3
>>> q.pop_front()
4
>>> q.empty()
True
>>> xin = 0
>>> expect_out = 0
>>> for x in xrange(1, 100):
... for y in xrange(x):
... q.push_back(xin)
... xin += 1
... xout = q.pop_front()
... if xout != expect_out:
... print "Failed: got %d, expected %d" % (xout, expect_out)
... break
... expect_out += 1
>>> while not q.empty():
... xout = q.pop_front()
... if xout != expect_out:
... print "Failed: got %d, expected %d" % (xout, expect_out)
... break
... expect_out += 1
"""
# TODO: copy this to solution.py when it is done next
if __name__ == "__main__":
import doctest
result = doctest.testmod()
if result.failed > 0:
print "Failed:", result
import sys
sys.exit(1)
else:
print "Success:", result