Ejemplo n.º 1
0
    def test_circle_linked(self):
        cll = CircleLinkedList()
        cll.add(12)
        cll.add(24)
        cll.add(48)
        cll.add(96)

        link_first = cll.get_link(12)
        self.assertEqual(None, link_first.prev)
        self.assertEqual(24, link_first.next)
        self.assertEqual(None, link_first.start)
        self.assertEqual(96, link_first.end)

        link_middle = cll.get_link(24)
        self.assertEqual(12, link_middle.prev)
        self.assertEqual(48, link_middle.next)
        self.assertEqual(None, link_middle.start)
        self.assertEqual(None, link_middle.end)

        link_last = cll.get_link(48)
        self.assertEqual(24, link_last.prev)
        self.assertEqual(96, link_last.next)
        self.assertEqual(None, link_last.start)
        self.assertEqual(None, link_last.end)

        link_last = cll.get_link(96)
        self.assertEqual(48, link_last.prev)
        self.assertEqual(None, link_last.next)
        self.assertEqual(12, link_last.start)
        self.assertEqual(None, link_last.end)

        self.assertEqual(False, cll.empty())
Ejemplo n.º 2
0
 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())