示例#1
0
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()
示例#2
0
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
示例#3
0
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