def test_seq_constructor(): l = SingleLinkedList([0, 1, 2, 3, 4]) assert l.length == 5 for i in range(5): assert i == l.pop_front()
def test_pop_front(): l = SingleLinkedList() for i in range(5): l.push_back(i) for i in range(4): assert l.pop_front() == i assert l.head.data == i + 1 assert l.head.data == l.tail.data assert l.tail.data == 4 l.pop_front() assert l.head == None assert l.tail == None
def test_reverse(): l = SingleLinkedList() for i in range(5): l.push_front(i) l.reverse() assert l.head.data == 0 assert l.tail.data == 4 assert l.tail.next == None for i in range(5): assert l.pop_front() == i