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

Method testProjectFileSwap

plugins/quickopen/tests/test_quickopen.cpp:34–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34void TestQuickOpen::testProjectFileSwap()
35{
36 QScopedPointer<TestProject> project(getProjectWithFiles(2));
37 QVector<ProjectFile> projectFiles;
38 KDevelop::forEachFile(project->projectItem(), [&projectFiles](ProjectFileItem* fileItem) {
39 projectFiles.push_back(ProjectFile{fileItem});
40 });
41 QCOMPARE(projectFiles.size(), 2);
42
43 const auto equivalent = [](const ProjectFile &x, const ProjectFile &y) {
44 return !(x < y) && !(y < x);
45 };
46
47 ProjectFile a = projectFiles.at(0);
48 ProjectFile b = projectFiles.at(1);
49 QCOMPARE(a.projectPath, b.projectPath);
50 QVERIFY(!equivalent(a, b));
51
52 const auto aCopy = a;
53 const auto bCopy = b;
54 QCOMPARE(aCopy.projectPath, a.projectPath);
55 QVERIFY(equivalent(aCopy, a));
56 QCOMPARE(bCopy.projectPath, b.projectPath);
57 QVERIFY(equivalent(bCopy, b));
58
59 using std::swap;
60
61 swap(a, b);
62 QCOMPARE(a.projectPath, bCopy.projectPath);
63 QVERIFY(equivalent(a, bCopy));
64 QCOMPARE(b.projectPath, aCopy.projectPath);
65 QVERIFY(equivalent(b, aCopy));
66
67 QString anotherProjectPath = "/some/special/path/to/a-project";
68#ifdef Q_OS_WIN
69 anotherProjectPath.prepend("C:");
70#endif
71 a.projectPath = Path{anotherProjectPath};
72 QCOMPARE(a.projectPath.pathOrUrl(), anotherProjectPath);
73
74 swap(a, b);
75 QCOMPARE(a.projectPath, aCopy.projectPath);
76 QVERIFY(equivalent(a, aCopy));
77 QCOMPARE(b.projectPath.pathOrUrl(), anotherProjectPath);
78 QVERIFY(equivalent(b, bCopy));
79
80 QVERIFY(a.projectPath != b.projectPath);
81 QVERIFY(!equivalent(a, b));
82}
83
84void TestQuickOpen::testDuchainFilter()
85{

Callers

nothing calls this directly

Calls 8

getProjectWithFilesFunction · 0.85
forEachFileFunction · 0.85
pathOrUrlMethod · 0.80
swapFunction · 0.50
projectItemMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected