mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 04:10:49 +08:00
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:
21
tests/unittest/test_fix_json_escape_char.py
Normal file
21
tests/unittest/test_fix_json_escape_char.py
Normal 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
|
Reference in New Issue
Block a user