MCPcopy Create free account
hub / github.com/KDE/kdevelop / testWildcardPathMatching

Method testWildcardPathMatching

kdevplatform/util/tests/test_kdevformatsource.cpp:205–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205void TestKdevFormatSource::testWildcardPathMatching()
206{
207 QFETCH(QStringList, formatDirs);
208 QFETCH(QByteArrayList, formatContents);
209 QFETCH(QStringList, unmatchedPaths);
210 QFETCH(QStringList, matchedPaths);
211
212 QTemporaryDir tmpDir;
213 QVERIFY2(tmpDir.isValid(), qPrintable("couldn't create temporary directory: " + tmpDir.errorString()));
214
215 using FilesystemHelpers::makeAbsoluteCreateAndWrite;
216
217 for (auto& dir : formatDirs) {
218 dir = QFileInfo{QDir{dir}, "format_sources"}.filePath();
219 }
220 QString errorPath = makeAbsoluteCreateAndWrite(tmpDir.path(), formatDirs, formatContents);
221 QVERIFY2(errorPath.isEmpty(), qPrintable("couldn't create or write to temporary file or directory " + errorPath));
222
223 errorPath = makeAbsoluteCreateAndWrite(tmpDir.path(), unmatchedPaths);
224 if (errorPath.isEmpty()) {
225 errorPath = makeAbsoluteCreateAndWrite(tmpDir.path(), matchedPaths);
226 }
227 QVERIFY2(errorPath.isEmpty(), qPrintable("couldn't create temporary file or directory " + errorPath));
228
229 bool expectedFormattingResult = false; // for unmatchedPaths
230 for (const auto& paths : { unmatchedPaths, matchedPaths }) {
231 for (const auto& path : paths) {
232 QVERIFY2(QFileInfo{path}.isFile(), qPrintable(path + ": file was not created or was deleted"));
233 const QString error = applyFormatting(path, expectedFormattingResult);
234 QVERIFY2(error.isEmpty(), qPrintable(error));
235 }
236 expectedFormattingResult = true; // for matchedPaths
237 }
238}
239
240bool TestKdevFormatSource::initTest(const QStringList& formatFileData)
241{

Callers

nothing calls this directly

Calls 6

applyFormattingFunction · 0.85
isValidMethod · 0.45
errorStringMethod · 0.45
filePathMethod · 0.45
pathMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected