aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
authorJoachim Meyer <joachim@joameyer.de>2020-12-17 23:58:13 +0100
committerJoachim Meyer <joachim@joameyer.de>2021-02-04 10:14:44 +0100
commite3f02302e318837d2421c6425450f04ae0a82b90 (patch)
treefcfc5744ffdbbd9853e91587477acc68ac15ed18 /llvm/unittests/Support/CommandLineTest.cpp
parent6c59dc474dcc6db6daa1dad8bccc098bce4942ee (diff)
downloadllvm-e3f02302e318837d2421c6425450f04ae0a82b90.zip
llvm-e3f02302e318837d2421c6425450f04ae0a82b90.tar.gz
llvm-e3f02302e318837d2421c6425450f04ae0a82b90.tar.bz2
[Support] Indent multi-line descr of enum cli options.
As noted in https://reviews.llvm.org/D93459, the formatting of multi-line descriptions of clEnumValN and the likes is unfavorable. Thus this patch adds support for correctly indenting these. Reviewed By: serge-sans-paille Differential Revision: https://reviews.llvm.org/D93494
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index a05f389..4accdc5 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -1263,6 +1263,28 @@ TEST_F(PrintOptionInfoTest, PrintOptionInfoEmptyValueDescription) {
// clang-format on
}
+TEST_F(PrintOptionInfoTest, PrintOptionInfoMultilineValueDescription) {
+ std::string Output =
+ runTest(cl::ValueRequired,
+ cl::values(clEnumValN(OptionValue::Val, "v1",
+ "This is the first enum value\n"
+ "which has a really long description\n"
+ "thus it is multi-line."),
+ clEnumValN(OptionValue::Val, "",
+ "This is an unnamed enum value option\n"
+ "Should be indented as well")));
+
+ // clang-format off
+ EXPECT_EQ(Output,
+ (" --" + Opt + "=<value> - " + HelpText + "\n"
+ " =v1 - This is the first enum value\n"
+ " which has a really long description\n"
+ " thus it is multi-line.\n"
+ " =<empty> - This is an unnamed enum value option\n"
+ " Should be indented as well\n").str());
+ // clang-format on
+}
+
class GetOptionWidthTest : public ::testing::Test {
public:
enum class OptionValue { Val };