diff options
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r-- | llvm/unittests/Support/CommandLineTest.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp index 9b24c1e40bc..bc4fb5ab122 100644 --- a/llvm/unittests/Support/CommandLineTest.cpp +++ b/llvm/unittests/Support/CommandLineTest.cpp @@ -476,4 +476,27 @@ TEST(CommandLineTest, RemoveFromAllSubCommands) { EXPECT_FALSE(cl::ParseCommandLineOptions(3, args2, nullptr, true)); } +TEST(CommandLineTest, GetRegisteredSubcommands) { + cl::ResetCommandLineParser(); + + StackSubCommand SC1("sc1", "First Subcommand"); + StackSubCommand SC2("sc2", "Second subcommand"); + + const char *args0[] = {"prog", "sc1"}; + const char *args1[] = {"prog", "sc2"}; + + EXPECT_TRUE(cl::ParseCommandLineOptions(2, args0, nullptr, true)); + for (auto *S : cl::getRegisteredSubcommands()) { + if (*S) + EXPECT_STREQ("sc1", S->getName()); + } + + cl::ResetAllOptionOccurrences(); + EXPECT_TRUE(cl::ParseCommandLineOptions(2, args1, nullptr, true)); + for (auto *S : cl::getRegisteredSubcommands()) { + if (*S) + EXPECT_STREQ("sc2", S->getName()); + } +} + } // anonymous namespace |