summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-05-07 09:23:05 +0000
committerDaniel Jasper <djasper@google.com>2014-05-07 09:23:05 +0000
commit8acf822b6fdebddc08d9f1b3614e83491a43b32c (patch)
tree908ea523c7f7b25bbc5ecf010a3fdf33f9cb0b4c /clang/unittests/Format/FormatTest.cpp
parent5d174547a9788ecb15ba33abbb4ef2e1abee0ba3 (diff)
downloadbcm5719-llvm-8acf822b6fdebddc08d9f1b3614e83491a43b32c.tar.gz
bcm5719-llvm-8acf822b6fdebddc08d9f1b3614e83491a43b32c.zip
clang-format: Fix corner cases for comments in if conditions.
Before: if ( // a x + 3) { .. After: if ( // a x + 3) { .. llvm-svn: 208175
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index bd7e23f60b8..75f1854666c 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -390,6 +390,11 @@ TEST_F(FormatTest, ElseIf) {
"else {\n"
" g()\n"
"}");
+
+ verifyFormat("if (a) {\n"
+ "} else if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaa)) {\n"
+ "}");
}
TEST_F(FormatTest, FormatsForLoop) {
@@ -847,6 +852,18 @@ TEST_F(FormatTest, UnderstandsSingleLineComments) {
" int i; /* iiiiiiiiiiiiiiiiiiiii */ \\\n"
" int jjjjjjjjjjjjjjjjjjjjjjjj; /* */",
getLLVMStyleWithColumns(61));
+
+ verifyFormat("if ( // This is some comment\n"
+ " x + 3) {\n"
+ "}");
+ EXPECT_EQ("if ( // This is some comment\n"
+ " // spanning two lines\n"
+ " x + 3) {\n"
+ "}",
+ format("if( // This is some comment\n"
+ " // spanning two lines\n"
+ " x + 3) {\n"
+ "}"));
}
TEST_F(FormatTest, KeepsParameterWithTrailingCommentsOnTheirOwnLine) {
OpenPOWER on IntegriCloud