aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index 88e6445..7f538f1 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -2117,6 +2117,22 @@ TEST(CommandLineTest, ConsumeAfterTwoPositionals) {
EXPECT_TRUE(Errs.empty());
}
+TEST(CommandLineTest, ConsumeOptionalString) {
+ cl::ResetCommandLineParser();
+
+ StackOption<std::optional<std::string>, cl::opt<std::optional<std::string>>>
+ Input("input");
+
+ const char *Args[] = {"prog", "--input=\"value\""};
+
+ std::string Errs;
+ raw_string_ostream OS(Errs);
+ ASSERT_TRUE(cl::ParseCommandLineOptions(2, Args, StringRef(), &OS));
+ ASSERT_TRUE(Input.has_value());
+ EXPECT_EQ("\"value\"", *Input);
+ EXPECT_TRUE(Errs.empty());
+}
+
TEST(CommandLineTest, ResetAllOptionOccurrences) {
cl::ResetCommandLineParser();