test: add nine-backslash escape test for prompt placeholders

This commit is contained in:
Konstantin Fickel 2026-02-20 21:13:57 +01:00
parent 3de3614433
commit 8f0e49ee6f
Signed by: kfickel
GPG key ID: A793722F9933C1A5

View file

@ -43,6 +43,15 @@ class TestSubstitutePlaceholders:
result = substitute_placeholders("Hello \\\\\\{name.txt}", project_dir) result = substitute_placeholders("Hello \\\\\\{name.txt}", project_dir)
assert result == "Hello \\{name.txt}" assert result == "Hello \\{name.txt}"
def test_nine_backslashes_before_placeholder(self, project_dir: Path) -> None:
"""Nine backslashes (odd) → 4 literal backslashes + literal {file.txt}."""
_ = (project_dir / "file.txt").write_text("content")
# 9 backslashes before {file.txt}: odd → escaped, halve to 4
result = substitute_placeholders(
"\\\\\\\\\\\\\\\\\\" + "{file.txt}", project_dir
)
assert result == "\\\\\\\\{file.txt}"
def test_placeholder_at_start(self, project_dir: Path) -> None: def test_placeholder_at_start(self, project_dir: Path) -> None:
_ = (project_dir / "greeting.txt").write_text("Hi there") _ = (project_dir / "greeting.txt").write_text("Hi there")
result = substitute_placeholders("{greeting.txt}!", project_dir) result = substitute_placeholders("{greeting.txt}!", project_dir)