File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 88from pathlib import Path
99
1010from codebasin import CodeBase , finder
11+ from codebasin .report import find_duplicates
1112
1213
1314class TestDuplicates (unittest .TestCase ):
@@ -117,6 +118,20 @@ def test_symlink_files(self):
117118 setmap = state .get_setmap (codebase )
118119 self .assertDictEqual (setmap , expected_setmap , "Mismatch in setmap" )
119120
121+ def test_find_duplicates (self ):
122+ """Check that we can correctly identify duplicate files."""
123+ tmp = tempfile .TemporaryDirectory ()
124+ path = Path (tmp .name )
125+ with open (path / "foo.cpp" , mode = "w" ) as f :
126+ f .write ("void foo();" )
127+ with open (path / "bar.cpp" , mode = "w" ) as f :
128+ f .write ("void foo();" )
129+ codebase = CodeBase (path )
130+
131+ duplicates = find_duplicates (codebase )
132+ expected_duplicates = [{path / "foo.cpp" , path / "bar.cpp" }]
133+ self .assertCountEqual (duplicates , expected_duplicates )
134+
120135 tmp .cleanup ()
121136
122137
You can’t perform that action at this time.
0 commit comments