Commit 4dbe4b4ec46c29bbc53067b2c695af2753196c81

Authored by Philip Top
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>
.appveyor.yml
... ... @@ -24,6 +24,7 @@ build_script:
24 24 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR="Visual Studio 14 2015"
25 25 - ps: cmake --build .
26 26 - cd ..
  27 + - ps: set CTEST_OUTPUT_ON_FAILURE=1
27 28 - conan create . CLIUtils/CLI11
28 29  
29 30 test_script:
... ...
conanfile.py
... ... @@ -37,7 +37,7 @@ class CLI11Conan(ConanFile):
37 37  
38 38 def build(self): # this is not building a library, just tests
39 39 cmake = CMake(self)
40   - cmake.definitions["CLI11_EXAMPLES"] = "OFF"
  40 + cmake.definitions["CLI11_BUILD_EXAMPLES"] = "OFF"
41 41 cmake.definitions["CLI11_SINGLE_FILE"] = "OFF"
42 42 cmake.configure()
43 43 cmake.build()
... ...
include/CLI/ConfigFwd.hpp
... ... @@ -61,7 +61,7 @@ class Config {
61 61 if(item.inputs.empty()) {
62 62 return "{}";
63 63 }
64   - throw ConversionError::TooManyInputsFlag(item.fullname());
  64 + throw ConversionError::TooManyInputsFlag(item.fullname()); // LCOV_EXCL_LINE
65 65 }
66 66  
67 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 132 return path_type::nonexistent;
133 133 }
134 134 switch(stat.type()) {
135   - case std::filesystem::file_type::none:
  135 + case std::filesystem::file_type::none: // LCOV_EXCL_LINE
136 136 case std::filesystem::file_type::not_found:
137 137 return path_type::nonexistent;
138 138 case std::filesystem::file_type::directory:
... ...
scripts/mdlint_style.rb
... ... @@ -6,3 +6,4 @@ exclude_rule &#39;MD034&#39; # Bare URL (for now)
6 6  
7 7 rule 'MD026', punctuation: '.,;:!' # Trailing punctuation in header (& in this case)
8 8 rule 'MD029', style: :ordered
  9 +rule 'MD007', indent: 2
... ...
tests/HelpersTest.cpp
... ... @@ -525,6 +525,10 @@ TEST_CASE(&quot;Validators: ProgramNameSplit&quot;, &quot;[helpers]&quot;) {
525 525 res = CLI::detail::split_program_name(std::string(" ./") + std::string(myfile) + " ");
526 526 CHECK(std::string("./") + std::string(myfile) == res.first);
527 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 534 TEST_CASE("CheckedMultiply: Int", "[helpers]") {
... ... @@ -1065,6 +1069,10 @@ TEST_CASE(&quot;Types: LexicalCastInt&quot;, &quot;[helpers]&quot;) {
1065 1069 std::string extra_input = "912i";
1066 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 1076 std::string empty_input{};
1069 1077 CHECK_FALSE(CLI::detail::lexical_cast(empty_input, x_signed));
1070 1078 CHECK_FALSE(CLI::detail::lexical_cast(empty_input, x_unsigned));
... ...