diff --git a/benchmarks/cpp/asio/echo_server_client.cpp b/benchmarks/cpp/asio/echo_server_client.cpp index 5eb3796f..2bdff9b0 100644 --- a/benchmarks/cpp/asio/echo_server_client.cpp +++ b/benchmarks/cpp/asio/echo_server_client.cpp @@ -27,9 +27,9 @@ auto example(boost::asio::ip::tcp::endpoint ep, std::string msg, int n) -> net:: auto dbuffer = net::dynamic_buffer(buffer); for (int i = 0; i < n; ++i) { co_await net::async_write(socket, net::buffer(msg)); - auto n = co_await net::async_read_until(socket, dbuffer, "\n"); + auto bytes_read = co_await net::async_read_until(socket, dbuffer, "\n"); //std::printf("> %s", buffer.data()); - dbuffer.consume(n); + dbuffer.consume(bytes_read); } //std::printf("Ok: %s", msg.data()); diff --git a/include/boost/redis/adapter/detail/adapters.hpp b/include/boost/redis/adapter/detail/adapters.hpp index c67191c6..5bb8af76 100644 --- a/include/boost/redis/adapter/detail/adapters.hpp +++ b/include/boost/redis/adapter/detail/adapters.hpp @@ -66,7 +66,7 @@ struct converter { template <> struct converter { template - static void apply(bool& t, resp3::basic_node const& node, system::error_code& ec) + static void apply(bool& t, resp3::basic_node const& node, system::error_code&) { t = *node.value.data() == 't'; } diff --git a/include/boost/redis/connection.hpp b/include/boost/redis/connection.hpp index 16f8352e..e366ff5a 100644 --- a/include/boost/redis/connection.hpp +++ b/include/boost/redis/connection.hpp @@ -354,7 +354,7 @@ class run_op { system::error_code ec1 = {}, system::error_code ec2 = {}, system::error_code ec3 = {}, - system::error_code ec4 = {}) + system::error_code = {}) { BOOST_ASIO_CORO_REENTER(coro_) for (;;) { diff --git a/include/boost/redis/resp3/impl/parser.ipp b/include/boost/redis/resp3/impl/parser.ipp index e5964bb9..0d126a57 100644 --- a/include/boost/redis/resp3/impl/parser.ipp +++ b/include/boost/redis/resp3/impl/parser.ipp @@ -10,6 +10,7 @@ #include #include +#include #include namespace boost::redis::resp3 { @@ -177,7 +178,7 @@ auto parser::consume_impl(type t, std::string_view elem, system::error_code& ec) case type::attribute: case type::map: { - std::size_t l = -1; + std::size_t l = static_cast(-1); to_int(l, elem, ec); if (ec) return {}; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 76b60a0f..3cc38128 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,8 +3,11 @@ add_library(boost_redis_project_options INTERFACE) target_link_libraries(boost_redis_project_options INTERFACE boost_redis) if (MSVC) - target_compile_options(boost_redis_project_options INTERFACE /bigobj) + # C4459: name hides outer scope variable is issued by Asio + target_compile_options(boost_redis_project_options INTERFACE /bigobj /W4 /WX /wd4459) target_compile_definitions(boost_redis_project_options INTERFACE _WIN32_WINNT=0x0601) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(boost_redis_project_options INTERFACE -Wall -Wextra -Werror) endif() add_library(boost_redis_src STATIC boost_redis.cpp) diff --git a/test/Jamfile b/test/Jamfile index 9107ec8f..9f526133 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -31,7 +31,7 @@ local requirements = ] [ ac.check-library /openssl//ssl : /openssl//ssl/shared : no ] [ ac.check-library /openssl//crypto : /openssl//crypto/shared : no ] - /boost/test//boost_unit_test_framework + /boost/test//boost_unit_test_framework/off ; diff --git a/test/test_conversions.cpp b/test/test_conversions.cpp index fe543db5..d92e431c 100644 --- a/test/test_conversions.cpp +++ b/test/test_conversions.cpp @@ -57,15 +57,15 @@ BOOST_AUTO_TEST_CASE(ints) // Check BOOST_TEST(std::get<1>(resp).value() == 42); - BOOST_TEST(std::get<2>(resp).value() == 42); + BOOST_TEST(std::get<2>(resp).value() == 42u); BOOST_TEST(std::get<3>(resp).value() == 42); - BOOST_TEST(std::get<4>(resp).value() == 42); + BOOST_TEST(std::get<4>(resp).value() == 42u); BOOST_TEST(std::get<5>(resp).value() == 42); - BOOST_TEST(std::get<6>(resp).value() == 42); + BOOST_TEST(std::get<6>(resp).value() == 42u); BOOST_TEST(std::get<7>(resp).value() == 42); - BOOST_TEST(std::get<8>(resp).value() == 42); + BOOST_TEST(std::get<8>(resp).value() == 42u); BOOST_TEST(std::get<9>(resp).value() == 42); - BOOST_TEST(std::get<10>(resp).value() == 42); + BOOST_TEST(std::get<10>(resp).value() == 42u); } BOOST_AUTO_TEST_CASE(bools) diff --git a/test/test_issue_50.cpp b/test/test_issue_50.cpp index a51942fc..33de47e6 100644 --- a/test/test_issue_50.cpp +++ b/test/test_issue_50.cpp @@ -102,7 +102,7 @@ auto co_main(config) -> net::awaitable BOOST_AUTO_TEST_CASE(issue_50) { net::io_context ioc; - net::co_spawn(ioc, std::move(co_main({})), net::detached); + net::co_spawn(ioc, co_main({}), net::detached); ioc.run(); } diff --git a/test/test_low_level.cpp b/test/test_low_level.cpp index 0dcd14bc..edd7cc4b 100644 --- a/test/test_low_level.cpp +++ b/test/test_low_level.cpp @@ -4,26 +4,24 @@ * accompanying file LICENSE.txt) */ -#include -#include #include +#include #include +#include -#define BOOST_TEST_MODULE low level +#define BOOST_TEST_MODULE low_level #include #include -#include #include #include // TODO: Test with empty strings. -namespace std -{ -auto operator==(boost::redis::ignore_t, boost::redis::ignore_t) noexcept {return true;} -auto operator!=(boost::redis::ignore_t, boost::redis::ignore_t) noexcept {return false;} -} +namespace std { +auto operator==(boost::redis::ignore_t, boost::redis::ignore_t) noexcept { return true; } +auto operator!=(boost::redis::ignore_t, boost::redis::ignore_t) noexcept { return false; } +} // namespace std namespace redis = boost::redis; namespace resp3 = boost::redis::resp3; @@ -56,12 +54,20 @@ using array_type = result>; using array_type2 = result>; // Map -using map_type = result>; -using mmap_type = result>; -using umap_type = result>; -using mumap_type = result>; +using map_type = result>; +using mmap_type = result>; +using umap_type = result>; +using mumap_type = result>; using op_map_type = result>>; -using tuple8_type = result>; +using tuple8_type = result>; // Null using op_type_01 = result>; @@ -85,7 +91,11 @@ struct expect { }; template -auto make_expected(std::string in, Result expected, error_code ec = {}, resp3::type error_type = resp3::type::invalid) +auto make_expected( + std::string in, + Result expected, + error_code ec = {}, + resp3::type error_type = resp3::type::invalid) { return expect{in, expected, ec, error_type}; } @@ -99,7 +109,7 @@ void test_sync(expect e) error_code ec; auto const res = parse(p, e.in, adapter, ec); - BOOST_TEST(res); // None of these tests need more data. + BOOST_TEST(res); // None of these tests need more data. if (ec) { BOOST_CHECK_EQUAL(ec, e.ec); @@ -123,7 +133,7 @@ void test_sync2(expect e) error_code ec; auto const res = parse(p, e.in, adapter, ec); - BOOST_TEST(res); // None of these tests need more data. + BOOST_TEST(res); // None of these tests need more data. BOOST_CHECK_EQUAL(ec, e.ec); } @@ -133,8 +143,6 @@ auto make_blob() str[1000] = '\r'; str[1001] = '\n'; return str; - - return str; } auto const blob = make_blob(); @@ -154,6 +162,8 @@ auto make_blob_string(std::string const& b) result> op_int_ok = 11; result> op_bool_ok = true; +// clang-format off + // TODO: Test a streamed string that is not finished with a string of // size 0 but other command comes in. generic_response streamed_string_e1 @@ -461,12 +471,11 @@ generic_response const attr_e1b test(make_expected(S10b, node_type{{resp3::type::simple_error, 1UL, 0UL, {""}}}, {}, resp3::type::simple_error)); \ test(make_expected(S12a, node_type{{resp3::type::blob_error, 1UL, 0UL, {"SYNTAX invalid syntax"}}}, {}, resp3::type::blob_error));\ test(make_expected(S12b, node_type{{resp3::type::blob_error, 1UL, 0UL, {}}}, {}, resp3::type::blob_error));\ - test(make_expected(S12c, result{}, boost::redis::error::resp3_blob_error));\ + test(make_expected(S12c, result{}, boost::redis::error::resp3_blob_error)); -BOOST_AUTO_TEST_CASE(sansio) -{ - NUMBER_TEST_CONDITIONS(test_sync) -} +// clang-format on + +BOOST_AUTO_TEST_CASE(sansio){NUMBER_TEST_CONDITIONS(test_sync)} BOOST_AUTO_TEST_CASE(ignore_adapter_simple_error) { @@ -478,10 +487,7 @@ BOOST_AUTO_TEST_CASE(ignore_adapter_blob_error) test_sync2(make_expected(S12a, ignore, boost::redis::error::resp3_blob_error)); } -BOOST_AUTO_TEST_CASE(ignore_adapter_no_error) -{ - test_sync2(make_expected(S05b, ignore)); -} +BOOST_AUTO_TEST_CASE(ignore_adapter_no_error) { test_sync2(make_expected(S05b, ignore)); } //----------------------------------------------------------------------------------- void check_error(char const* name, boost::redis::error ev) @@ -492,10 +498,9 @@ void check_error(char const* name, boost::redis::error ev) BOOST_TEST(!ec.message().empty()); BOOST_TEST(cat.equivalent( static_cast::type>(ev), - ec.category().default_error_condition( - static_cast::type>(ev)))); - BOOST_TEST(cat.equivalent(ec, - static_cast::type>(ev))); + ec.category().default_error_condition( + static_cast::type>(ev)))); + BOOST_TEST(cat.equivalent(ec, static_cast::type>(ev))); } BOOST_AUTO_TEST_CASE(cover_error) @@ -606,7 +611,7 @@ BOOST_AUTO_TEST_CASE(adapter_as) result> set; auto adapter = adapt2(set); - for (auto const& e: set_expected1a.value()) { + for (auto const& e : set_expected1a.value()) { error_code ec; adapter(e, ec); } diff --git a/test/test_low_level_sync_sans_io.cpp b/test/test_low_level_sync_sans_io.cpp index 0b5dfe1c..70d42c5e 100644 --- a/test/test_low_level_sync_sans_io.cpp +++ b/test/test_low_level_sync_sans_io.cpp @@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(issue_210_non_empty_set_size_one) deserialize(wire, adapt2(resp)); BOOST_CHECK_EQUAL(std::get<0>(resp.value()).value(), 1); - BOOST_CHECK_EQUAL(std::get<1>(resp.value()).value().size(), 1); + BOOST_CHECK_EQUAL(std::get<1>(resp.value()).value().size(), 1u); BOOST_CHECK_EQUAL(std::get<1>(resp.value()).value().at(0), std::string{"foo"}); BOOST_CHECK_EQUAL(std::get<2>(resp.value()).value(), "this_should_not_be_in_set"); BOOST_CHECK_EQUAL(std::get<3>(resp.value()).value(), 2); @@ -264,11 +264,11 @@ BOOST_AUTO_TEST_CASE(multiplexer_push) auto const ret = mpx.commit_read(ec); BOOST_TEST(ret.first.value()); - BOOST_CHECK_EQUAL(ret.second, 16); + BOOST_CHECK_EQUAL(ret.second, 16u); // TODO: Provide operator << for generic_response so we can compare // the whole vector. - BOOST_CHECK_EQUAL(resp.value().size(), 3); + BOOST_CHECK_EQUAL(resp.value().size(), 3u); BOOST_CHECK_EQUAL(resp.value().at(1).value, "one"); BOOST_CHECK_EQUAL(resp.value().at(2).value, "two"); @@ -294,11 +294,11 @@ BOOST_AUTO_TEST_CASE(multiplexer_push_needs_more) ret = mpx.commit_read(ec); BOOST_TEST(ret.first.value()); - BOOST_CHECK_EQUAL(ret.second, 16); + BOOST_CHECK_EQUAL(ret.second, 16u); // TODO: Provide operator << for generic_response so we can compare // the whole vector. - BOOST_CHECK_EQUAL(resp.value().size(), 3); + BOOST_CHECK_EQUAL(resp.value().size(), 3u); BOOST_CHECK_EQUAL(resp.value().at(1).value, "one"); BOOST_CHECK_EQUAL(resp.value().at(2).value, "two"); } @@ -343,8 +343,8 @@ BOOST_AUTO_TEST_CASE(multiplexer_pipeline) // There are three requests to coalesce, a second call should do // nothing. - BOOST_CHECK_EQUAL(mpx.prepare_write(), 3); - BOOST_CHECK_EQUAL(mpx.prepare_write(), 0); + BOOST_CHECK_EQUAL(mpx.prepare_write(), 3u); + BOOST_CHECK_EQUAL(mpx.prepare_write(), 0u); // After coalescing the requests for writing their statuses should // be changed to "staged". @@ -354,7 +354,7 @@ BOOST_AUTO_TEST_CASE(multiplexer_pipeline) // There are no waiting requests to cancel since they are all // staged. - BOOST_CHECK_EQUAL(mpx.cancel_waiting(), 0); + BOOST_CHECK_EQUAL(mpx.cancel_waiting(), 0u); // Since the requests haven't been sent (written) the done // callback should not have been called yet. @@ -365,7 +365,7 @@ BOOST_AUTO_TEST_CASE(multiplexer_pipeline) // The commit_write call informs the multiplexer the payload was // sent (e.g. written to the socket). This step releases requests // that has no response. - BOOST_CHECK_EQUAL(mpx.commit_write(), 1); + BOOST_CHECK_EQUAL(mpx.commit_write(), 1u); // The staged status should now have changed to written. BOOST_TEST(item1.elem_ptr->is_written()); @@ -387,7 +387,7 @@ BOOST_AUTO_TEST_CASE(multiplexer_pipeline) // The read operation should have been successfull. BOOST_TEST(ret.first.has_value()); - BOOST_TEST(ret.second != 0); + BOOST_TEST(ret.second != 0u); // The read buffer should also be empty now BOOST_TEST(mpx.get_read_buffer().empty()); diff --git a/tools/ci.py b/tools/ci.py index ff7d5ff1..621c22b5 100755 --- a/tools/ci.py +++ b/tools/ci.py @@ -295,6 +295,8 @@ def _run_b2_tests( 'toolset={}'.format(toolset), 'cxxstd={}'.format(cxxstd), 'variant={}'.format(variant), + 'warnings=extra', + 'warnings-as-errors=on', '-j4', 'libs/redis/test' ])