def test_add_several_first_elements(self): dll = DoublyLinkedList() dll.add_first(10) dll.add_first(5) dll.add_first(3) self.assertEqual(dll.count, 3) self.assertEqual(list(dll), [3, 5, 10])
def test_remove_last_one_element(self): """ Should make the list empty """ dll = DoublyLinkedList() dll.add_first(5) first_el = dll.remove_last() self.assertEqual(first_el, 5) self.assertEqual(dll.count, 0) self.assertEqual(list(dll), [])
def test_remove_last_several_elements(self): dll = DoublyLinkedList() dll.add_first(10) dll.add_first(9) dll.add_first(8) last_el = dll.remove_last() self.assertEqual(last_el, 10) self.assertEqual(dll.count, 2) self.assertEqual(list(dll), [8, 9])
def test_add_first_empty_list_should_add_element(self): dll = DoublyLinkedList() dll.add_first(5) self.assertEqual(dll.count, 1) self.assertEqual(list(dll), [5])