forked from qt-creator/qt-creator
ClangFormat: Clean up some code and and few unit-tests
Check the context related stuff and remove the restriction to format after the stream operator. Change-Id: Iaa2d32c9bffe7a0eeb7e8ade39f109b529e1eab0 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -408,6 +408,60 @@ TEST_F(ClangFormat, IndentIfBodyAndFormatBeforeIt)
|
||||
"}"));
|
||||
}
|
||||
|
||||
TEST_F(ClangFormat, DoNotFormatAfterTheFirstColon)
|
||||
{
|
||||
insertLines({"{",
|
||||
" Qt:",
|
||||
"}"});
|
||||
|
||||
extendedIndenter.indentBlock(doc.findBlockByNumber(1), ':', TextEditor::TabSettings(), 9);
|
||||
|
||||
ASSERT_THAT(documentLines(), ElementsAre("{",
|
||||
" Qt:",
|
||||
"}"));
|
||||
}
|
||||
|
||||
TEST_F(ClangFormat, OnlyIndentIncompleteStatementOnElectricalCharacter)
|
||||
{
|
||||
insertLines({"{bar();",
|
||||
"foo()",
|
||||
"}"});
|
||||
|
||||
extendedIndenter.indentBlock(doc.findBlockByNumber(1), '(', TextEditor::TabSettings(), 12);
|
||||
|
||||
ASSERT_THAT(documentLines(), ElementsAre("{bar();",
|
||||
" foo()",
|
||||
"}"));
|
||||
}
|
||||
|
||||
TEST_F(ClangFormat, IndentAndFormatCompleteStatementOnSemicolon)
|
||||
{
|
||||
insertLines({"{bar();",
|
||||
"foo();",
|
||||
"}"});
|
||||
|
||||
extendedIndenter.indentBlock(doc.findBlockByNumber(1), ';', TextEditor::TabSettings(), 14);
|
||||
|
||||
ASSERT_THAT(documentLines(), ElementsAre("{",
|
||||
" bar();",
|
||||
" foo();",
|
||||
"}"));
|
||||
}
|
||||
|
||||
TEST_F(ClangFormat, IndentAndFormatCompleteStatementOnClosingScope)
|
||||
{
|
||||
insertLines({"{bar();",
|
||||
"foo();",
|
||||
"}"});
|
||||
|
||||
extendedIndenter.indentBlock(doc.findBlockByNumber(1), '}', TextEditor::TabSettings(), 16);
|
||||
|
||||
ASSERT_THAT(documentLines(), ElementsAre("{",
|
||||
" bar();",
|
||||
" foo();",
|
||||
"}"));
|
||||
}
|
||||
|
||||
TEST_F(ClangFormat, FormatBasicFile)
|
||||
{
|
||||
insertLines({"int main()",
|
||||
|
||||
Reference in New Issue
Block a user