From 684a438167fd92402bb7968a6ddd2d53256b636e Mon Sep 17 00:00:00 2001 From: jwsong98 Date: Thu, 22 May 2025 16:18:45 +0900 Subject: [PATCH] test: add test case for fixing incorrect indentation in YAML code block scalar --- tests/unittest/test_try_fix_yaml.py | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/unittest/test_try_fix_yaml.py b/tests/unittest/test_try_fix_yaml.py index 09bdbff8..b23e9dd3 100644 --- a/tests/unittest/test_try_fix_yaml.py +++ b/tests/unittest/test_try_fix_yaml.py @@ -218,3 +218,36 @@ code_suggestions: } assert try_fix_yaml(review_text, first_key='code_suggestions', last_key='existing_code') == expected_output + + def test_wrong_indentation_code_block_scalar(self): + review_text = '''\ +code_suggestions: +- relevant_file: | + a.c + existing_code: | + int sum(int a, int b) { + return a + b; + } + + int sub(int a, int b) { + return a - b; + } +''' + expected_code_block = '''\ +int sum(int a, int b) { + return a + b; +} + +int sub(int a, int b) { + return a - b; +} +''' + expected_output = { + "code_suggestions": [ + { + "relevant_file": "a.c\n", + "existing_code": expected_code_block + } + ] + } + assert try_fix_yaml(review_text, first_key='code_suggestions', last_key='existing_code') == expected_output