Exemple #1
0
def test_can_return_an_error_():
    newList = LinkedList()
    newList2 = LinkedList()
    answer = zip_lists(newList, newList2)

    expected = "Lists are empty"
    actual = answer

    assert expected == actual
def test_one_empty_ll1():
    ll1 = LinkedList()
    ll2 = create_list_append([5, 9, 4])
    # h=zip(ll1,ll2)
    # assert h.value is 5
    # assert h.next.value is 9
    assert str(zip(ll1, ll2)) == '{ 5 } -> { 9 } -> { 4 } -> None'
def test_one_empty_ll2():
    ll1 = create_list_append([1, 3, 2])
    ll2 = LinkedList()
    # h=zip(ll1,ll2)
    # assert h.value is 1
    # assert h.next.value is 3
    assert str(zip(ll1, ll2)) == '{ 1 } -> { 3 } -> { 2 } -> None'
Exemple #4
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
Exemple #5
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
Exemple #6
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
Exemple #7
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_append(lis):
    """helper function to create list by append with given values, used in test module"""
    my_l_list = LinkedList()
    for i in lis:
        my_l_list.append(i)
    return my_l_list
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
def test_two_empty_ll():
    ll1 = LinkedList()
    ll2 = LinkedList()
    h = zip(ll1, ll2)
    assert h.head == None