Exemplo n.º 1
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.º 2
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
Exemplo n.º 3
0
def test_can_successfully_zip_two_linked_lists():
    newList = LinkedList()
    newList.insert(5)
    newList.insert(3)
    newList.insert(1)

    newList2 = LinkedList()
    newList2.insert(6)
    newList2.insert(4)
    newList2.insert(2)

    answer = zip_lists(newList, newList2)

    expected = ['1', '2', '3', '4', '5', '6']
    actual = [
        answer.headVal.nodeVal, answer.headVal.nextVal.nodeVal,
        answer.headVal.nextVal.nextVal.nodeVal,
        answer.headVal.nextVal.nextVal.nextVal.nodeVal,
        answer.headVal.nextVal.nextVal.nextVal.nextVal.nodeVal,
        answer.headVal.nextVal.nextVal.nextVal.nextVal.nextVal.nodeVal
    ]

    assert expected == actual
def create_list_insert(lis):
    """helper function to create list by insert with given values, used in test module"""
    my_l_list = LinkedList()
    for i in lis:
        my_l_list.insert(i)
    return my_l_list