def test_append_several(): ll = LinkedList() ll.append(1) ll.append(2) ll.append(3) assert ll.includes(3) assert str(ll) == '{ 1 } -> { 2 } -> { 3 } -> NULL'
def test_append_node_to_list(): link_list = LinkedList() link_list.insert('b') link_list.insert('c') link_list.append('a') actual = str(link_list) expected = "{c}->{b}->{a}->NULL" assert actual == expected
def test_insert_before_middle(): link_list = LinkedList() link_list.insert('c') link_list.insert('d') link_list.append('b') link_list.append('a') link_list.insertBefore('b', 'yasss') actual = str(link_list) expected = "{d}->{c}->{yasss}->{b}->{a}->NULL" assert actual == expected
def test_insert_after_last(): link_list = LinkedList() link_list.insert('c') link_list.insert('d') link_list.append('b') link_list.append('a') link_list.insertAfter('a', 'yasss') actual = str(link_list) expected = "{d}->{c}->{b}->{a}->{yasss}->NULL" assert actual == expected
def test_same_size_lists(): list1 = LinkedList() list1.append(1) list1.append(2) list1.append(3) list2 = LinkedList() list2.append(4) list2.append(5) list2.append(6) actual = str(zipLists(list1, list2)) expected = "{1}->{4}->{2}->{5}->{3}->{6}->NULL" assert actual == expected
def test_list1_longer_plus(): list1 = LinkedList() list1.append(1) list1.append(2) list1.append(3) list1.append(7) list1.append(8) list2 = LinkedList() list2.append(4) list2.append(5) actual = str(zipLists(list1, list2)) expected = "{1}->{4}->{2}->{5}->{3}->{7}->{8}->NULL" assert actual == expected
def test_append_empty(): ll = LinkedList() ll.append('test') assert str(ll.head) == "test"