diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2022-04-05 15:38:56 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2022-04-07 08:20:22 +0000 |
commit | 3cdec51eaf2c26fce048d9564e7faf9502d6b0c9 (patch) | |
tree | 107e3c6a6d1dd45e88830de488e5a6c47f5393e8 /src/plugins/cppeditor/cppquickfix_test.cpp | |
parent | f27c4214f8014f230860457d94822e5166f44b26 (diff) | |
download | qt-creator-3cdec51eaf2c26fce048d9564e7faf9502d6b0c9.tar.gz |
CppEditor: Properly handle function types as template arguments
... when creating getters and setters.
Fixes: QTCREATORBUG-27133
Change-Id: Ia77147a270fb1229c765ff9d5f03aa243d51fe97
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppquickfix_test.cpp')
-rw-r--r-- | src/plugins/cppeditor/cppquickfix_test.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index a2ed383c12..6a6b27b383 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -3362,6 +3362,43 @@ void QuickfixTest::testGenerateGetterSetterOnlySetterHeaderFileWithIncludeGuard( QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 0); } +void QuickfixTest::testGenerateGetterFunctionAsTemplateArg() +{ + QList<TestDocumentPtr> testDocuments; + const QByteArray original = R"( +template<typename T> class TS {}; +template<typename T, typename U> class TS<T(U)> {}; + +class S2 { + TS<int(int)> @member; +}; +)"; + const QByteArray expected = R"( +template<typename T> class TS {}; +template<typename T, typename U> class TS<T(U)> {}; + +class S2 { + TS<int(int)> member; + +public: + const TS<int (int)> &getMember() const + { + return member; + } +}; +)"; + + testDocuments << CppTestDocument::create("file.h", original, expected); + + QuickFixSettings s; + s->getterOutsideClassFrom = 0; + s->getterInCppFileFrom = 0; + s->getterNameTemplate = "get<Name>"; + + GenerateGetterSetter factory; + QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 1); +} + class CppCodeStyleSettingsChanger { public: CppCodeStyleSettingsChanger(const CppCodeStyleSettings &settings); |