Beispiel #1
0
 def test_attempt_to_pop_more_than_num_nodes(self):
     q = StackLinkedList([1, 2, 3])
     with pytest.raises(RuntimeError):
         q.pop()
         q.pop()
         q.pop()
         q.pop()
Beispiel #2
0
 def test_contains_success(self):
     lst = list(range(10))
     q = StackLinkedList(lst)
     for i in lst:
         assert i in q
Beispiel #3
0
 def test_inequality_length(self):
     q1 = StackLinkedList([1, 2, 3, 4])
     q2 = StackLinkedList([1, 2, 3, 4, 5])
     assert q1 != q2
Beispiel #4
0
 def test_inequality_type(self):
     q = StackLinkedList([1, 2, 3, 4])
     lst = [1, 2, 3, 4]
     assert q != lst
Beispiel #5
0
 def test_equality(self):
     q1 = StackLinkedList([1, 2, 3, 4])
     q2 = StackLinkedList([1, 2, 3, 4])
     assert q1 == q2
Beispiel #6
0
 def test_str(self):
     q = StackLinkedList([1, 2, 3, 4, 5])
     assert str(q) == "StackLinkedList([1, 2, 3, 4, 5])"
Beispiel #7
0
 def test_initialize_start_empty(self):
     stack = StackLinkedList()
Beispiel #8
0
 def test_push_start_filled(self):
     stack = StackLinkedList([1, 2, 3])
     stack.push(1)
     stack.push(2)
     stack.push(3)
Beispiel #9
0
 def test_is_empty(self):
     q = StackLinkedList()
     assert q.is_empty()
Beispiel #10
0
 def test_iter_random_numbers(self):
     random_numbers = np.random.randint(10, size=10)
     q = StackLinkedList(random_numbers)
     for index, value in enumerate(q):
         assert value == random_numbers[index]
Beispiel #11
0
 def test_iter(self):
     lst = list(range(10))
     q = StackLinkedList(lst)
     for index, value in enumerate(q):
         assert value == lst[index]
Beispiel #12
0
 def test_pop_start_filled(self):
     q = StackLinkedList([1, 2, 3])
     q.pop()
     q.pop()
     q.pop()
Beispiel #13
0
 def test_pop_start_empty(self):
     q = StackLinkedList()
     with pytest.raises(RuntimeError):
         q.pop()
Beispiel #14
0
 def test_contains_negative(self):
     q = StackLinkedList([1, 2, 3, 4])
     assert 99 not in q
Beispiel #15
0
 def test_len(self):
     lst = list(range(10))
     q = StackLinkedList(lst)
     assert len(q) == len(lst)
Beispiel #16
0
 def test_initialize_start_filled(self):
     stack = StackLinkedList([1, 2, 3])
Beispiel #17
0
 def test_push_start_empty(self):
     stack = StackLinkedList()
     stack.push(1)
     stack.push(2)
     stack.push(3)