def test_insert_after_does_not_exist(): ll = LinkedList() ll.insert(1) ll.insert(2) with pytest.raises(Exception) as context: ll.insert_after(3, 3) assert str(context.value) == "No node containing: 3"
def test_insert_after_exists(): ll = LinkedList() ll.insert(2) ll.insert(1) ll.insert_after(3, 2) assert str(ll) == '{ 1 } -> { 2 } -> { 3 } -> NULL'
def test_insert_after_empty(): ll = LinkedList() with pytest.raises(Exception) as context: ll.insert_after(1, 1) assert str(context.value) == "Cannot `insert_after` on empty LinkedList"