-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_queue.py
53 lines (39 loc) · 1.02 KB
/
test_queue.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
from queue import Queue
import pytest
def test_enqueue_first_item():
queue = Queue()
queue.enqueue("Bacon")
assert queue.last.val == "Bacon"
def test_enqueue_multi_last_item():
queue = Queue()
queue.enqueue("Bacon")
queue.enqueue("Steak")
queue.enqueue("Beer")
assert queue.last.val == "Beer"
def test_dequeue_empty():
queue = Queue()
with pytest.raises(ValueError):
queue.dequeue()
def test_dequeue():
queue = Queue()
queue.enqueue("Bacon")
assert queue.dequeue() == "Bacon"
def test_dequeue_multi():
queue = Queue()
queue.enqueue("Bacon")
queue.enqueue("Beer")
assert queue.dequeue() == "Bacon"
assert queue.first.val == "Beer"
def test_size():
queue = Queue()
queue.enqueue("Bacon")
queue.enqueue("Beer")
assert queue.size() == 2
def test_size_with_remove():
queue = Queue()
queue.enqueue("Bacon")
queue.enqueue("Beer")
queue.enqueue("Cow")
queue.enqueue("Whiskey")
queue.dequeue()
assert queue.size() == 3