예제 #1
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
예제 #2
0
 def test_reverse(self):
     mylist = LinkedList()
     mylist.add(1)
     mylist.add(2)
     mylist.add(3)
     assert mylist.toList() == [3, 2, 1]
     mylist.reverse()
     assert mylist.toList() == [1, 2, 3]
     mylist.reverse()
     assert mylist.toList() == [3, 2, 1]
예제 #3
0
 def test_insert_middle_full_list(self):
     mylist = LinkedList()
     mylist.add(1)
     mylist.add(2)
     mylist.add(3)
     mylist.add(4)
     mylist.insert(2, 17)
     mylist.reverse()
     mylist.reverse()
     assert mylist.toList() == [4, 3, 17, 2, 1]
     assert mylist.size() == 5
예제 #4
0
 def test_reverse_empty(self):
     mylist = LinkedList()
     mylist.reverse()
     assert mylist.toList() == []