示例#1
0
 def test_delete(self):
     cll = CircleLinkedList()
     cll.add(12)
     cll.add(99)
     cll.add(37)
     cll.add(66)
     cll.add(44)
     cll.delete(37)
     self.assertEqual([12, 99], cll.traverse())
     self.assertEqual([66, 44], cll.traverse(66))
     self.assertEqual([99, 12], cll.traverse_back())
     self.assertEqual([44, 66], cll.traverse_back(44))
     self.assertEqual([12, 99, 66, 44], cll.get_link_values())
     self.assertEqual(4, cll.count_links())
示例#2
0
 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())
示例#3
0
 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())
示例#4
0
 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())