Skip to content

Commit

Permalink
add coverage exclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
phlptp committed Oct 5, 2024
1 parent 8a26698 commit 068e9b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/CLI/TypeTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,9 @@ bool integral_conversion(const std::string &input, T &output) noexcept {
return (val == (input.c_str() + input.size()) && static_cast<std::uint64_t>(output) == output_ll);
}
if(input.compare(0, 2, "0b") == 0 || input.compare(0, 2, "0B") == 0) {
// LCOV_EXCL_START
// In some new compilers including the coverage testing one binary strings are handled properly in strtoull automatically
// so this coverage is missing but is well tested in other compilers
val = nullptr;
errno = 0;
output_ll = std::strtoull(input.c_str() + 2, &val, 2);
Expand All @@ -923,6 +926,7 @@ bool integral_conversion(const std::string &input, T &output) noexcept {
}
output = static_cast<T>(output_ll);
return (val == (input.c_str() + input.size()) && static_cast<std::uint64_t>(output) == output_ll);
// LCOV_EXCL_STOP
}
return false;
}
Expand Down Expand Up @@ -966,6 +970,9 @@ bool integral_conversion(const std::string &input, T &output) noexcept {
return (val == (input.c_str() + input.size()) && static_cast<std::int64_t>(output) == output_ll);
}
if(input.compare(0, 2, "0b") == 0 || input.compare(0, 2, "0B") == 0) {
// LCOV_EXCL_START
// In some new compilers including the coverage testing one binary strings are handled properly in strtoll automatically
// so this coverage is missing but is well tested in other compilers
val = nullptr;
errno = 0;
output_ll = std::strtoll(input.c_str() + 2, &val, 2);
Expand All @@ -974,6 +981,7 @@ bool integral_conversion(const std::string &input, T &output) noexcept {
}
output = static_cast<T>(output_ll);
return (val == (input.c_str() + input.size()) && static_cast<std::int64_t>(output) == output_ll);
// LCOV_EXCL_STOP
}
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions include/CLI/impl/App_inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2265,11 +2265,14 @@ CLI11_INLINE void retire_option(App *app, Option *opt) {
->expected(option_copy->get_expected_min(), option_copy->get_expected_max())
->allow_extra_args(option_copy->get_allow_extra_args());

// LCOV_EXCL_START
// something odd with coverage on new compilers
Validator retired_warning{[opt2](std::string &) {
std::cout << "WARNING " << opt2->get_name() << " is retired and has no effect\n";
return std::string();
},
""};
// LCOV_EXCL_STOP
retired_warning.application_index(0);
opt2->check(retired_warning);
}
Expand All @@ -2287,11 +2290,14 @@ CLI11_INLINE void retire_option(App *app, const std::string &option_name) {
->type_name("RETIRED")
->expected(0, 1)
->default_str("RETIRED");
// LCOV_EXCL_START
// something odd with coverage on new compilers
Validator retired_warning{[opt2](std::string &) {
std::cout << "WARNING " << opt2->get_name() << " is retired and has no effect\n";
return std::string();
},
""};
//LCOV_EXCL_STOP
retired_warning.application_index(0);
opt2->check(retired_warning);
}
Expand Down

0 comments on commit 068e9b2

Please sign in to comment.