Exemplo n.º 1
0
def test_llzip3():
    a = b = None
    for i in reversed(range(1, 3, 1)):
        a = Node(i, a)

    for i in reversed(range(2, 5, 1)):
        b = Node(i, b)

    zippedlist = zipLists(a, b)
    assert printList("", zippedlist) == '1 —> 2 —> 2 —> 3 —> 4 —> None'
Exemplo n.º 2
0
def test_llzip1():
    a = b = None
    for i in reversed(range(7, 12, 2)):
        a = Node(i, a)

    for i in reversed(range(2, 7, 2)):
        b = Node(i, b)

    zippedlist = zipLists(a, b)
    assert printList("", zippedlist) == '7 —> 2 —> 9 —> 4 —> 11 —> 6 —> None'
Exemplo n.º 3
0
def test_zip_one():
    ll_one = LinkedList()
    ll_one.append('test')
    ll_one.append(5)
    ll_one.append(7)
    ll_one.append(8)
    ll_one.append(9)

    ll_two = LinkedList()
    ll_two.append('two')
    ll_two.append(0)
    ll_two.append('a')
    ll_two.append(23)
    ll_two.append('k')
    actual = zipLists(ll_one, ll_two)
    excepted = '{ test } -> { two } -> { 5 } -> { 0 } -> { 7 } -> { a } -> { 8 } -> { 23 } -> { 9 } -> { k } -> Null'
    assert actual == excepted
Exemplo n.º 4
0
def test_zip_three():
    ll_one = LinkedList()
    ll_one.append('hi')
    ll_one.insert(5)
    ll_one.append(7)
    ll_one.insertBefore(8, 5)
    ll_one.append("ayman")

    ll_two = LinkedList()
    ll_two.append('y')
    ll_two.insert('a')
    ll_two.append('m')
    ll_two.insertAfter('m', 'a')
    ll_two.append('n')
    actual = zipLists(ll_one, ll_two)
    excepted = '{ 5 } -> { a } -> { hi } -> { y } -> { 7 } -> { m } -> { 5 } -> { a } -> { ayman } -> { n } -> Null'
    assert actual == excepted
Exemplo n.º 5
0
def test_zip_two():
    ll_one = LinkedList()
    ll_one.append('test')
    ll_one.insert(5)
    ll_one.append(7)
    ll_one.insertBefore(7, 8)
    ll_one.append(9)

    ll_two = LinkedList()
    ll_two.append('two')
    ll_two.append(0)
    ll_two.append(23)
    ll_two.insertAfter(23, 'a')
    ll_two.append('k')
    actual = zipLists(ll_one, ll_two)
    excepted = '{ 5 } -> { two } -> { test } -> { 0 } -> { 8 } -> { 23 } -> { 7 } -> { a } -> { 9 } -> { k } -> Null'
    assert actual == excepted