1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 12:13:52 +00:00

add extra test

This commit is contained in:
Henry Fredrick Schreiner 2018-11-24 23:40:18 +02:00
parent afa7a45665
commit bd4dc91184
2 changed files with 15 additions and 1 deletions

View File

@ -1389,7 +1389,7 @@ class App {
}
}
/// Return True if a help flag detected (checks all parents)
/// Return True if a help flag detected (checks all parents) (only run if help called before subcommand)
bool _any_help_flag() const {
bool result = false;
const Option *help_ptr = get_help_ptr();

View File

@ -438,6 +438,8 @@ struct SubcommandProgram : public TApp {
int count;
SubcommandProgram() {
app.set_help_all_flag("--help-all");
start = app.add_subcommand("start", "Start prog");
stop = app.add_subcommand("stop", "Stop prog");
@ -541,6 +543,18 @@ TEST_F(SubcommandProgram, HelpOrder) {
EXPECT_THROW(run(), CLI::CallForHelp);
}
TEST_F(SubcommandProgram, HelpAllOrder) {
args = {"--help-all"};
EXPECT_THROW(run(), CLI::CallForAllHelp);
args = {"start", "--help-all"};
EXPECT_THROW(run(), CLI::CallForAllHelp);
args = {"--help-all", "start"};
EXPECT_THROW(run(), CLI::CallForAllHelp);
}
TEST_F(SubcommandProgram, Callbacks) {
start->callback([]() { throw CLI::Success(); });