def test_remove_duplicates():
    middle = linkednode.LinkedNode(10)
    middle += 30
    middle += 40
    middle += 50
    middle += 50
    middle += 50
    middle += 50
    middle += 60
    middle = linkednode_exercises.remove_duplicates(middle)
    assert linkednode.print_list(middle) == '10, 30, 40, 50, 60'

    beginning = linkednode.LinkedNode(10)
    beginning += 10
    beginning += 10
    beginning += 10
    beginning += 20
    beginning += 30
    beginning = linkednode_exercises.remove_duplicates(beginning)
    assert linkednode.print_list(beginning) == '10, 20, 30'

    ending = linkednode.LinkedNode(10)
    ending += 20
    ending += 30
    ending += 30
    ending = linkednode_exercises.remove_duplicates(beginning)
    assert linkednode.print_list(ending) == '10, 20, 30'

    jumpy = linkednode.LinkedNode(1)
    jumpy += 2
    jumpy += 1
    jumpy += 2
    jumpy += 3
    jumpy += 1
    jumpy = linkednode_exercises.remove_duplicates(jumpy)
    assert linkednode.print_list(jumpy) == '1, 2, 3'

    mess = linkednode.LinkedNode(10)
    mess += 10
    mess += 10
    mess += 20
    mess += 30
    mess += 30
    mess += 40
    mess += 50
    mess += 10
    mess += 60
    mess += 60
    mess += 30
    mess = linkednode_exercises.remove_duplicates(mess)
    assert linkednode.print_list(mess) == '10, 20, 30, 40, 50, 60'
Example #2
0
def test_insert():
    list = LinkedNode(10)
    list += 30
    list += 40
    list += 50
    assert repr(list) == '10'
    assert repr(list.next_node.key) == '30'
    assert print_list(list) == '10, 30, 40, 50'
Example #3
0
def test_delete():
    list = LinkedNode(10)
    list += 20
    list += 30
    list += 40
    list = delete_item(list, 30)
    assert print_list(list) == '10, 20, 40'

    list = delete_item(list, 10)
    assert print_list(list) == '20, 40'

    list = delete_item(list, 50)
    assert print_list(list) == '20, 40'

    list = delete_item(list, 40)
    assert print_list(list) == '20'

    list = delete_item(list, 20)
    assert type(list) == NoneType