Skip to content

Commit

Permalink
Merge pull request #47 from keyhr/fix/preprocessor/04
Browse files Browse the repository at this point in the history
[fix] error if preprocessor part does not exist
  • Loading branch information
keyhr authored Jan 10, 2023
2 parents 51532b0 + df11146 commit 495bc7e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion c_formatter_42/formatters/preprocessor_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 15 additions & 0 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 495bc7e

Please sign in to comment.