mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 20:23:55 +00:00
Adding and fixing more warnings
This commit is contained in:
parent
268c26ad62
commit
bea833bbcd
@ -6,7 +6,7 @@ set -evx
|
|||||||
|
|
||||||
mkdir -p build-tidy
|
mkdir -p build-tidy
|
||||||
cd build-tidy
|
cd build-tidy
|
||||||
CXX_FLAGS="-Werror -Wall -Wextra -pedantic -std=c++11" cmake .. -DCLANG_TIDY_FIX=ON
|
CXX_FLAGS="-Werror -Wcast-align -Wfloat-equal -Wimplicit-atomic-properties -Wmissing-declarations -Woverlength-strings -Wshadow -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code -std=c++11" cmake .. -DCLANG_TIDY_FIX=ON
|
||||||
cmake --build .
|
cmake --build .
|
||||||
|
|
||||||
set -evx
|
set -evx
|
||||||
|
@ -27,7 +27,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_definitions("/W4")
|
add_definitions("/W4")
|
||||||
else()
|
else()
|
||||||
add_definitions("-Wall -Wextra -pedantic")
|
add_definitions(-Wall -Wextra -pedantic)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER 3.6)
|
if(CMAKE_VERSION VERSION_GREATER 3.6)
|
||||||
|
@ -1048,10 +1048,10 @@ class App {
|
|||||||
|
|
||||||
/// This returns the number of remaining options, minus the -- seperator
|
/// This returns the number of remaining options, minus the -- seperator
|
||||||
size_t remaining_size(bool recurse = false) const {
|
size_t remaining_size(bool recurse = false) const {
|
||||||
size_t count = std::count_if(
|
size_t count = static_cast<size_t>(std::count_if(
|
||||||
std::begin(missing_), std::end(missing_), [](const std::pair<detail::Classifer, std::string> &val) {
|
std::begin(missing_), std::end(missing_), [](const std::pair<detail::Classifer, std::string> &val) {
|
||||||
return val.first != detail::Classifer::POSITIONAL_MARK;
|
return val.first != detail::Classifer::POSITIONAL_MARK;
|
||||||
});
|
}));
|
||||||
if(recurse) {
|
if(recurse) {
|
||||||
for(const App_p &sub : subcommands_) {
|
for(const App_p &sub : subcommands_) {
|
||||||
count += sub->remaining_size(recurse);
|
count += sub->remaining_size(recurse);
|
||||||
|
@ -633,24 +633,24 @@ TEST_F(TApp, RequiredFlags) {
|
|||||||
|
|
||||||
TEST_F(TApp, CallbackFlags) {
|
TEST_F(TApp, CallbackFlags) {
|
||||||
|
|
||||||
int value = 0;
|
size_t value = 0;
|
||||||
|
|
||||||
auto func = [&value](size_t x) { value = x; };
|
auto func = [&value](size_t x) { value = x; };
|
||||||
|
|
||||||
app.add_flag_function("-v", func);
|
app.add_flag_function("-v", func);
|
||||||
|
|
||||||
run();
|
run();
|
||||||
EXPECT_EQ(value, 0);
|
EXPECT_EQ(value, (size_t)0);
|
||||||
|
|
||||||
app.reset();
|
app.reset();
|
||||||
args = {"-v"};
|
args = {"-v"};
|
||||||
run();
|
run();
|
||||||
EXPECT_EQ(value, 1);
|
EXPECT_EQ(value, (size_t)1);
|
||||||
|
|
||||||
app.reset();
|
app.reset();
|
||||||
args = {"-vv"};
|
args = {"-vv"};
|
||||||
run();
|
run();
|
||||||
EXPECT_EQ(value, 2);
|
EXPECT_EQ(value, (size_t)2);
|
||||||
|
|
||||||
EXPECT_THROW(app.add_flag_function("hi", func), CLI::IncorrectConstruction);
|
EXPECT_THROW(app.add_flag_function("hi", func), CLI::IncorrectConstruction);
|
||||||
}
|
}
|
||||||
@ -658,24 +658,24 @@ TEST_F(TApp, CallbackFlags) {
|
|||||||
#if __cplusplus >= 201402L
|
#if __cplusplus >= 201402L
|
||||||
TEST_F(TApp, CallbackFlagsAuto) {
|
TEST_F(TApp, CallbackFlagsAuto) {
|
||||||
|
|
||||||
int value = 0;
|
size_t value = 0;
|
||||||
|
|
||||||
auto func = [&value](size_t x) { value = x; };
|
auto func = [&value](size_t x) { value = x; };
|
||||||
|
|
||||||
app.add_flag("-v", func);
|
app.add_flag("-v", func);
|
||||||
|
|
||||||
run();
|
run();
|
||||||
EXPECT_EQ(value, 0);
|
EXPECT_EQ(value, (size_t)0);
|
||||||
|
|
||||||
app.reset();
|
app.reset();
|
||||||
args = {"-v"};
|
args = {"-v"};
|
||||||
run();
|
run();
|
||||||
EXPECT_EQ(value, 1);
|
EXPECT_EQ(value, (size_t)1);
|
||||||
|
|
||||||
app.reset();
|
app.reset();
|
||||||
args = {"-vv"};
|
args = {"-vv"};
|
||||||
run();
|
run();
|
||||||
EXPECT_EQ(value, 2);
|
EXPECT_EQ(value, (size_t)2);
|
||||||
|
|
||||||
EXPECT_THROW(app.add_flag("hi", func), CLI::IncorrectConstruction);
|
EXPECT_THROW(app.add_flag("hi", func), CLI::IncorrectConstruction);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
set(GOOGLE_TEST_INDIVIDUAL ON)
|
set(GOOGLE_TEST_INDIVIDUAL OFF)
|
||||||
include(AddGoogletest)
|
include(AddGoogletest)
|
||||||
|
|
||||||
set(CLI_TESTS
|
set(CLI_TESTS
|
||||||
|
@ -415,8 +415,8 @@ TEST(Types, LexicalCastParsable) {
|
|||||||
|
|
||||||
std::complex<double> output;
|
std::complex<double> output;
|
||||||
EXPECT_TRUE(CLI::detail::lexical_cast(input, output));
|
EXPECT_TRUE(CLI::detail::lexical_cast(input, output));
|
||||||
EXPECT_EQ(output.real(), 4.2); // Doing this in one go sometimes has trouble
|
EXPECT_DOUBLE_EQ(output.real(), 4.2); // Doing this in one go sometimes has trouble
|
||||||
EXPECT_EQ(output.imag(), 7.3); // on clang + c++4.8 due to missing const
|
EXPECT_DOUBLE_EQ(output.imag(), 7.3); // on clang + c++4.8 due to missing const
|
||||||
|
|
||||||
EXPECT_FALSE(CLI::detail::lexical_cast(fail_input, output));
|
EXPECT_FALSE(CLI::detail::lexical_cast(fail_input, output));
|
||||||
EXPECT_FALSE(CLI::detail::lexical_cast(extra_input, output));
|
EXPECT_FALSE(CLI::detail::lexical_cast(extra_input, output));
|
||||||
|
@ -34,8 +34,8 @@ TEST_F(TApp, AddingComplexParser) {
|
|||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
||||||
EXPECT_EQ(1.5, comp.real());
|
EXPECT_DOUBLE_EQ(1.5, comp.real());
|
||||||
EXPECT_EQ(2.5, comp.imag());
|
EXPECT_DOUBLE_EQ(2.5, comp.imag());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TApp, DefaultComplex) {
|
TEST_F(TApp, DefaultComplex) {
|
||||||
@ -48,13 +48,13 @@ TEST_F(TApp, DefaultComplex) {
|
|||||||
EXPECT_THAT(help, HasSubstr("1"));
|
EXPECT_THAT(help, HasSubstr("1"));
|
||||||
EXPECT_THAT(help, HasSubstr("2"));
|
EXPECT_THAT(help, HasSubstr("2"));
|
||||||
|
|
||||||
EXPECT_EQ(1, comp.real());
|
EXPECT_DOUBLE_EQ(1, comp.real());
|
||||||
EXPECT_EQ(2, comp.imag());
|
EXPECT_DOUBLE_EQ(2, comp.imag());
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
||||||
EXPECT_EQ(4, comp.real());
|
EXPECT_DOUBLE_EQ(4, comp.real());
|
||||||
EXPECT_EQ(3, comp.imag());
|
EXPECT_DOUBLE_EQ(3, comp.imag());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TApp, BuiltinComplex) {
|
TEST_F(TApp, BuiltinComplex) {
|
||||||
@ -68,13 +68,13 @@ TEST_F(TApp, BuiltinComplex) {
|
|||||||
EXPECT_THAT(help, HasSubstr("2"));
|
EXPECT_THAT(help, HasSubstr("2"));
|
||||||
EXPECT_THAT(help, HasSubstr("COMPLEX"));
|
EXPECT_THAT(help, HasSubstr("COMPLEX"));
|
||||||
|
|
||||||
EXPECT_EQ(1, comp.real());
|
EXPECT_DOUBLE_EQ(1, comp.real());
|
||||||
EXPECT_EQ(2, comp.imag());
|
EXPECT_DOUBLE_EQ(2, comp.imag());
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
||||||
EXPECT_EQ(4, comp.real());
|
EXPECT_DOUBLE_EQ(4, comp.real());
|
||||||
EXPECT_EQ(3, comp.imag());
|
EXPECT_DOUBLE_EQ(3, comp.imag());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TApp, BuiltinComplexIgnoreI) {
|
TEST_F(TApp, BuiltinComplexIgnoreI) {
|
||||||
@ -85,8 +85,8 @@ TEST_F(TApp, BuiltinComplexIgnoreI) {
|
|||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
||||||
EXPECT_EQ(4, comp.real());
|
EXPECT_DOUBLE_EQ(4, comp.real());
|
||||||
EXPECT_EQ(3, comp.imag());
|
EXPECT_DOUBLE_EQ(3, comp.imag());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TApp, BuiltinComplexFail) {
|
TEST_F(TApp, BuiltinComplexFail) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user