diff --git a/c_formatter_42/formatters/preprocessor_directive.py b/c_formatter_42/formatters/preprocessor_directive.py index 27d763d..ed86469 100644 --- a/c_formatter_42/formatters/preprocessor_directive.py +++ b/c_formatter_42/formatters/preprocessor_directive.py @@ -35,8 +35,8 @@ def preprocessor_directive(content: str) -> str: indent -= 1 # if newline doesn't follows preprocessor part, insert one - lastline_index = idented[-1][0] try: + lastline_index = idented[-1][0] if lines[lastline_index + 1] != "": lines.insert(lastline_index + 1, "") except IndexError: diff --git a/setup.cfg b/setup.cfg index 194e78f..0bead7b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = c_formatter_42 -version = 0.2.0 +version = 0.2.1 description = formatting tool complient with 42 school's norm long_description = file: README.md long_description_content_type = text/markdown diff --git a/tests/test_run.py b/tests/test_run.py index 12874e6..cb47b03 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -53,3 +53,18 @@ def test_run_align_break_column_max(): def test_run_func_decl_single_tab_and_global_aligned(): pass + + +def test_basic(): + input = """ +int main(int argc, char*argv[]){ + return 0; +} +""" + output = """ +int\tmain(int argc, char *argv[]) +{ + return (0); +} +""" + assert output == run_all(input)