from aiservice.common.llm_output_utils import truncate_pathological_output


def test_truncate_pathological_output_clean() -> None:
    code = "def foo():\n    return 42"
    assert truncate_pathological_output(code) == code


def test_truncate_pathological_output_with_pathological_pattern() -> None:
    code = "def foo():\n    x = " + "\\''''''''''''" + "\nmore stuff"
    result = truncate_pathological_output(code)
    assert result == "def foo():\n    x ="


def test_truncate_pathological_output_double_quotes() -> None:
    code = "x = " + '\\""""""""""""' + "stuff"
    result = truncate_pathological_output(code)
    assert result == "x ="
