-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_library.py
38 lines (24 loc) · 1.09 KB
/
test_library.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
import unittest
import library
class TestBufferQueue(unittest.TestCase):
def setUp(self):
self.maxsize = 10
self.queue = library.BufferQueue(maxsize=self.maxsize)
def test_bufferQueue(self):
self.assertEqual(self.queue.isempty(), True, 'Not empty.')
self.assertRaises(IndexError, self.queue.pop)
for element in range(self.maxsize):
self.queue.put(element)
self.assertEqual(self.queue.isempty(), False, 'Empty.')
self.assertEqual(len(self.queue), self.maxsize, 'Wrong size.')
self.assertEqual(self.queue.pop(), self.maxsize - 1, "Wrong element.")
self.assertEqual(len(self.queue), self.maxsize - 1, 'Wrong size.')
self.queue.put(self.maxsize - 1)
self.queue.put(self.maxsize)
self.assertEqual(len(self.queue), self.maxsize, 'Wrong size.')
self.assertEqual(self.queue.pop(), self.maxsize, "Wrong element.")
self.assertEqual(len(self.queue), self.maxsize - 1, 'Wrong size.')
def tearDown(self):
del self.queue
if __name__ == '__main__':
unittest.main()