aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Format/FormatTestComments.cpp
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2018-07-30 08:45:45 +0000
committerKrasimir Georgiev <krasimir@google.com>2018-07-30 08:45:45 +0000
commit6a5c95bd6643a78b5bc1df7397444138956ffbc0 (patch)
treee7409e3697234de49f96f0acda6079bf858f8f40 /clang/unittests/Format/FormatTestComments.cpp
parente5899447b40355ad0a79db6e04f8f1d5293d8fd1 (diff)
downloadllvm-6a5c95bd6643a78b5bc1df7397444138956ffbc0.zip
llvm-6a5c95bd6643a78b5bc1df7397444138956ffbc0.tar.gz
llvm-6a5c95bd6643a78b5bc1df7397444138956ffbc0.tar.bz2
[clang-format] Indent after breaking Javadoc annotated line
Summary: This patch makes clang-format indent the subsequent lines created by breaking a long javadoc annotated line. Reviewers: mprobst Reviewed By: mprobst Subscribers: acoomans, cfe-commits Differential Revision: https://reviews.llvm.org/D49797 llvm-svn: 338232
Diffstat (limited to 'clang/unittests/Format/FormatTestComments.cpp')
-rw-r--r--clang/unittests/Format/FormatTestComments.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp
index cacd202..2b07ded 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -3105,6 +3105,106 @@ TEST_F(FormatTestComments, ReflowBackslashCrash) {
// clang-format on
}
+TEST_F(FormatTestComments, IndentsLongJavadocAnnotatedLines) {
+ FormatStyle Style = getGoogleStyle(FormatStyle::LK_Java);
+ Style.ColumnLimit = 60;
+ FormatStyle Style20 = getGoogleStyle(FormatStyle::LK_Java);
+ Style20.ColumnLimit = 20;
+ EXPECT_EQ(
+ "/**\n"
+ " * @param x long long long long long long long long long\n"
+ " * long\n"
+ " */\n",
+ format("/**\n"
+ " * @param x long long long long long long long long long long\n"
+ " */\n",
+ Style));
+ EXPECT_EQ("/**\n"
+ " * @param x long long long long long long long long long\n"
+ " * long long long long long long long long long long\n"
+ " */\n",
+ format("/**\n"
+ " * @param x long long long long long long long long long "
+ "long long long long long long long long long long\n"
+ " */\n",
+ Style));
+ EXPECT_EQ("/**\n"
+ " * @param x long long long long long long long long long\n"
+ " * long long long long long long long long long long\n"
+ " * long\n"
+ " */\n",
+ format("/**\n"
+ " * @param x long long long long long long long long long "
+ "long long long long long long long long long long long\n"
+ " */\n",
+ Style));
+ EXPECT_EQ(
+ "/**\n"
+ " * Sentence that\n"
+ " * should be broken.\n"
+ " * @param short\n"
+ " * keep indentation\n"
+ " */\n", format(
+ "/**\n"
+ " * Sentence that should be broken.\n"
+ " * @param short\n"
+ " * keep indentation\n"
+ " */\n", Style20));
+
+ EXPECT_EQ("/**\n"
+ " * @param l1 long1\n"
+ " * to break\n"
+ " * @param l2 long2\n"
+ " * to break\n"
+ " */\n",
+ format("/**\n"
+ " * @param l1 long1 to break\n"
+ " * @param l2 long2 to break\n"
+ " */\n",
+ Style20));
+
+ EXPECT_EQ("/**\n"
+ " * @param xx to\n"
+ " * break\n"
+ " * no reflow\n"
+ " */\n",
+ format("/**\n"
+ " * @param xx to break\n"
+ " * no reflow\n"
+ " */\n",
+ Style20));
+
+ EXPECT_EQ("/**\n"
+ " * @param xx to\n"
+ " * break yes\n"
+ " * reflow\n"
+ " */\n",
+ format("/**\n"
+ " * @param xx to break\n"
+ " * yes reflow\n"
+ " */\n",
+ Style20));
+
+ FormatStyle JSStyle20 = getGoogleStyle(FormatStyle::LK_JavaScript);
+ JSStyle20.ColumnLimit = 20;
+ EXPECT_EQ("/**\n"
+ " * @param l1 long1\n"
+ " * to break\n"
+ " */\n",
+ format("/**\n"
+ " * @param l1 long1 to break\n"
+ " */\n",
+ JSStyle20));
+ EXPECT_EQ("/**\n"
+ " * @param {l1 long1\n"
+ " * to break}\n"
+ " */\n",
+ format("/**\n"
+ " * @param {l1 long1 to break}\n"
+ " */\n",
+ JSStyle20));
+}
+
} // end namespace
} // end namespace format
} // end namespace clang