Skip to content

Commit 495bc7e

Browse files
authored
Merge pull request #47 from keyhr/fix/preprocessor/04
[fix] error if preprocessor part does not exist
2 parents 51532b0 + df11146 commit 495bc7e

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

c_formatter_42/formatters/preprocessor_directive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def preprocessor_directive(content: str) -> str:
3535
indent -= 1
3636

3737
# if newline doesn't follows preprocessor part, insert one
38-
lastline_index = idented[-1][0]
3938
try:
39+
lastline_index = idented[-1][0]
4040
if lines[lastline_index + 1] != "":
4141
lines.insert(lastline_index + 1, "")
4242
except IndexError:

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = c_formatter_42
3-
version = 0.2.0
3+
version = 0.2.1
44
description = formatting tool complient with 42 school's norm
55
long_description = file: README.md
66
long_description_content_type = text/markdown

tests/test_run.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,18 @@ def test_run_align_break_column_max():
5353

5454
def test_run_func_decl_single_tab_and_global_aligned():
5555
pass
56+
57+
58+
def test_basic():
59+
input = """
60+
int main(int argc, char*argv[]){
61+
return 0;
62+
}
63+
"""
64+
output = """
65+
int\tmain(int argc, char *argv[])
66+
{
67+
return (0);
68+
}
69+
"""
70+
assert output == run_all(input)

0 commit comments

Comments
 (0)