예제 #1
0
 def test_many_items_last(self):
     mylist = LinkedList()
     mylist.add(1)
     mylist.add(2)
     mylist.add(3)
     assert mylist.pop(-1) == 1
     assert mylist.size() == 2
예제 #2
0
 def test_many_items_middle(self):
     mylist = LinkedList()
     mylist.add(1)
     mylist.add(2)
     mylist.add(3)
     assert mylist.pop(-2) == 2
     assert mylist.size() == 2
예제 #3
0
 def test_many_items_first(self):
     mylist = LinkedList()
     mylist.add(1)
     mylist.add(2)
     mylist.add(3)
     mylist.reverse()
     mylist.reverse()
     assert mylist.pop(0) == 3
     assert mylist.size() == 2
예제 #4
0
 def test_one_item_last(self):
     mylist = LinkedList()
     mylist.add(2)
     assert mylist.pop(-1) == 2
     assert mylist.isEmpty()
예제 #5
0
 def test_index_out_of_range_low(self):
     with pytest.raises(IndexError):
         mylist = LinkedList()
         mylist.add(2)
         mylist.pop(-100)
예제 #6
0
 def test_non_integer_pos(self):
     with pytest.raises(TypeError):
         mylist = LinkedList()
         mylist.add(3)
         mylist.pop(.4)
예제 #7
0
 def test_empty_list(self):
     with pytest.raises(IndexError):
         mylist = LinkedList()
         mylist.pop()