Example #1
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)
Example #2
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)
 def test_contains_true(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     list_1.push(2)
     list_1.push(3)
     list_1.push(4)
     self.assertEqual(list_1.contains(3), True)
Example #4
0
 def test_contains_multi_elem(self):
     test_list = DoubleLinkedList()
     for i in range(10):
         test_list.push(i)
     for i in range(3):
         test_list.push(5)
     self.assertEqual(test_list.len(), 13)
     self.assertEqual(test_list.contains(5), 4)
Example #5
0
 def test_not_contains_elem(self):
     test_list = DoubleLinkedList()
     for i in range(10):
         test_list.push(i)
     self.assertEqual(test_list.len(), 10)
     self.assertEqual(test_list.contains(14), 0)
Example #6
0
 def test_contains_only_multi_elem(self):
     test_list = DoubleLinkedList()
     for i in range(10):
         test_list.push(1)
     self.assertEqual(test_list.len(), 10)
     self.assertEqual(test_list.contains(1), 10)
Example #7
0
 def test_contains_only_elem(self):
     test_list = DoubleLinkedList()
     test_list.push("test")
     self.assertEqual(test_list.len(), 1)
     self.assertEqual(test_list.contains("test"), 1)
Example #8
0
 def test_contains_empty(self):
     test_list = DoubleLinkedList()
     self.assertEqual(test_list.contains("test"), 0)
 def test_contains_false(self):
     list_1 = DoubleLinkedList()
     list_1.push(1)
     list_1.push(2)
     list_1.push(3)
     self.assertEqual(list_1.contains(0), False)