Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a few more coverage tests #794

Merged
merged 10 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion include/CLI/ConfigFwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/CLI/impl/Validators_inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions scripts/mdlint_style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

rule 'MD026', punctuation: '.,;:!' # Trailing punctuation in header (& in this case)
rule 'MD029', style: :ordered
rule 'MD007', indent: 2
8 changes: 8 additions & 0 deletions tests/HelpersTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]") {
Expand Down Expand Up @@ -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));
Expand Down