def test_size(self):
     """
     Tests that the size of a linked list is returned
     """
     l = LinkedList()
     self.assertEqual(l.size(), 0)
     l.insert_first(1)
     l.insert_first(1)
     l.insert_first(1)
     l.insert_first(1)
     self.assertEqual(l.size(), 4)
 def test_clear(self):
     """
     Test that a list is emptied
     """
     l = LinkedList()
     self.assertEqual(l.size(), 0)
     l.insert_first(1)
     l.insert_first(1)
     l.insert_first(1)
     l.insert_first(1)
     self.assertEqual(l.size(), 4)
     l.clear()
     self.assertEqual(l.size(), 0)
 def test_remove_first_size_3(self):
     """
     Tests the removal of first node in list when list has three nodes 
     """
     l = LinkedList()
     l.insert_first("c")
     l.insert_first("b")
     l.insert_first("a")
     l.remove_first()
     self.assertEqual(l.size(), 2)
     self.assertEqual(l.get_first().data, "b")
     l.remove_first()
     self.assertEqual(l.size(), 1)
     self.assertEqual(l.get_first().data, "c")
 def test_insert_last(self):
     """
     Tests adding a node to the end of a list
     """
     l = LinkedList()
     l.insert_first("a")
     l.insert_last("b")
     self.assertEqual(l.size(), 2)
     self.assertEqual(l.get_last().data, "b")
 def test_remove_first_size_1(self):
     """
     Tests the removal of first node in list when list has one node
     """
     l = LinkedList()
     l.insert_first("a")
     l.remove_first()
     self.assertEqual(l.size(), 0)
     self.assertEqual(l.get_first(), None)
 def test_remove_last_3(self):
     """
     Tests the removal of last node in a list with three nodes 
     """
     l = LinkedList()
     l.insert_first("c")
     l.insert_first("b")
     l.insert_first("a")
     l.remove_last()
     self.assertEqual(l.size(), 2)
     self.assertEqual(l.get_last().data, "b")
 def test_remove_last_2(self):
     """
     Tests the removal of last node in a list with two nodes 
     """
     l = LinkedList()
     l.insert_first("b")
     l.insert_first("a")
     l.remove_last()
     self.assertEqual(l.size(), 1)
     self.assertEqual(l.get_last().data, "a")
     self.assertEqual(l.get_last().next, None)