mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 12:13:52 +00:00
Adding test for #87
This commit is contained in:
parent
4f6bbba317
commit
0959430e57
@ -1,6 +1,7 @@
|
||||
## In progress
|
||||
## Version 1.5: Optional
|
||||
|
||||
This version has some internal cleanup and improved support for the newest compilers.
|
||||
|
||||
This version introduced support for optionals, along with clarification and examples of custom conversion overloads. Enums now have been dropped from the automatic conversion system, allowing explicit protection for out-of-range ints (or a completely custom conversion). This version has some internal cleanup and improved support for the newest compilers. Several bugs were fixed, as well.
|
||||
|
||||
Note: This is the final release with `requires`, please switch to `needs`.
|
||||
|
||||
|
@ -388,7 +388,8 @@ Significant features and/or improvements to the code were contributed by:
|
||||
* [Lucas Czech](https://github.com/lczech)
|
||||
* [Mathias Soeken](https://github.com/msoeken)
|
||||
* [Nathan Hourt](https://github.com/nathanhourt)
|
||||
|
||||
* [Stéphane Del Pino](https://github.com/delpinux)
|
||||
* [Anton](https://github.com/SX91)
|
||||
|
||||
CLI11 was developed at the [University of Cincinnati] to support of the [GooFit] library under [NSF Award 1414736]. Version 0.9 was featured in a [DIANA/HEP] meeting at CERN ([see the slides][DIANA slides]). Please give it a try! Feedback is always welcome.
|
||||
|
||||
|
@ -1458,3 +1458,21 @@ TEST_F(TApp, ThrowingTransform) {
|
||||
EXPECT_EQ(e.what(), std::string("--mess: My Message"));
|
||||
}
|
||||
}
|
||||
|
||||
// #87
|
||||
TEST_F(TApp, CustomDoubleOption) {
|
||||
|
||||
std::pair<int, float> custom_opt;
|
||||
|
||||
auto opt = app.add_option("posit", [&custom_opt](CLI::results_t vals) {
|
||||
custom_opt = {stol(vals.at(0)), stod(vals.at(1))};
|
||||
return true;
|
||||
});
|
||||
opt->set_custom_option("INT FLOAT", 2);
|
||||
|
||||
args = {"12", "1.5"};
|
||||
|
||||
run();
|
||||
EXPECT_EQ(custom_opt.first, 12);
|
||||
EXPECT_FLOAT_EQ(custom_opt.second, 1.5);
|
||||
}
|
||||
|
@ -461,3 +461,19 @@ TEST_F(CapturedHelp, RepacedError) {
|
||||
EXPECT_THAT(err.str(), HasSubstr("Thing"));
|
||||
EXPECT_THAT(err.str(), HasSubstr("Usage"));
|
||||
}
|
||||
|
||||
// #87
|
||||
TEST(THelp, CustomDoubleOption) {
|
||||
|
||||
std::pair<int, float> custom_opt;
|
||||
|
||||
CLI::App app;
|
||||
|
||||
auto opt = app.add_option("posit", [&custom_opt](CLI::results_t vals) {
|
||||
custom_opt = {stol(vals.at(0)), stod(vals.at(1))};
|
||||
return true;
|
||||
});
|
||||
opt->set_custom_option("INT FLOAT", 2);
|
||||
|
||||
EXPECT_THAT(app.help(), Not(HasSubstr("x 2")));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user