def test_insert_before_middle(): list = LinkedList() list.append(1) list.append(2) list.append(3) list.insertBefore(2, 2.5) assert list.head.next.value == 2.5
def delete_last(): list = LinkedList() list.append(1) list.append(2) list.append(3) list.deleteValue(1) assert list.head.next.next.value == None
def test_kth_greater(): list = LinkedList() list.append(1) list.append(2) list.append(3) with pytest.raises(Exception): assert list.get_kth_value(5)
def delete_middle(): list = LinkedList() list.append(1) list.append(2) list.append(3) list.deleteValue(2) assert list.head.next.value == 3
def delete_first(): list = LinkedList() list.append(1) list.append(2) list.append(3) list.deleteValue(1) assert list.head.value == 2
def test_insert_after_last(): list = LinkedList() list.append(1) list.append(2) list.append(3) list.insertAfter(3, 3.5) assert list.head.next.next.next.value == 3.5
def test_insert_after_middle(): list = LinkedList() list.append(1) list.append(2) list.append(3) list.insertAfter(2, 2.5) assert list.head.next.next.value == 2.5
def test_insert_before_first(): list = LinkedList() list.append(1) list.append(2) list.append(3) list.insertBefore(1, 1.5) assert list.head.value == 1.5
def test_kth_negative(): list = LinkedList() list.append(1) list.append(2) list.append(3) with pytest.raises(Exception): assert list.get_kth_value(-1)
def test_kth_same_length(): list = LinkedList() list.append(1) list.append(2) list.append(3) with pytest.raises(Exception): assert list.get_kth_value(3)
def test_append_multi(): list = LinkedList() list.append(1) list.append(2) list.append(3) assert list.head.value == 1 assert list.head.next.value == 2 assert list.head.next.next.value == 3
def test_zio_2nd_longer(): list1 = LinkedList() list2 = LinkedList() list1.append(1) list2.append(4) list2.append(5) list1.zipLists(list2) assert list1.__str__() == "{ 1 } -> { 4 } -> { 5 } -> NULL"
def test_zip_2nd_empty(): list1 = LinkedList() list2 = LinkedList() list1.append(1) list1.append(2) list1.append(3) list1.zipLists(list2) assert list1.__str__() == "{ 1 } -> { 2 } -> { 3 } -> NULL"
def test_zio_same_length(): list1 = LinkedList() list2 = LinkedList() list1.append(1) list1.append(2) list1.append(3) list2.append(4) list2.append(5) list2.append(6) list1.zipLists(list2) assert list1.__str__( ) == "{ 1 } -> { 4 } -> { 2 } -> { 5 } -> { 3 } -> { 6 } -> NULL"
def test_append(): list = LinkedList() list.insert(1) list.insert(2) list.append(3) assert list.head.next.next.value == 3
def test_append_empty(): list = LinkedList() list.append(1) assert list.head.value == 1
def test_kth_middle(): list = LinkedList() list.append(1) list.append(2) list.append(3) assert list.get_kth_value(1) == 2
def test_kth_size_one(): list = LinkedList() list.append(1) assert list.get_kth_value(0) == 1