def test_traverse_back(self): cll = CircleLinkedList() cll.add(12) cll.add(99) cll.add(37) self.assertEqual([37, 99, 12], cll.traverse_back()) self.assertEqual(3, cll.count_links())
def test_traverse(self): cll = CircleLinkedList() cll.add(12) cll.add(99) cll.add(37) self.assertEqual([12, 99, 37], cll.traverse()) self.assertEqual(3, cll.count_links())
def test_get_link_values(self): cll = CircleLinkedList() cll.add(12) cll.add(99) cll.add(37) cll.add(66) items_expected = [12, 99, 37, 66] self.assertEqual(items_expected, cll.get_link_values()) self.assertEqual(4, cll.count_links())
def test_traverse_back_from(self): cll = CircleLinkedList() cll.add(12) cll.add(99) cll.add(37) cll.add(66) cll.add(44) self.assertEqual([66, 37, 99, 12], cll.traverse_back(66)) self.assertEqual(5, cll.count_links())
def test_traverse_from(self): cll = CircleLinkedList() cll.add(12) cll.add(99) cll.add(37) cll.add(66) cll.add(44) self.assertEqual([37, 66, 44], cll.traverse(37)) self.assertEqual(5, cll.count_links())
def test_get_link(self): cll = CircleLinkedList() cll.add(12) cll.add(99) cll.add(37) link = cll.get_link(99) self.assertEqual(99, link.value) self.assertEqual(37, link.next) self.assertEqual(12, link.prev) self.assertEqual(3, cll.count_links())
def test_delete_reconnect(self): cll = CircleLinkedList() cll.add(12) cll.add(99) cll.add(37) cll.add(66) cll.add(44) cll.delete(37, reconnect=True) self.assertEqual([12, 99, 66, 44], cll.traverse()) self.assertEqual([44, 66, 99, 12], cll.traverse_back()) self.assertEqual([12, 99, 66, 44], cll.get_link_values()) self.assertEqual(4, cll.count_links())
def test_update(self): cll = CircleLinkedList() cll.add(12) cll.add(99) cll.add(37) cll.add(66) cll.update(99, 88) traverse_expected = [12, 88, 37, 66] self.assertEqual(traverse_expected, cll.traverse()) traverse_expected.reverse() self.assertEqual(traverse_expected, cll.traverse_back()) # items_expected = [12, 37, 66, 88] # self.assertEqual(items_expected, cll.get_link_values()) self.assertEqual(4, cll.count_links())