diff --git a/.codecov.yml b/.codecov.yml index 61c2e2f21..7ba78c162 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -5,3 +5,11 @@ ignore: - "docs" - "test_package" - "fuzz" + +parsers: + gcov: + branch_detection: + conditional: yes + loop: yes + method: no + macro: no diff --git a/include/CLI/TypeTools.hpp b/include/CLI/TypeTools.hpp index 780bd2f44..63294d9c4 100644 --- a/include/CLI/TypeTools.hpp +++ b/include/CLI/TypeTools.hpp @@ -904,7 +904,7 @@ bool integral_conversion(const std::string &input, T &output) noexcept { nstring.erase(std::remove(nstring.begin(), nstring.end(), '\''), nstring.end()); return integral_conversion(nstring, output); } - if(input.compare(0, 2, "0o") == 0) { + if(input.compare(0, 2, "0o") == 0||input.compare(0, 2, "0O") == 0) { val = nullptr; errno = 0; output_ll = std::strtoull(input.c_str() + 2, &val, 8); @@ -914,7 +914,7 @@ bool integral_conversion(const std::string &input, T &output) noexcept { output = static_cast(output_ll); return (val == (input.c_str() + input.size()) && static_cast(output) == output_ll); } - if(input.compare(0, 2, "0b") == 0) { + if(input.compare(0, 2, "0b") == 0||input.compare(0, 2, "0B") == 0) { val = nullptr; errno = 0; output_ll = std::strtoull(input.c_str() + 2, &val, 2); @@ -955,7 +955,7 @@ bool integral_conversion(const std::string &input, T &output) noexcept { nstring.erase(std::remove(nstring.begin(), nstring.end(), '\''), nstring.end()); return integral_conversion(nstring, output); } - if(input.compare(0, 2, "0o") == 0) { + if(input.compare(0, 2, "0o") == 0 || input.compare(0, 2, "0O")==0) { val = nullptr; errno = 0; output_ll = std::strtoll(input.c_str() + 2, &val, 8); @@ -965,7 +965,7 @@ bool integral_conversion(const std::string &input, T &output) noexcept { output = static_cast(output_ll); return (val == (input.c_str() + input.size()) && static_cast(output) == output_ll); } - if(input.compare(0, 2, "0b") == 0) { + if(input.compare(0, 2, "0b") == 0 ||input.compare(0, 2, "0B")==0) { val = nullptr; errno = 0; output_ll = std::strtoll(input.c_str() + 2, &val, 2); diff --git a/include/CLI/impl/Formatter_inl.hpp b/include/CLI/impl/Formatter_inl.hpp index cdd6c258a..9a5e9f7ba 100644 --- a/include/CLI/impl/Formatter_inl.hpp +++ b/include/CLI/impl/Formatter_inl.hpp @@ -156,7 +156,7 @@ CLI11_INLINE std::string Formatter::make_help(const App *app, std::string name, // This immediately forwards to the make_expanded method. This is done this way so that subcommands can // have overridden formatters if(mode == AppFormatMode::Sub) - return make_expanded(app, AppFormatMode::Normal); + return make_expanded(app, mode); std::stringstream out; if((app->get_name().empty()) && (app->get_parent() != nullptr)) { diff --git a/tests/OptionTypeTest.cpp b/tests/OptionTypeTest.cpp index b7f99868b..5e25a9290 100644 --- a/tests/OptionTypeTest.cpp +++ b/tests/OptionTypeTest.cpp @@ -280,6 +280,8 @@ static const std::map testValuesInt{ {"-995'862'275", -995862275}, {"0b11010110", 0xD6}, {"0b1101'0110", 0xD6}, + {"0B11010110", 0xD6}, + {"0B1101'0110", 0xD6}, {"1_2_3_4_5", 12345}, }; @@ -309,6 +311,10 @@ TEST_CASE_METHOD(TApp, "intConversionsErange", "[optiontype]") { args = {"--val", "0b1011000001101011001100110011111000101010101011111111111111111111111001010111011100"}; CHECK_THROWS_AS(run(), CLI::ParseError); + + args = {"--val", "0B1011000001101011001100110011111000101010101011111111111111111111111001010111011100"}; + + CHECK_THROWS_AS(run(), CLI::ParseError); } static const std::map testValuesUInt{ @@ -329,6 +335,8 @@ static const std::map testValuesUInt{ {"995'862'275", 995862275}, {"0b11010110", 0xD6}, {"0b1101'0110", 0xD6}, + {"0B11010110", 0xD6}, + {"0B1101'0110", 0xD6}, {"1_2_3_4_5", 12345}, }; @@ -358,6 +366,10 @@ TEST_CASE_METHOD(TApp, "uintConversionsErange", "[optiontype]") { args = {"--val", "0b1011000001101011001100110011111000101010101011111111111111111111111001010111011100"}; CHECK_THROWS_AS(run(), CLI::ParseError); + + args = {"--val", "0B1011000001101011001100110011111000101010101011111111111111111111111001010111011100"}; + + CHECK_THROWS_AS(run(), CLI::ParseError); } TEST_CASE_METHOD(TApp, "CharOption", "[optiontype]") {