@@ -215,30 +215,27 @@ void TestProjectFile::emptyUserInclude() const
215215}
216216
217217// Absolute path is made relative when it does not require walking up more than 2 parent folders
218- void TestProjectFile::setExcludedPathsRelative () const
218+ void TestProjectFile::getRelativePathRelative () const
219219{
220220 ProjectFile projectFile;
221221 projectFile.setFilename (" /some/path/123.cppcheck" );
222- projectFile.setExcludedPaths (QStringList () << " /some/externals/foo.cpp" );
223- QCOMPARE (projectFile.getExcludedPaths ()[0 ], QString (" ../externals/foo.cpp" ));
222+ QCOMPARE (projectFile.getRelativePath (" /some/externals/foo.cpp" ), QString (" ../externals/foo.cpp" ));
224223}
225224
226225// Absolute path is kept as-is when making it relative would require walking up more than 2 parent folders
227- void TestProjectFile::setExcludedPathsTooFarUp () const
226+ void TestProjectFile::getRelativePathTooFarUp () const
228227{
229228 ProjectFile projectFile;
230229 projectFile.setFilename (" /some/path/123.cppcheck" );
231- projectFile.setExcludedPaths (QStringList () << " /other/deep/foo.cpp" );
232- QCOMPARE (projectFile.getExcludedPaths ()[0 ], QString (" /other/deep/foo.cpp" ));
230+ QCOMPARE (projectFile.getRelativePath (" /other/deep/foo.cpp" ), QString (" /other/deep/foo.cpp" ));
233231}
234232
235- // Paths that are already relative are kept unchanged
236- void TestProjectFile::setExcludedPathsAlreadyRelative () const
233+ // Absolute path in a subfolder of the project path is made relative without walking up at all
234+ void TestProjectFile::getRelativePathSubfolder () const
237235{
238236 ProjectFile projectFile;
239237 projectFile.setFilename (" /some/path/123.cppcheck" );
240- projectFile.setExcludedPaths (QStringList () << " gui/temp/" );
241- QCOMPARE (projectFile.getExcludedPaths ()[0 ], QString (" gui/temp/" ));
238+ QCOMPARE (projectFile.getRelativePath (" /some/path/src/file1.c" ), QString (" src/file1.c" ));
242239}
243240
244241QTEST_MAIN (TestProjectFile)
0 commit comments