def test_full_linked_list_deep_equality():
    ll1 = LinkedList()
    ll2 = LinkedList()
    ll1.append(0)
    ll1.insert(1)
    ll2.insert(0)
    assert ll1.head.next_.val == ll2.head.val
def test_ll_append2():
    linkedlist = LinkedList()
    linkedlist.insert(0)
    linkedlist.append(1)
    linkedlist.insert(2)
    linkedlist.append(3)
    assert str(linkedlist) == "{ 2 } -> { 0 } -> { 1 } -> { 3 } -> NULL"
def test_ll_insert_before5():
    ll = LinkedList()
    ll.append(5)
    ll.append(3)
    ll.append(1)
    with pytest.raises(Exception):
        ll.insert_before(7, 10)
def test_ll_insert_before4():
    ll = LinkedList()
    ll.append(5)
    ll.append(3)
    ll.append(1)
    ll.insert_before(5, 10)
    assert str(ll) == "{ 10 } -> { 5 } -> { 3 } -> { 1 } -> NULL"
def test_ll_merge1():
    ll1 = LinkedList()
    ll1.append(2)
    ll1.append(4)
    ll1.append(6)
    ll2 = LinkedList()
    ll2.append(1)
    ll2.append(3)
    ll2.append(5)
    mergedLists = LinkedList.merge_lls(ll2, ll1)
    assert (str(mergedLists) ==
            "{ 1 } -> { 2 } -> { 3 } -> { 4 } -> { 5 } -> { 6 } -> NULL")
    assert mergedLists.length == 6
def test_ll_merge_uneven_long_second():
    ll1 = LinkedList()
    ll1.append(2)
    ll1.append(4)
    ll1.append(6)
    ll2 = LinkedList()
    ll2.append(1)
    mergedLists = LinkedList.merge_lls(ll2, ll1)
    assert str(mergedLists) == "{ 1 } -> { 2 } -> { 4 } -> { 6 } -> NULL"
    assert mergedLists.length == 4
def test_ll_merge_uneven_long_first():
    ll1 = LinkedList()
    ll1.append(2)
    ll2 = LinkedList()
    ll2.append(1)
    ll2.append(3)
    ll2.append(5)
    mergedLists = LinkedList.merge_lls(ll2, ll1)
    assert str(mergedLists) == "{ 1 } -> { 2 } -> { 3 } -> { 5 } -> NULL"
    assert mergedLists.length == 4
def test_ll_append3():
    linkedlist = LinkedList()
    linkedlist.append(1)
    assert linkedlist.head.val == 1
def test_ll_append1():
    linkedlist = LinkedList()
    linkedlist.insert(0)
    linkedlist.append(1)
    assert str(linkedlist) == "{ 0 } -> { 1 } -> NULL"
def test_ll_merge_one_empty_list():
    ll1 = LinkedList()
    ll1.append(0)
    ll2 = LinkedList()
    mergedLists = LinkedList.merge_lls(ll2, ll1)
    assert str(mergedLists) == "{ 0 } -> NULL"