1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 12:13:52 +00:00

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>
This commit is contained in:
Philip Top 2022-10-27 21:23:22 -07:00 committed by GitHub
parent 90e6ee1aaa
commit 4dbe4b4ec4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 3 deletions

View File

@ -24,6 +24,7 @@ build_script:
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR="Visual Studio 14 2015"
- ps: cmake --build .
- cd ..
- ps: set CTEST_OUTPUT_ON_FAILURE=1
- conan create . CLIUtils/CLI11
test_script:

View File

@ -37,7 +37,7 @@ class CLI11Conan(ConanFile):
def build(self): # this is not building a library, just tests
cmake = CMake(self)
cmake.definitions["CLI11_EXAMPLES"] = "OFF"
cmake.definitions["CLI11_BUILD_EXAMPLES"] = "OFF"
cmake.definitions["CLI11_SINGLE_FILE"] = "OFF"
cmake.configure()
cmake.build()

View File

@ -61,7 +61,7 @@ class Config {
if(item.inputs.empty()) {
return "{}";
}
throw ConversionError::TooManyInputsFlag(item.fullname());
throw ConversionError::TooManyInputsFlag(item.fullname()); // LCOV_EXCL_LINE
}
/// Parse a config file, throw an error (ParseError:ConfigParseError or FileError) on failure

View File

@ -132,7 +132,7 @@ CLI11_INLINE path_type check_path(const char *file) noexcept {
return path_type::nonexistent;
}
switch(stat.type()) {
case std::filesystem::file_type::none:
case std::filesystem::file_type::none: // LCOV_EXCL_LINE
case std::filesystem::file_type::not_found:
return path_type::nonexistent;
case std::filesystem::file_type::directory:

View File

@ -6,3 +6,4 @@ exclude_rule 'MD034' # Bare URL (for now)
rule 'MD026', punctuation: '.,;:!' # Trailing punctuation in header (& in this case)
rule 'MD029', style: :ordered
rule 'MD007', indent: 2

View File

@ -525,6 +525,10 @@ TEST_CASE("Validators: ProgramNameSplit", "[helpers]") {
res = CLI::detail::split_program_name(std::string(" ./") + std::string(myfile) + " ");
CHECK(std::string("./") + std::string(myfile) == res.first);
CHECK(res.second.empty());
res = CLI::detail::split_program_name("'odd_program_name.exe --arg --arg2=5");
CHECK("'odd_program_name.exe" == res.first);
CHECK_FALSE(res.second.empty());
}
TEST_CASE("CheckedMultiply: Int", "[helpers]") {
@ -1065,6 +1069,10 @@ TEST_CASE("Types: LexicalCastInt", "[helpers]") {
std::string extra_input = "912i";
CHECK_FALSE(CLI::detail::lexical_cast(extra_input, y));
extra_input = "true";
CHECK(CLI::detail::lexical_cast(extra_input, x_signed));
CHECK(x_signed != 0);
std::string empty_input{};
CHECK_FALSE(CLI::detail::lexical_cast(empty_input, x_signed));
CHECK_FALSE(CLI::detail::lexical_cast(empty_input, x_unsigned));