def test_first_is_bigger(): my_list = LinkedList() my_list.insert(4) my_list.insert(3) my_list.insert(2) my_list.insert(1) other_list = LinkedList() other_list.insert(6) other_list.insert(5) merge_list(my_list, other_list) assert my_list.to_string() == ' 1 5 2 6 3 4'
def test_merge_same_size(): my_list = LinkedList() my_list.insert(3) my_list.insert(2) my_list.insert(1) other_list = LinkedList() other_list.insert(6) other_list.insert(5) other_list.insert(4) merge_list(my_list, other_list) assert my_list.to_string() == ' 1 4 2 5 3 6'
def test_second_is_bigger(): my_list = LinkedList() my_list.insert(2) my_list.insert(1) other_list = LinkedList() my_list.insert(4) my_list.insert(3) other_list.insert(6) other_list.insert(5) merge_list(my_list, other_list) assert my_list.to_string() == ' 3 5 4 6 1 2'
def test_list_2nd_empty(): l_list2 = LinkedList() l_list1 = create_list(['d', 'c', 'b', 'a']) ref_to_head = merge_list(l_list1, l_list2) assert ref_to_head.value == "a" assert l_list1.__str__() == 'a, b, c, d'
def test_2_empty(): list_1 = LinkedList(['a', 'b']) list_2 = LinkedList() list_3 = merge_list(list_1, list_2) assert list_3.__str__() == 'a : b : None'
def test_1_empty(): list_1 = LinkedList() list_2 = LinkedList(['b', 'c']) list_3 = merge_list(list_1, list_2) assert list_3.__str__() == 'b : c : None'
def test_empty_lists(): list_1 = LinkedList() list_2 = LinkedList() with pytest.raises(Exception): merge_list(list_1, list_2)
def test_2_list_1_element(): list_1 = LinkedList([1, 3]) list_2 = LinkedList([2]) list_3 = merge_list(list_1, list_2) assert list_3.__str__() == '1 : 2 : 3 : None'
def test_1_list_1_element(): list_1 = LinkedList([1]) list_2 = LinkedList(['b', 'c']) list_3 = merge_list(list_1, list_2) assert list_3.__str__() == '1 : b : c : None'
def test_2_shorter(): list_1 = LinkedList(['1', '3', '2']) list_2 = LinkedList(['5', '9']) list_3 = merge_list(list_1, list_2) assert list_3.__str__() == '1 : 5 : 3 : 9 : 2 : None'
def test_merge_one(ll_one): empty_list = LinkedList() empty_list.insert('b') new_ll = merge_list(ll_one, empty_list) assert new_ll.get_length() == 'a -> b -> '
def test_1slist_shorter(): l_list1 = create_list(['d', 'c', 'b', 'a']) l_list2 = create_list(['h', 'g', 'f', 'e', 'z']) ref_to_head = merge_list(l_list1, l_list2) assert ref_to_head.value == "a" assert l_list1.__str__() == 'a, z, b, e, c, f, d, g, h'
def test_lists_empty(): l_list1 = LinkedList() l_list2 = LinkedList() with pytest.raises(Exception): merge_list(l_list1, l_list2)
def test_lists_equal(): l_list1 = create_list(['d', 'c', 'b', 'a']) l_list2 = create_list(['h', 'g', 'f', 'e']) ref_to_head = merge_list(l_list1, l_list2) assert ref_to_head.value == "a" assert l_list1.__str__() == 'a, e, b, f, c, g, d, h'
def test_1slist_longer(): l_list1 = create_list(['d', 'c', 'b', 'a', 'z']) l_list2 = create_list(['h', 'g', 'f', 'e']) ref_to_head = merge_list(l_list1, l_list2) assert ref_to_head.value == "z" assert l_list1.__str__() == 'z, e, a, f, b, g, c, h, d'
def test_merge_different_length(ll_three, ll_five): new_ll = merge_list(ll_five, ll_three) assert new_ll.get_length() == 'True -> 3 -> c -> a -> 8 -> 2 -> a -> 9 -> '
def test_merge_many(ll_six, ll_eight): new_ll = merge_list(ll_six, ll_eight) assert new_ll.get_length( ) == '6 -> 1 -> False -> 7 -> p -> w -> 8 -> True -> h -> c -> 9 -> 2 -> z -> 4 -> '
def test_list_2ndlist_1element(): l_list1 = create_list(['d', 'c', 'b', 'a']) l_list2 = create_list([1]) ref_to_head = merge_list(l_list1, l_list2) assert ref_to_head.value == 'a' assert l_list1.__str__() == 'a, 1, b, c, d'
def test_merge_none(ll_none): new_ll = merge_list(ll_none, ll_none) assert new_ll.get_length() == ''