Beispiel #1
0
 def test_delete_missing_length(self):
     ll = LinkedList.get_linked_list(1, 2, 3)
     ll.delete_val(4)
     self.assertEqual(len(ll), 3)
Beispiel #2
0
 def test_delete_head(self):
     ll = LinkedList.get_linked_list(1, 2, 3)
     ll.delete_val(1)
     self.assertTrue(ll.head.data == 2)
Beispiel #3
0
 def test_delete_missing_value(self):
     ll = LinkedList.get_linked_list(1, 2, 3)
     ll.delete_val(4)
     self.assertFalse(ll.find(4))
Beispiel #4
0
 def test_delete_oob_index(self):
     with self.assertRaises(IndexError):
         LinkedList.get_linked_list(1).delete_index(1)
Beispiel #5
0
 def test_delete_value_empty(self):
     self.assertIsNone(LinkedList().delete_val(0))
Beispiel #6
0
 def test_find_matching_value(self):
     ll = LinkedList.get_linked_list(1, 2, 3)
     self.assertTrue(ll.find(2))
Beispiel #7
0
 def test_delete_neg_index_first(self):
     ll = LinkedList.get_linked_list(1, 2)
     ll.delete_index(-2)
     self.assertFalse(ll.find(1))
Beispiel #8
0
 def test_delete_index_existing_length(self):
     ll = LinkedList.get_linked_list(1, 2)
     ll.delete_index(1)
     self.assertEqual(len(ll), 1)
Beispiel #9
0
 def test_delete_index_existing_value(self):
     ll = LinkedList.get_linked_list(1, 2)
     ll.delete_index(1)
     self.assertFalse(ll.find(2))
Beispiel #10
0
 def test_add_non_empty_value(self):
     ll = LinkedList.get_linked_list(1, 2)
     ll.add(5)
     self.assertTrue(ll.find(5))
Beispiel #11
0
 def test_delete_index_empty(self):
     ll = LinkedList()
     ll.delete_index(2)
     self.assertEqual(len(ll), 0)
Beispiel #12
0
 def test_add_empty_value(self):
     ll = LinkedList()
     ll.add(5)
     self.assertTrue(ll.find(5))
Beispiel #13
0
 def test_add_non_empty_length(self):
     ll = LinkedList.get_linked_list(1, 2)
     ll.add(5)
     self.assertEqual(len(ll), 3)
Beispiel #14
0
 def test_add_empty_length(self):
     ll = LinkedList()
     ll.add(5)
     self.assertEqual(len(ll), 1)
Beispiel #15
0
 def test_delete_match_value(self):
     ll = LinkedList.get_linked_list(1, 2, 3)
     ll.delete_val(2)
     self.assertFalse(ll.find(2))
Beispiel #16
0
 def test_find_empty(self):
     ll = LinkedList()
     self.assertFalse(ll.find(1))
Beispiel #17
0
 def test_delete_match_length(self):
     ll = LinkedList.get_linked_list(1, 2, 3)
     ll.delete_val(2)
     self.assertEqual(len(ll), 2)
Beispiel #18
0
 def test_find_missing_value(self):
     ll = LinkedList.get_linked_list(1, 2, 3)
     self.assertFalse(ll.find(4))