forked from qt-creator/qt-creator
ClangFormat: Fix list declaration
Fixed list declaration indentation. Fixed function declaration with parameters on the new line. Added tests for both cases. Fixes: QTCREATORBUG-25011 Change-Id: Ida4f6ec4f407c5e5b015dc2c0afff110262d9645 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -655,4 +655,74 @@ void ClangFormatTest::testClassIndentStructure()
|
||||
(std::vector<QString>{"class test {", " Q_OBJECT", "public:", "};"}));
|
||||
}
|
||||
|
||||
void ClangFormatTest::testIndentInitializeVector()
|
||||
{
|
||||
insertLines({
|
||||
"class Test {",
|
||||
"public:",
|
||||
" Test();",
|
||||
"};",
|
||||
"",
|
||||
"Test::Test()",
|
||||
"{",
|
||||
" QVector<int> list = {",
|
||||
" 1,",
|
||||
" 2,",
|
||||
" 3,",
|
||||
" };",
|
||||
" QVector<int> list_2 = {",
|
||||
" 1,",
|
||||
" 2,",
|
||||
" 3,",
|
||||
" };",
|
||||
"}",
|
||||
"",
|
||||
"int main()",
|
||||
"{",
|
||||
"}"
|
||||
});
|
||||
m_indenter->indent(*m_cursor, QChar::Null, TextEditor::TabSettings());
|
||||
QCOMPARE(documentLines(),
|
||||
(std::vector<QString>{
|
||||
"class Test {",
|
||||
"public:",
|
||||
" Test();",
|
||||
"};",
|
||||
"",
|
||||
"Test::Test()",
|
||||
"{",
|
||||
" QVector<int> list = {",
|
||||
" 1,",
|
||||
" 2,",
|
||||
" 3,",
|
||||
" };",
|
||||
" QVector<int> list_2 = {",
|
||||
" 1,",
|
||||
" 2,",
|
||||
" 3,",
|
||||
" };",
|
||||
"}",
|
||||
"",
|
||||
"int main()",
|
||||
"{",
|
||||
"}"
|
||||
}));
|
||||
}
|
||||
|
||||
void ClangFormatTest::testIndentFunctionArgumentOnNewLine()
|
||||
{
|
||||
insertLines(
|
||||
{"Bar foo(",
|
||||
"a,",
|
||||
")"
|
||||
});
|
||||
m_indenter->indentBlock(m_doc->findBlockByNumber(1), QChar::Null, TextEditor::TabSettings());
|
||||
QCOMPARE(documentLines(),
|
||||
(std::vector<QString>{
|
||||
"Bar foo(",
|
||||
" a,",
|
||||
")"
|
||||
}));
|
||||
}
|
||||
|
||||
} // namespace ClangFormat::Internal
|
||||
|
||||
Reference in New Issue
Block a user