-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add line breaks after each stitched file if missing. (#46)
Breaking change with existing behavior.
- Loading branch information
Showing
3 changed files
with
118 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from io import StringIO | ||
from pathlib import Path | ||
|
||
from quom import Quom | ||
|
||
FILE_MAIN_CPP = """\ | ||
#include "a.hpp" | ||
int main() { | ||
return 0; | ||
} | ||
// Stitch Begin | ||
// End | ||
""" | ||
|
||
FILE_A_HPP = 'int a;' | ||
|
||
FILE_A_CPP = """\ | ||
#include "b.hpp" | ||
#include "c.hpp" | ||
void mid() {}""" | ||
|
||
FILE_B_HPP = 'int b;' | ||
FILE_C_HPP = 'int c;' | ||
|
||
FILE_B_CPP = """\ | ||
#include <b>""" | ||
|
||
FILE_C_CPP = """\ | ||
#include <c>""" | ||
|
||
RESULT = """\ | ||
int a; | ||
int main() { | ||
return 0; | ||
} | ||
// Stitch Begin | ||
// End | ||
int b; | ||
int c; | ||
void mid() {} | ||
#include <b> | ||
#include <c> | ||
""" | ||
|
||
RESULT_STITCH = """\ | ||
int a; | ||
int main() { | ||
return 0; | ||
} | ||
int b; | ||
int c; | ||
void mid() {} | ||
#include <b> | ||
#include <c> | ||
// End | ||
""" | ||
|
||
|
||
def init(): | ||
with open('main.hpp', 'w+', encoding='utf-8') as file: | ||
file.write(FILE_MAIN_CPP) | ||
|
||
with open('a.hpp', 'w+', encoding='utf-8') as file: | ||
file.write(FILE_A_HPP) | ||
|
||
with open('a.cpp', 'w+', encoding='utf-8') as file: | ||
file.write(FILE_A_CPP) | ||
|
||
with open('b.hpp', 'w+', encoding='utf-8') as file: | ||
file.write(FILE_B_HPP) | ||
|
||
with open('b.cpp', 'w+', encoding='utf-8') as file: | ||
file.write(FILE_B_CPP) | ||
|
||
with open('c.hpp', 'w+', encoding='utf-8') as file: | ||
file.write(FILE_C_HPP) | ||
|
||
with open('c.cpp', 'w+', encoding='utf-8') as file: | ||
file.write(FILE_C_CPP) | ||
|
||
|
||
def test_add_line_break_in_stitched_files_if_missing(fs): | ||
init() | ||
|
||
dst = StringIO() | ||
Quom(Path('main.hpp'), dst) | ||
|
||
assert dst.getvalue() == RESULT | ||
|
||
|
||
def test_add_line_break_in_stitched_files_if_missing_at_stitch_location(fs): | ||
init() | ||
|
||
dst = StringIO() | ||
Quom(Path('main.hpp'), dst, stitch_format='Stitch Begin') | ||
|
||
assert dst.getvalue() == RESULT_STITCH |