Пример #1
0
 def test_del(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     list_1.push(2)
     list_1.push(2)
     list_1.delete(2)
     self.assertEqual(list_1.len(), 2)
Пример #2
0
 def test_delete_elem_only_multi(self):
     test_list = DoubleLinkedList()
     for i in range(5):
         test_list.push(2)
     self.assertEqual(test_list.len(), 5)
     self.assertEqual(test_list.contains(2), 5)
     test_list.delete(2)
     self.assertEqual(test_list.len(), 0)
     self.assertEqual(test_list.contains(2), 0)
Пример #3
0
 def test_delete_elem_multi(self):
     test_list = DoubleLinkedList()
     for i in range(3):
         test_list.push(i)
     test_list.push(1)
     for i in range(3):
         test_list.push(i)
     self.assertEqual(test_list.len(), 7)
     self.assertEqual(test_list.contains(1), 3)
     test_list.delete(1)
     self.assertEqual(test_list.len(), 4)
     self.assertEqual(test_list.contains(1), 0)
Пример #4
0
 def test_delete_elem_only(self):
     test_list = DoubleLinkedList()
     test_list.push("test")
     self.assertEqual(test_list.len(), 1)
     test_list.delete("test")
     self.assertEqual(test_list.len(), 0)
Пример #5
0
 def test_delete_empty(self):
     test_list = DoubleLinkedList()
     self.assertEqual(test_list.delete("test"), "no such element")