summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-09-06 07:54:20 +0000
committerDaniel Jasper <djasper@google.com>2013-09-06 07:54:20 +0000
commit1c5d9df8d1af0f266923edba8fcb367a51a03d26 (patch)
tree390bc8bac153490c628dc129b01b5f34bd50ec32 /clang/unittests/Format/FormatTest.cpp
parent3b1cc9b858462aa190e3b27089f6f9f8c9dd9bb6 (diff)
downloadbcm5719-llvm-1c5d9df8d1af0f266923edba8fcb367a51a03d26.tar.gz
bcm5719-llvm-1c5d9df8d1af0f266923edba8fcb367a51a03d26.zip
clang-format: Fix comment formatting bugs in nested blocks.
This fixes two issues: 1) The indent of a line comment was not adapted to the subsequent statement as it would be outside of a nested block. 2) A missing DryRun flag caused actualy breaks to be inserted in overly long comments while trying to come up with the best line breaking decisions. llvm-svn: 190123
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 6d953eb3018..3eaa69a8b6c 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -564,6 +564,17 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
" }\n"
"#undef OPERATION_CASE\n"
"}");
+ verifyFormat("DEBUG({\n"
+ " switch (x) {\n"
+ " case A:\n"
+ " f();\n"
+ " break;\n"
+ " // On B:\n"
+ " case B:\n"
+ " g();\n"
+ " break;\n"
+ " }\n"
+ "});");
}
TEST_F(FormatTest, FormatsLabels) {
@@ -2241,6 +2252,24 @@ TEST_F(FormatTest, LayoutNestedBlocks) {
" for (int i = 0; i < 10; ++i)\n"
" return;\n"
"}");
+ verifyFormat("call(parameter, {\n"
+ " something();\n"
+ " // Comment using all columns.\n"
+ " somethingelse();\n"
+ "});",
+ getLLVMStyleWithColumns(40));
+ EXPECT_EQ("call(parameter, {\n"
+ " something();\n"
+ " // Comment too\n"
+ " // looooooooooong.\n"
+ " somethingElse();\n"
+ "});",
+ format("call(parameter, {\n"
+ " something();\n"
+ " // Comment too looooooooooong.\n"
+ " somethingElse();\n"
+ "});",
+ getLLVMStyleWithColumns(29)));
}
TEST_F(FormatTest, PutEmptyBlocksIntoOneLine) {
OpenPOWER on IntegriCloud