예제 #1
0
    def test_clean_list_with_one_element(self):
        l = LinkedList()
        h = Node(1)

        l.add_in_tail(h)

        self.assertEqual(l.len(), 1)
        self.assertEqual(l.head, h)
        self.assertEqual(l.tail, h)

        l.clean()

        self.assertEqual(l.len(), 0)
        self.assertEqual(l.head, None)
        self.assertEqual(l.tail, None)
예제 #2
0
    def test_clean(self):
        l = LinkedList()
        h = Node(1)
        t = Node(4)

        for node in [h, Node(2), Node(3), t]:
            l.add_in_tail(node)

        self.assertEqual(l.len(), 4)
        self.assertEqual(l.head, h)
        self.assertEqual(l.tail, t)

        l.clean()

        self.assertEqual(l.len(), 0)
        self.assertEqual(l.head, None)
        self.assertEqual(l.tail, None)