示例#1
0
 def test_traverse_back(self):
     dll = DoubleLinkedList()
     dll.add(12)
     dll.add(99)
     dll.add(37)
     self.assertEqual([37, 99, 12], dll.traverse_back())
     self.assertEqual(3, dll.count_links())
示例#2
0
 def test_traverse(self):
     dll = DoubleLinkedList()
     dll.add(12)
     dll.add(99)
     dll.add(37)
     self.assertEqual([12, 99, 37], dll.traverse())
     self.assertEqual(3, dll.count_links())
示例#3
0
 def test_traverse_from(self):
     dll = DoubleLinkedList()
     dll.add(12)
     dll.add(99)
     dll.add(37)
     dll.add(66)
     dll.add(44)
     self.assertEqual([37, 66, 44], dll.traverse(37))
     self.assertEqual(5, dll.count_links())
示例#4
0
 def test_get_link_values(self):
     dll = DoubleLinkedList()
     dll.add(12)
     dll.add(99)
     dll.add(37)
     dll.add(66)
     items_expected = [12, 99, 37, 66]
     self.assertEqual(items_expected, dll.get_link_values())
     self.assertEqual(4, dll.count_links())
示例#5
0
 def test_traverse_back_from(self):
     dll = DoubleLinkedList()
     dll.add(12)
     dll.add(99)
     dll.add(37)
     dll.add(66)
     dll.add(44)
     self.assertEqual([66, 37, 99, 12], dll.traverse_back(66))
     self.assertEqual(5, dll.count_links())
示例#6
0
 def test_get_link(self):
     dll = DoubleLinkedList()
     dll.add(12)
     dll.add(99)
     dll.add(37)
     link = dll.get_link(99)
     self.assertEqual(99, link.value)
     self.assertEqual(37, link.next)
     self.assertEqual(12, link.prev)
     self.assertEqual(3, dll.count_links())
示例#7
0
 def test_delete_reconnect(self):
     dll = DoubleLinkedList()
     dll.add(12)
     dll.add(99)
     dll.add(37)
     dll.add(66)
     dll.add(44)
     dll.delete(37, reconnect=True)
     self.assertEqual([12, 99, 66, 44], dll.traverse())
     self.assertEqual([44, 66, 99, 12], dll.traverse_back())
     self.assertEqual([12, 99, 66, 44], dll.get_link_values())
     self.assertEqual(4, dll.count_links())
示例#8
0
 def test_update(self):
     dll = DoubleLinkedList()
     dll.add(12)
     dll.add(99)
     dll.add(37)
     dll.add(66)
     dll.update(99, 88)
     traverse_expected = [12, 88, 37, 66]
     self.assertEqual(traverse_expected, dll.traverse())
     traverse_expected.reverse()
     self.assertEqual(traverse_expected, dll.traverse_back())
     # items_expected = [12, 37, 66, 88]
     # self.assertEqual(items_expected, dll.get_link_values())
     self.assertEqual(4, dll.count_links())