1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-08 15:53:51 +00:00

run some tests and fixes for C++20 (#663)

This commit is contained in:
Philip Top 2021-11-01 20:10:44 -07:00 committed by GitHub
parent 16919dd1b2
commit 728ac3a877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 6 deletions

View File

@ -102,6 +102,9 @@ jobs:
gcc9: gcc9:
containerImage: gcc:9 containerImage: gcc:9
cli11.std: 17 cli11.std: 17
gcc11:
containerImage: gcc:11
cli11.std: 20
gcc8: gcc8:
containerImage: gcc:8 containerImage: gcc:8
cli11.std: 17 cli11.std: 17

View File

@ -799,9 +799,10 @@ class App {
/// Add option for flag with integer result - defaults to allowing multiple passings, but can be forced to one /// Add option for flag with integer result - defaults to allowing multiple passings, but can be forced to one
/// if `multi_option_policy(CLI::MultiOptionPolicy::Throw)` is used. /// if `multi_option_policy(CLI::MultiOptionPolicy::Throw)` is used.
template <typename T, template <
enable_if_t<std::is_constructible<T, std::int64_t>::value && !is_bool<T>::value, detail::enabler> = typename T,
detail::dummy> enable_if_t<std::is_constructible<T, std::int64_t>::value && !std::is_const<T>::value && !is_bool<T>::value,
detail::enabler> = detail::dummy>
Option *add_flag(std::string flag_name, Option *add_flag(std::string flag_name,
T &flag_count, ///< A variable holding the count T &flag_count, ///< A variable holding the count
std::string flag_description = "") { std::string flag_description = "") {

View File

@ -2308,3 +2308,11 @@ TEST_CASE_METHOD(TApp, "logFormSingleDash", "[app]") {
CHECK(veryverbose); CHECK(veryverbose);
CHECK(veryveryverbose); CHECK(veryveryverbose);
} }
TEST_CASE("C20_compile", "simple") {
CLI::App app{"test"};
auto flag = app.add_flag("--flag", "desc");
app.parse("--flag");
CHECK_FALSE(flag->empty());
}

View File

@ -239,16 +239,19 @@ TEST_CASE_METHOD(TApp, "BoostOptionalEnumTest", "[optional]") {
auto dstring = optptr->get_default_str(); auto dstring = optptr->get_default_str();
CHECK(dstring.empty()); CHECK(dstring.empty());
run(); run();
CHECK(!opt); auto checkOpt = static_cast<bool>(opt);
CHECK_FALSE(checkOpt);
args = {"-v", "3"}; args = {"-v", "3"};
run(); run();
CHECK(opt); checkOpt = static_cast<bool>(opt);
CHECK(checkOpt);
CHECK(*opt == eval::val3); CHECK(*opt == eval::val3);
opt = {}; opt = {};
args = {"--val", "1"}; args = {"--val", "1"};
run(); run();
CHECK(opt); checkOpt = static_cast<bool>(opt);
CHECK(checkOpt);
CHECK(*opt == eval::val1); CHECK(*opt == eval::val1);
} }