forked from qt-creator/qt-creator
CppEditor: fix "Convert to Stack Variable" for empty initializer lists
The "Convert to Stack Variable" quick fix generated invalid code for the following snippet: QString s = new QString(); Task-number: QTCREATORBUG-14279 Change-Id: I1f5e33d2089bc2d5713eae1e9f4dc5986523112c Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -1559,6 +1559,19 @@ void CppEditorPlugin::test_quickfix_data()
|
||||
" str.clear();\n"
|
||||
"}\n");
|
||||
|
||||
QTest::newRow("ConvertFromPointer_withEmptyInitializer")
|
||||
<< CppQuickFixFactoryPtr(new ConvertFromAndToPointer)
|
||||
<< _("void foo() {\n"
|
||||
" QString *@str = new QString();\n"
|
||||
" if (!str->isEmpty())\n"
|
||||
" str->clear();\n"
|
||||
"}\n")
|
||||
<< _("void foo() {\n"
|
||||
" QString str;\n"
|
||||
" if (!str.isEmpty())\n"
|
||||
" str.clear();\n"
|
||||
"}\n");
|
||||
|
||||
QTest::newRow("ConvertFromPointer_structWithPointer")
|
||||
<< CppQuickFixFactoryPtr(new ConvertFromAndToPointer)
|
||||
<< _("struct Bar{ QString *str; };\n"
|
||||
|
||||
Reference in New Issue
Block a user