def test_zipLists(self, list1, list2): list1 = LinkedList() list2 = LinkedList() list1.append(1) list1.append(2) list2.append(3) list2.append(4) zipLists(list1, list2) assert zipLists.value == 1 assert zipLists.next.value == 3 assert zipLists.next.next.value == 2 assert zipLists.next.next.next.value == 4
def test_zip_edge_two(long_list, list_two): """ tests zip function when list two is longer than list one. """ returned = zipLists(list_two, long_list) result = returned.__str__() assert result == 'b -> a -> d -> c -> f -> e -> h -> g -> i'
def test_base_zip(list_one, list_two): """ tests zip function with no edge cases. """ returned = zipLists(list_one, list_two) result = returned.__str__() assert result == 'a -> b -> c -> d -> e -> f -> g -> h'
def test_zip_lists_same_length(): first_list = LinkedList([5, 6, 7, 8, 9, 10, 11]) second_list = LinkedList([12, 13, 14, 15, 16, 17, 18]) new_head = zipLists(first_list, second_list) assert str( first_list ) == '5 ->12 ->6 ->13 ->7 ->14 ->8 ->15 ->9 ->16 ->10 ->17 ->11 ->18'
def test_zip_lists_normal(): zipped_list = zipLists(llist_a, llist_b) actual = str(zipped_list) expected = '{213} -> {45} -> {454} -> {918} -> {981} -> {203} -> {123} -> {978} -> {415} -> {253} -> {98} -> {455} -> {23} -> {198} -> NULL' assert actual == expected
def test_zip_lists_empty(): first_list = LinkedList() second_list = LinkedList([12, 13, 14]) new_head = zipLists(first_list, second_list) assert new_head.value == 12
def test_zip_lists_bad_input(): with pytest.raises(TypeError): headless = zipLists('potato', 5)
def test_zip_lists_longer_second(): first_list = LinkedList([5, 6, 7]) second_list = LinkedList([12, 13, 14, 15, 16]) new_head = zipLists(first_list, second_list) assert str(first_list) == '5 ->12 ->6 ->13 ->7 ->14 ->15 ->16'
def test_zip_lists_longer_first(): first_list = LinkedList([5, 6, 7, 8, 9]) second_list = LinkedList([12, 13, 14]) new_head = zipLists(first_list, second_list) assert str(first_list) == '5 ->12 ->6 ->13 ->7 ->14 ->8 ->9'