Commit 728ac3a877d0ae9f6733a710165ad7acfd4c107a
Committed by
GitHub
1 parent
16919dd1
run some tests and fixes for C++20 (#663)
Showing
4 changed files
with
21 additions
and
6 deletions
azure-pipelines.yml
include/CLI/App.hpp
| ... | ... | @@ -799,9 +799,10 @@ class App { |
| 799 | 799 | |
| 800 | 800 | /// Add option for flag with integer result - defaults to allowing multiple passings, but can be forced to one |
| 801 | 801 | /// if `multi_option_policy(CLI::MultiOptionPolicy::Throw)` is used. |
| 802 | - template <typename T, | |
| 803 | - enable_if_t<std::is_constructible<T, std::int64_t>::value && !is_bool<T>::value, detail::enabler> = | |
| 804 | - detail::dummy> | |
| 802 | + template < | |
| 803 | + typename T, | |
| 804 | + enable_if_t<std::is_constructible<T, std::int64_t>::value && !std::is_const<T>::value && !is_bool<T>::value, | |
| 805 | + detail::enabler> = detail::dummy> | |
| 805 | 806 | Option *add_flag(std::string flag_name, |
| 806 | 807 | T &flag_count, ///< A variable holding the count |
| 807 | 808 | std::string flag_description = "") { | ... | ... |
tests/AppTest.cpp
| ... | ... | @@ -2308,3 +2308,11 @@ TEST_CASE_METHOD(TApp, "logFormSingleDash", "[app]") { |
| 2308 | 2308 | CHECK(veryverbose); |
| 2309 | 2309 | CHECK(veryveryverbose); |
| 2310 | 2310 | } |
| 2311 | + | |
| 2312 | +TEST_CASE("C20_compile", "simple") { | |
| 2313 | + CLI::App app{"test"}; | |
| 2314 | + auto flag = app.add_flag("--flag", "desc"); | |
| 2315 | + | |
| 2316 | + app.parse("--flag"); | |
| 2317 | + CHECK_FALSE(flag->empty()); | |
| 2318 | +} | ... | ... |
tests/OptionalTest.cpp
| ... | ... | @@ -239,16 +239,19 @@ TEST_CASE_METHOD(TApp, "BoostOptionalEnumTest", "[optional]") { |
| 239 | 239 | auto dstring = optptr->get_default_str(); |
| 240 | 240 | CHECK(dstring.empty()); |
| 241 | 241 | run(); |
| 242 | - CHECK(!opt); | |
| 242 | + auto checkOpt = static_cast<bool>(opt); | |
| 243 | + CHECK_FALSE(checkOpt); | |
| 243 | 244 | |
| 244 | 245 | args = {"-v", "3"}; |
| 245 | 246 | run(); |
| 246 | - CHECK(opt); | |
| 247 | + checkOpt = static_cast<bool>(opt); | |
| 248 | + CHECK(checkOpt); | |
| 247 | 249 | CHECK(*opt == eval::val3); |
| 248 | 250 | opt = {}; |
| 249 | 251 | args = {"--val", "1"}; |
| 250 | 252 | run(); |
| 251 | - CHECK(opt); | |
| 253 | + checkOpt = static_cast<bool>(opt); | |
| 254 | + CHECK(checkOpt); | |
| 252 | 255 | CHECK(*opt == eval::val1); |
| 253 | 256 | } |
| 254 | 257 | ... | ... |