Example #1
0
 def test_attempt_to_dequeue_more_than_num_nodes(self):
     q = QueueLinkedList([1, 2, 3])
     with pytest.raises(RuntimeError):
         q.dequeue()
         q.dequeue()
         q.dequeue()
         q.dequeue()
Example #2
0
 def test_contains_success(self):
     lst = list(range(10))
     q = QueueLinkedList(lst)
     for i in lst:
         assert i in q
Example #3
0
 def test_inequality_length(self):
     q1 = QueueLinkedList([1, 2, 3, 4])
     q2 = QueueLinkedList([1, 2, 3, 4, 5])
     assert q1 != q2
Example #4
0
 def test_inequality_type(self):
     q = QueueLinkedList([1, 2, 3, 4])
     lst = [1, 2, 3, 4]
     assert q != lst
Example #5
0
 def test_equality(self):
     q1 = QueueLinkedList([1, 2, 3, 4])
     q2 = QueueLinkedList([1, 2, 3, 4])
     assert q1 == q2
Example #6
0
 def test_str(self):
     q = QueueLinkedList([1, 2, 3, 4, 5])
     assert str(q) == "QueueLinkedList([1, 2, 3, 4, 5])"
Example #7
0
 def test_initialize_empty(self):
     q = QueueLinkedList()
Example #8
0
 def test_enqueue_start_filled(self):
     q = QueueLinkedList([1, 2, 3, 4])
     q.enqueue(1)
     q.enqueue(2)
     q.enqueue(3)
Example #9
0
 def test_len(self):
     lst = list(range(10))
     q = QueueLinkedList(lst)
     assert len(q) == len(lst)
Example #10
0
 def test_is_empty(self):
     q = QueueLinkedList()
     assert q.is_empty()
Example #11
0
 def test_iter(self):
     lst = list(range(10))
     q = QueueLinkedList(lst)
     for index, value in enumerate(q):
         assert value == lst[index]
Example #12
0
 def test_dequeue_start_filled(self):
     q = QueueLinkedList([1, 2, 3])
     q.dequeue()
     q.dequeue()
     q.dequeue()
Example #13
0
 def test_dequeue_start_empty(self):
     q = QueueLinkedList()
     with pytest.raises(RuntimeError):
         q.dequeue()
Example #14
0
 def test_contains_negative(self):
     q = QueueLinkedList([1, 2, 3, 4])
     assert 99 not in q
Example #15
0
 def test_iter_random_numbers(self):
     random_numbers = np.random.randint(10, size=10)
     q = QueueLinkedList(random_numbers)
     for index, value in enumerate(q):
         assert value == random_numbers[index]
Example #16
0
 def test_initialize_filled(self):
     q = QueueLinkedList([1, 2, 3, 4])
Example #17
0
 def test_enqueue_start_empty(self):
     q = QueueLinkedList()
     q.enqueue(1)
     q.enqueue(2)
     q.enqueue(3)