Beispiel #1
0
    def test_insert_first_element_to_empty_list(self):
        l = SingleLinkedList()
        l.insert_at_position(0, 'D')
        self._check_is_single_element_list(l)

        l = SingleLinkedList()
        l.insert_at_position(-1, 'D')
        self._check_is_single_element_list(l)
Beispiel #2
0
 def test_insert_at_position(self):
     l = SingleLinkedList([9, 6, 5])
     l.insert_at_position(0, -3)
     self._check_list(l, (-3, 9, 6, 5))
     l.insert_at_position(0, -4)
     self._check_list(l, (-4, -3, 9, 6, 5))
     l.insert_at_position(1, -5)
     self._check_list(l, (-4, -5, -3, 9, 6, 5))
     l.insert_at_position(4, -6)
     self._check_list(l, (-4, -5, -3, 9, -6, 6, 5))
     l.insert_at_position(7, -7)
     self._check_list(l, (-4, -5, -3, 9, -6, 6, 5, -7))