Merge pull request #1825 from pr-agent-group-2/feature/fix_json_escape_char-test

Add unit tests for fix_json_escape_char function
This commit is contained in:
Tal
2025-05-26 07:49:39 +03:00
committed by GitHub

View File

@ -0,0 +1,21 @@
from pr_agent.algo.utils import fix_json_escape_char
class TestFixJsonEscapeChar:
def test_valid_json(self):
"""Return unchanged when input JSON is already valid"""
text = '{"a": 1, "b": "ok"}'
expected_output = {"a": 1, "b": "ok"}
assert fix_json_escape_char(text) == expected_output
def test_single_control_char(self):
"""Remove a single ASCII control-character"""
text = '{"msg": "hel\x01lo"}'
expected_output = {"msg": "hel lo"}
assert fix_json_escape_char(text) == expected_output
def test_multiple_control_chars(self):
"""Remove multiple control-characters recursively"""
text = '{"x": "A\x02B\x03C"}'
expected_output = {"x": "A B C"}
assert fix_json_escape_char(text) == expected_output