Exemplo n.º 1
0
 def test_remove(self):
     instance = FrontLinkedList()
     for i in range(1, 6):
         instance.add(i)
     self.assertEqual(5, instance.size())
     instance.remove(3)
     self.assertEqual(4, instance.size())
     for item in instance:
         self.assertNotEqual(3, item.data())
Exemplo n.º 2
0
 def test_remove_deletes_the_first_occurrence_from_the_front(self):
     instance = FrontLinkedList()
     instance.add("4")
     instance.add("3")
     instance.add("2")
     instance.add("1")
     instance.add("4")
     instance.add("0")
     instance.remove("4")
     counter = 0
     next_item = None
     for item in instance:
         if item.data() == "4":
             counter += 1
             next_item = item.next()
     self.assertEqual(1, counter)
     self.assertFalse(next_item)
 def test_remove_deletes_the_first_occurrence_from_the_front(self):
     instance = FrontLinkedList()
     instance.add("4")
     instance.add("3")
     instance.add("2")
     instance.add("1")
     instance.add("4")
     instance.add("0")
     instance.remove("4")
     counter = 0
     next_item = None
     for item in instance:
         if item.data() == "4":
             counter += 1
             next_item = item.next()
     self.assertEqual(1, counter)
     self.assertFalse(next_item)
Exemplo n.º 4
0
 def test_remove(self):
     instance = FrontLinkedList()
     # No elements
     instance.remove(1)
     self.assertEqual(0, instance.size())
     # One element, which is removed
     instance.add(2)
     self.assertEqual(1, instance.size())
     instance.remove(2)
     self.assertEqual(0, instance.size())
     # One element, which is not removed
     instance.add(5)
     self.assertEqual(1, instance.size())
     instance.remove(2)
     self.assertEqual(1, instance.size())
     instance.remove(5)  # clear list
     # Two elements
     instance.add(2)
     instance.add("x")
     self.assertEqual(2, instance.size())
     instance.remove(2)
     self.assertEqual(1, instance.size())
     # Many elements        
     for i in range(1, 6):
         instance.add(i)
     self.assertEqual(6, instance.size())
     instance.remove("x")
     self.assertEqual(5, instance.size())
     for item in instance:
         self.assertNotEqual("x", item.data())
 def test_remove(self):
     instance = FrontLinkedList()
     # No elements
     instance.remove(1)
     self.assertEqual(0, instance.size())
     # One element, which is removed
     instance.add(2)
     self.assertEqual(1, instance.size())
     instance.remove(2)
     self.assertEqual(0, instance.size())
     # One element, which is not removed
     instance.add(5)
     self.assertEqual(1, instance.size())
     instance.remove(2)
     self.assertEqual(1, instance.size())
     instance.remove(5)  # clear list
     # Two elements
     instance.add(2)
     instance.add("x")
     self.assertEqual(2, instance.size())
     instance.remove(2)
     self.assertEqual(1, instance.size())
     # Many elements
     for i in range(1, 6):
         instance.add(i)
     self.assertEqual(6, instance.size())
     instance.remove("x")
     self.assertEqual(5, instance.size())
     for item in instance:
         self.assertNotEqual("x", item.data())