Skip to content

Commit 505a131

Browse files
test(miner): cover C and C++ source scanning
1 parent 0b5591d commit 505a131

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from mempalace.miner import READABLE_EXTENSIONS, scan_project
2+
3+
4+
CPP_EXTENSIONS = {".c", ".h", ".cpp", ".hpp", ".cc", ".cxx", ".inl"}
5+
6+
7+
def test_cpp_extensions_are_readable():
8+
assert CPP_EXTENSIONS <= READABLE_EXTENSIONS
9+
10+
11+
def test_scan_project_includes_cpp_files_case_insensitively(tmp_path):
12+
expected = []
13+
for index, extension in enumerate(sorted(CPP_EXTENSIONS)):
14+
filename = f"example_{index}{extension}"
15+
(tmp_path / filename).write_text("int main() { return 0; }\n", encoding="utf-8")
16+
expected.append(filename)
17+
18+
(tmp_path / "uppercase.CPP").write_text("int main() { return 0; }\n", encoding="utf-8")
19+
expected.append("uppercase.CPP")
20+
21+
files = scan_project(str(tmp_path))
22+
scanned = sorted(path.relative_to(tmp_path).as_posix() for path in files)
23+
assert scanned == sorted(expected)

0 commit comments

Comments
 (0)