aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-03-27 11:52:18 +0000
committerAlexander Kornienko <alexfh@google.com>2013-03-27 11:52:18 +0000
commit5262dd909a34f4c3e3f061009679fabb77b43ba4 (patch)
treebb6137d6866038975308ebd453dfb4f948d3cf32 /unittests
parentf2ff5bdef011a060994afe84131b3134c5ffd8bc (diff)
downloadclang-5262dd909a34f4c3e3f061009679fabb77b43ba4.tar.gz
Split line comments
Summary: Split line comments that exceed column limit + fixed leading whitespace handling when splitting block comments. Reviewers: djasper, klimek Reviewed By: djasper CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D577 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178133 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTest.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 5988a90596..daeb1dbaf0 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -681,6 +681,26 @@ TEST_F(FormatTest, AlignsMultiLineComments) {
" */"));
}
+TEST_F(FormatTest, SplitsLongCxxComments) {
+ EXPECT_EQ("// A comment that\n"
+ "// doesn't fit on\n"
+ "// one line",
+ format("// A comment that doesn't fit on one line",
+ getLLVMStyleWithColumns(20)));
+ EXPECT_EQ("if (true) // A comment that\n"
+ " // doesn't fit on\n"
+ " // one line",
+ format("if (true) // A comment that doesn't fit on one line ",
+ getLLVMStyleWithColumns(30)));
+ EXPECT_EQ("// Don't_touch_leading_whitespace",
+ format("// Don't_touch_leading_whitespace",
+ getLLVMStyleWithColumns(20)));
+ EXPECT_EQ(
+ "//Don't add leading\n"
+ "//whitespace",
+ format("//Don't add leading whitespace", getLLVMStyleWithColumns(20)));
+}
+
TEST_F(FormatTest, SplitsLongLinesInComments) {
EXPECT_EQ("/* This is a long\n"
" * comment that\n"
@@ -727,10 +747,10 @@ TEST_F(FormatTest, SplitsLongLinesInComments) {
" */",
getLLVMStyleWithColumns(20)));
EXPECT_EQ("/*\n"
- " * This_comment_can_not_be_broken_into_lines\n"
+ " * This_comment_can_not_be_broken_into_lines\n"
" */",
format("/*\n"
- " * This_comment_can_not_be_broken_into_lines\n"
+ " * This_comment_can_not_be_broken_into_lines\n"
" */",
getLLVMStyleWithColumns(20)));
EXPECT_EQ("{\n"
@@ -1166,13 +1186,13 @@ TEST_F(FormatTest, HandlePreprocessorDirectiveContext) {
"#define A( \\\n"
" A, B)\n"
"#include \"b.h\"\n"
- "// some comment\n",
+ "// somecomment\n",
format(" // some comment\n"
" #include \"a.h\"\n"
"#define A(A,\\\n"
" B)\n"
" #include \"b.h\"\n"
- " // some comment\n",
+ " // somecomment\n",
getLLVMStyleWithColumns(13)));
}
@@ -2442,7 +2462,7 @@ TEST_F(FormatTest, IncorrectCodeMissingSemicolon) {
TEST_F(FormatTest, IndentationWithinColumnLimitNotPossible) {
verifyFormat("int aaaaaaaa =\n"
- " // Overly long comment\n"
+ " // Overlylongcomment\n"
" b;",
getLLVMStyleWithColumns(20));
verifyFormat("function(\n"