forked from satojkovic/algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_queue.py
More file actions
31 lines (27 loc) · 787 Bytes
/
Copy pathtest_queue.py
File metadata and controls
31 lines (27 loc) · 787 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
import unittest
from queue import *
from nose.tools import eq_
class TestQueue(unittest.TestCase):
def test_enque(self):
q = Queue()
eq_(q.is_empty(), True)
[q.enque(i) for i in [5, 13, 8, 2, 10]]
eq_(q.head.data, 5)
eq_(q.tail.data, 10)
eq_(q.is_empty(), False)
[q.enque(i) for i in [5, 'A']]
eq_(q.head.data, 5)
eq_(q.tail.data, 'A')
eq_(q.is_empty(), False)
def test_deque(self):
q = Queue()
eq_(q.is_empty(), True)
[q.enque(i) for i in [5, 13, 8]]
eq_(q.is_empty(), False)
eq_(q.deque(), 5)
eq_(q.deque(), 13)
eq_(q.deque(), 8)
eq_(q.deque(), None)
eq_(q.is_empty(), True)
if __name__ == "__main__":
unittest.main()