def test_get_at_index(self): dll = DoublyLinkedList(['A', 'B', 'C']) assert dll.get_at_index(0) == 'A' assert dll.get_at_index(1) == 'B' assert dll.get_at_index(2) == 'C' with self.assertRaises(ValueError): dll.get_at_index(3) dll.get_at_index(-1)
def test_get_at_index(self): ll = DoublyLinkedList(['A', 'B', 'C']) assert ll.get_at_index(0) == 'A' # head item assert ll.get_at_index(1) == 'B' # middle item assert ll.get_at_index(2) == 'C' # tail item with self.assertRaises(ValueError): ll.get_at_index(3) # index too high with self.assertRaises(ValueError): ll.get_at_index(-1) # index too low