def test_insert_3(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n1)
        linked_list.add_in_tail(self.n2)
        linked_list.add_in_tail(self.n3)

        linked_list.insert(self.n2, self.n6)

        self.assertEqual(self.n2.next, self.n6)
        self.assertEqual(self.n6.next, self.n3)
    def test_insert_2(self):
        linked_list = LinkedList()
        linked_list.add_in_tail(self.n1)
        linked_list.add_in_tail(self.n2)
        linked_list.add_in_tail(self.n3)

        linked_list.insert(self.n3, self.n4)

        self.assertEqual(self.n3.next, self.n4)
        self.assertEqual(linked_list.tail, self.n4)
    def test_insert_1(self):
        linked_list = LinkedList()

        linked_list.insert(None, self.n1)
        self.assertEqual(linked_list.head, self.n1)
        self.assertEqual(linked_list.tail, self.n1)
Beispiel #4
0
from list import LinkedList

import time

import os

if __name__ == '__main__':
    my = LinkedList()
    my.insert(1)
    my.insert(2)
    my.insert(3)
    my.insert(5)
    my.insert(7)
    #my.disp()
    my.insertAfter(6,7)
    #my.disp()
    my.insertAfter(4,5)
    #my.disp()
    my.deleteBeg()
    my.insertEnd(0)
    my.disp()
    my.deleteEnd()
    my.disp()
    time.sleep(5)
    os.system("clear")
    my.deleteAny(5)
    my.disp()