Commit 4dbe4b4ec46c29bbc53067b2c695af2753196c81
Committed by
GitHub
1 parent
90e6ee1a
tests: add a few more coverage tests (#794)
* add a few more coverage tests * style: pre-commit.ci fixes * try to fix pre-commit issues * update mdlint style as a test * style: pre-commit.ci fixes * fix test * switch test to not generate warning * add a few more tests * tweak the conanfile and appveyor to debug issue * update tests Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Showing
6 changed files
with
13 additions
and
3 deletions
.appveyor.yml
| @@ -24,6 +24,7 @@ build_script: | @@ -24,6 +24,7 @@ build_script: | ||
| 24 | -DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR="Visual Studio 14 2015" | 24 | -DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR="Visual Studio 14 2015" |
| 25 | - ps: cmake --build . | 25 | - ps: cmake --build . |
| 26 | - cd .. | 26 | - cd .. |
| 27 | + - ps: set CTEST_OUTPUT_ON_FAILURE=1 | ||
| 27 | - conan create . CLIUtils/CLI11 | 28 | - conan create . CLIUtils/CLI11 |
| 28 | 29 | ||
| 29 | test_script: | 30 | test_script: |
conanfile.py
| @@ -37,7 +37,7 @@ class CLI11Conan(ConanFile): | @@ -37,7 +37,7 @@ class CLI11Conan(ConanFile): | ||
| 37 | 37 | ||
| 38 | def build(self): # this is not building a library, just tests | 38 | def build(self): # this is not building a library, just tests |
| 39 | cmake = CMake(self) | 39 | cmake = CMake(self) |
| 40 | - cmake.definitions["CLI11_EXAMPLES"] = "OFF" | 40 | + cmake.definitions["CLI11_BUILD_EXAMPLES"] = "OFF" |
| 41 | cmake.definitions["CLI11_SINGLE_FILE"] = "OFF" | 41 | cmake.definitions["CLI11_SINGLE_FILE"] = "OFF" |
| 42 | cmake.configure() | 42 | cmake.configure() |
| 43 | cmake.build() | 43 | cmake.build() |
include/CLI/ConfigFwd.hpp
| @@ -61,7 +61,7 @@ class Config { | @@ -61,7 +61,7 @@ class Config { | ||
| 61 | if(item.inputs.empty()) { | 61 | if(item.inputs.empty()) { |
| 62 | return "{}"; | 62 | return "{}"; |
| 63 | } | 63 | } |
| 64 | - throw ConversionError::TooManyInputsFlag(item.fullname()); | 64 | + throw ConversionError::TooManyInputsFlag(item.fullname()); // LCOV_EXCL_LINE |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | /// Parse a config file, throw an error (ParseError:ConfigParseError or FileError) on failure | 67 | /// Parse a config file, throw an error (ParseError:ConfigParseError or FileError) on failure |
include/CLI/impl/Validators_inl.hpp
| @@ -132,7 +132,7 @@ CLI11_INLINE path_type check_path(const char *file) noexcept { | @@ -132,7 +132,7 @@ CLI11_INLINE path_type check_path(const char *file) noexcept { | ||
| 132 | return path_type::nonexistent; | 132 | return path_type::nonexistent; |
| 133 | } | 133 | } |
| 134 | switch(stat.type()) { | 134 | switch(stat.type()) { |
| 135 | - case std::filesystem::file_type::none: | 135 | + case std::filesystem::file_type::none: // LCOV_EXCL_LINE |
| 136 | case std::filesystem::file_type::not_found: | 136 | case std::filesystem::file_type::not_found: |
| 137 | return path_type::nonexistent; | 137 | return path_type::nonexistent; |
| 138 | case std::filesystem::file_type::directory: | 138 | case std::filesystem::file_type::directory: |
scripts/mdlint_style.rb
| @@ -6,3 +6,4 @@ exclude_rule 'MD034' # Bare URL (for now) | @@ -6,3 +6,4 @@ exclude_rule 'MD034' # Bare URL (for now) | ||
| 6 | 6 | ||
| 7 | rule 'MD026', punctuation: '.,;:!' # Trailing punctuation in header (& in this case) | 7 | rule 'MD026', punctuation: '.,;:!' # Trailing punctuation in header (& in this case) |
| 8 | rule 'MD029', style: :ordered | 8 | rule 'MD029', style: :ordered |
| 9 | +rule 'MD007', indent: 2 |
tests/HelpersTest.cpp
| @@ -525,6 +525,10 @@ TEST_CASE("Validators: ProgramNameSplit", "[helpers]") { | @@ -525,6 +525,10 @@ TEST_CASE("Validators: ProgramNameSplit", "[helpers]") { | ||
| 525 | res = CLI::detail::split_program_name(std::string(" ./") + std::string(myfile) + " "); | 525 | res = CLI::detail::split_program_name(std::string(" ./") + std::string(myfile) + " "); |
| 526 | CHECK(std::string("./") + std::string(myfile) == res.first); | 526 | CHECK(std::string("./") + std::string(myfile) == res.first); |
| 527 | CHECK(res.second.empty()); | 527 | CHECK(res.second.empty()); |
| 528 | + | ||
| 529 | + res = CLI::detail::split_program_name("'odd_program_name.exe --arg --arg2=5"); | ||
| 530 | + CHECK("'odd_program_name.exe" == res.first); | ||
| 531 | + CHECK_FALSE(res.second.empty()); | ||
| 528 | } | 532 | } |
| 529 | 533 | ||
| 530 | TEST_CASE("CheckedMultiply: Int", "[helpers]") { | 534 | TEST_CASE("CheckedMultiply: Int", "[helpers]") { |
| @@ -1065,6 +1069,10 @@ TEST_CASE("Types: LexicalCastInt", "[helpers]") { | @@ -1065,6 +1069,10 @@ TEST_CASE("Types: LexicalCastInt", "[helpers]") { | ||
| 1065 | std::string extra_input = "912i"; | 1069 | std::string extra_input = "912i"; |
| 1066 | CHECK_FALSE(CLI::detail::lexical_cast(extra_input, y)); | 1070 | CHECK_FALSE(CLI::detail::lexical_cast(extra_input, y)); |
| 1067 | 1071 | ||
| 1072 | + extra_input = "true"; | ||
| 1073 | + CHECK(CLI::detail::lexical_cast(extra_input, x_signed)); | ||
| 1074 | + CHECK(x_signed != 0); | ||
| 1075 | + | ||
| 1068 | std::string empty_input{}; | 1076 | std::string empty_input{}; |
| 1069 | CHECK_FALSE(CLI::detail::lexical_cast(empty_input, x_signed)); | 1077 | CHECK_FALSE(CLI::detail::lexical_cast(empty_input, x_signed)); |
| 1070 | CHECK_FALSE(CLI::detail::lexical_cast(empty_input, x_unsigned)); | 1078 | CHECK_FALSE(CLI::detail::lexical_cast(empty_input, x_unsigned)); |