From acccdd774b600040014659a3179a766030a49f7f Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 16 Aug 2021 11:23:47 +0200 Subject: [PATCH] CppTools: Fix tests - Prevent invalid access to temporary. - Fix typo. - Use accidentally unused class member. Amends 33108795d6. Change-Id: I2cc91e294fb4be7f4e20b383171b06a39f53c99c Reviewed-by: Eike Ziller --- src/plugins/cpptools/compileroptionsbuilder_test.cpp | 6 +++--- src/plugins/cpptools/projectinfo_test.cpp | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/cpptools/compileroptionsbuilder_test.cpp b/src/plugins/cpptools/compileroptionsbuilder_test.cpp index 256cabe58fb..5f231a244c1 100644 --- a/src/plugins/cpptools/compileroptionsbuilder_test.cpp +++ b/src/plugins/cpptools/compileroptionsbuilder_test.cpp @@ -47,7 +47,7 @@ namespace { class CompilerOptionsBuilderTest { public: - ProjectPart finalize() + const ProjectPart &finalize() { QFile pchFile(pchFileNativePath()); pchFile.open(QIODevice::WriteOnly); @@ -68,8 +68,8 @@ public: }; RawProjectPartFlags rppFlags; rppFlags.commandLineFlags = flags; - projectPart = ProjectPart::create({}, rpp, {}, {}, Utils::Language::Cxx, {}, rppFlags, - tcInfo); + projectPart = ProjectPart::create({}, rpp, {}, {}, Utils::Language::Cxx, languageExtensions, + rppFlags, tcInfo); compilerOptionsBuilder.emplace(CompilerOptionsBuilder(*projectPart)); return *projectPart; } diff --git a/src/plugins/cpptools/projectinfo_test.cpp b/src/plugins/cpptools/projectinfo_test.cpp index 69ba398a0ac..0f1d4f18d13 100644 --- a/src/plugins/cpptools/projectinfo_test.cpp +++ b/src/plugins/cpptools/projectinfo_test.cpp @@ -186,7 +186,7 @@ void CppToolsPlugin::test_projectPartChooser_forMultiplePreferSelectedForBuildin RawProjectPart rpp1; rpp1.setSelectedForBuilding(false); RawProjectPart rpp2; - rpp1.setSelectedForBuilding(true); + rpp2.setSelectedForBuilding(true); const ProjectPart::Ptr firstProjectPart = ProjectPart::create({}, rpp1); const ProjectPart::Ptr secondProjectPart = ProjectPart::create({}, rpp2); ProjectPartChooserTest t; @@ -498,7 +498,7 @@ namespace { class HeaderPathFilterTest { public: - ProjectPart finalize() + const ProjectPart &finalize() { RawProjectPart rpp; rpp.setHeaderPaths(headerPaths); @@ -574,6 +574,7 @@ void CppToolsPlugin::test_headerPathFilter_system() void CppToolsPlugin::test_headerPathFilter_user() { HeaderPathFilterTest t; + t.finalize(); t.filter->process(); QCOMPARE(t.filter->userHeaderPaths, (HeaderPaths{t.user("/build/user_path"),