mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-30 04:33:53 +00:00
Adding and fixing a test for single name
This commit is contained in:
parent
e8b15a2901
commit
851f8dc83d
@ -362,9 +362,9 @@ class Option : public OptionBase<Option> {
|
|||||||
/// The most discriptive name available
|
/// The most discriptive name available
|
||||||
std::string single_name() const {
|
std::string single_name() const {
|
||||||
if(!lnames_.empty())
|
if(!lnames_.empty())
|
||||||
return lnames_[0];
|
return std::string("--") + lnames_[0];
|
||||||
else if(!snames_.empty())
|
else if(!snames_.empty())
|
||||||
return snames_[0];
|
return std::string("-") + snames_[0];
|
||||||
else
|
else
|
||||||
return pname_;
|
return pname_;
|
||||||
}
|
}
|
||||||
|
@ -354,6 +354,20 @@ TEST(THelp, CustomHelp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(THelp, NiceName) {
|
||||||
|
CLI::App app;
|
||||||
|
|
||||||
|
int x;
|
||||||
|
auto long_name = app.add_option("-s,--long,-q,--other,that", x);
|
||||||
|
auto short_name = app.add_option("more,-x,-y", x);
|
||||||
|
auto positional = app.add_option("posit", x);
|
||||||
|
|
||||||
|
EXPECT_EQ(long_name->single_name(), "--long");
|
||||||
|
EXPECT_EQ(short_name->single_name(), "-x");
|
||||||
|
EXPECT_EQ(positional->single_name(), "posit");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
TEST(Exit, ErrorWithHelp) {
|
TEST(Exit, ErrorWithHelp) {
|
||||||
CLI::App app{"My prog"};
|
CLI::App app{"My prog"};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user