summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor/cppsourceprocessor_test.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2022-11-24 13:05:41 +0100
committerhjk <hjk@qt.io>2022-11-30 17:27:56 +0000
commit39ffdb416ff3381515b7b4bf579acb23941cd6fc (patch)
tree544fd0f432246e397c3b851ed35d2b6d297dc661 /src/plugins/cppeditor/cppsourceprocessor_test.cpp
parentdc3a4f0002b2c8e4c437b2d6b3bf9e2e4be91a19 (diff)
downloadqt-creator-39ffdb416ff3381515b7b4bf579acb23941cd6fc.tar.gz
CPlusPlus: Use FilePath for resolved include paths
... and fix fallout. Change-Id: I66886e91ff476eff15db51cc024a8021e952d44d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/plugins/cppeditor/cppsourceprocessor_test.cpp')
-rw-r--r--src/plugins/cppeditor/cppsourceprocessor_test.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/plugins/cppeditor/cppsourceprocessor_test.cpp b/src/plugins/cppeditor/cppsourceprocessor_test.cpp
index 06b1748d8f..af617637f7 100644
--- a/src/plugins/cppeditor/cppsourceprocessor_test.cpp
+++ b/src/plugins/cppeditor/cppsourceprocessor_test.cpp
@@ -39,15 +39,15 @@ public:
cleanUp();
}
- Document::Ptr run(const QString &filePath) const
+ Document::Ptr run(const FilePath &filePath) const
{
QScopedPointer<CppSourceProcessor> sourceProcessor(
CppModelManager::createSourceProcessor());
sourceProcessor->setHeaderPaths({ProjectExplorer::HeaderPath::makeUser(
TestIncludePaths::directoryOfTestFile())});
- sourceProcessor->run(filePath);
+ sourceProcessor->run(filePath.toString());
- Document::Ptr document = m_cmm->document(Utils::FilePath::fromString(filePath));
+ Document::Ptr document = m_cmm->document(filePath);
return document;
}
@@ -70,7 +70,7 @@ private:
/// Check: Resolved and unresolved includes are properly tracked.
void SourceProcessorTest::testIncludesResolvedUnresolved()
{
- const QString testFilePath
+ const FilePath testFilePath
= TestIncludePaths::testFilePath(QLatin1String("test_main_resolvedUnresolved.cpp"));
SourcePreprocessor processor;
@@ -81,7 +81,7 @@ void SourceProcessorTest::testIncludesResolvedUnresolved()
QCOMPARE(resolvedIncludes.size(), 1);
QCOMPARE(resolvedIncludes.at(0).type(), Client::IncludeLocal);
QCOMPARE(resolvedIncludes.at(0).unresolvedFileName(), QLatin1String("header.h"));
- const QString expectedResolvedFileName
+ const FilePath expectedResolvedFileName
= TestIncludePaths::testFilePath(QLatin1String("header.h"));
QCOMPARE(resolvedIncludes.at(0).resolvedFileName(), expectedResolvedFileName);
@@ -95,10 +95,9 @@ void SourceProcessorTest::testIncludesResolvedUnresolved()
/// Check: Avoid self-include entries due to cyclic includes.
void SourceProcessorTest::testIncludesCyclic()
{
- const QString fileName1 = TestIncludePaths::testFilePath(QLatin1String("cyclic1.h"));
- const QString fileName2 = TestIncludePaths::testFilePath(QLatin1String("cyclic2.h"));
- const QSet<FilePath> sourceFiles = {FilePath::fromString(fileName1),
- FilePath::fromString(fileName2)};
+ const FilePath filePath1 = TestIncludePaths::testFilePath(QLatin1String("cyclic1.h"));
+ const FilePath filePath2 = TestIncludePaths::testFilePath(QLatin1String("cyclic2.h"));
+ const QSet<FilePath> sourceFiles = {filePath1, filePath2};
// Create global snapshot (needed in BuiltinEditorDocumentParser)
TestCase testCase;
@@ -106,7 +105,7 @@ void SourceProcessorTest::testIncludesCyclic()
// Open editor
TextEditor::BaseTextEditor *editor;
- QVERIFY(testCase.openCppEditor(FilePath::fromString(fileName1), &editor));
+ QVERIFY(testCase.openCppEditor(filePath1, &editor));
testCase.closeEditorAtEndOfTestCase(editor);
// Check editor snapshot
@@ -118,24 +117,24 @@ void SourceProcessorTest::testIncludesCyclic()
QCOMPARE(snapshot.size(), 3); // Configuration file included
// Check includes
- Document::Ptr doc1 = snapshot.document(fileName1);
+ Document::Ptr doc1 = snapshot.document(filePath1);
QVERIFY(doc1);
- Document::Ptr doc2 = snapshot.document(fileName2);
+ Document::Ptr doc2 = snapshot.document(filePath2);
QVERIFY(doc2);
QCOMPARE(doc1->unresolvedIncludes().size(), 0);
QCOMPARE(doc1->resolvedIncludes().size(), 1);
- QCOMPARE(doc1->resolvedIncludes().first().resolvedFileName(), fileName2);
+ QCOMPARE(doc1->resolvedIncludes().first().resolvedFileName(), filePath2);
QCOMPARE(doc2->unresolvedIncludes().size(), 0);
QCOMPARE(doc2->resolvedIncludes().size(), 1);
- QCOMPARE(doc2->resolvedIncludes().first().resolvedFileName(), fileName1);
+ QCOMPARE(doc2->resolvedIncludes().first().resolvedFileName(), filePath1);
}
/// Check: All include errors are reported as diagnostic messages.
void SourceProcessorTest::testIncludesAllDiagnostics()
{
- const QString testFilePath
+ const FilePath testFilePath
= TestIncludePaths::testFilePath(QLatin1String("test_main_allDiagnostics.cpp"));
SourcePreprocessor processor;
@@ -149,7 +148,7 @@ void SourceProcessorTest::testIncludesAllDiagnostics()
void SourceProcessorTest::testMacroUses()
{
- const QString testFilePath
+ const FilePath testFilePath
= TestIncludePaths::testFilePath(QLatin1String("test_main_macroUses.cpp"));
SourcePreprocessor processor;