mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 20:23:55 +00:00
Adding one more test
This commit is contained in:
parent
239d3b1c31
commit
cd98e70c9e
@ -484,14 +484,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check to see if a subcommand is part of this command (text version)
|
/// Check to see if a subcommand is part of this command (text version)
|
||||||
App* get_subcommand(std::string subcom) {
|
|
||||||
for(const App_p &subcomptr : subcommands_)
|
|
||||||
if(subcomptr->check_name(subcom))
|
|
||||||
return subcomptr.get();
|
|
||||||
throw CLI::OptionNotFound(subcom);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check to see if a subcommand is part of this command (text version, const)
|
|
||||||
App* get_subcommand(std::string subcom) const {
|
App* get_subcommand(std::string subcom) const {
|
||||||
for(const App_p &subcomptr : subcommands_)
|
for(const App_p &subcomptr : subcommands_)
|
||||||
if(subcomptr->check_name(subcom))
|
if(subcomptr->check_name(subcom))
|
||||||
|
@ -4,6 +4,10 @@ TEST_F(TApp, BasicSubcommands) {
|
|||||||
auto sub1 = app.add_subcommand("sub1");
|
auto sub1 = app.add_subcommand("sub1");
|
||||||
auto sub2 = app.add_subcommand("sub2");
|
auto sub2 = app.add_subcommand("sub2");
|
||||||
|
|
||||||
|
EXPECT_EQ(sub1, app.get_subcommand(sub1));
|
||||||
|
EXPECT_EQ(sub1, app.get_subcommand("sub1"));
|
||||||
|
EXPECT_THROW(app.get_subcommand("sub3"), CLI::OptionNotFound);
|
||||||
|
|
||||||
run();
|
run();
|
||||||
EXPECT_EQ((size_t) 0, app.get_subcommands().size());
|
EXPECT_EQ((size_t) 0, app.get_subcommands().size());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user