From 90bcd621fbc4708bf63f83a366cec7db767b9bbb Mon Sep 17 00:00:00 2001 From: Marcelo Zimbres Date: Tue, 14 Mar 2023 14:08:55 +0100 Subject: [PATCH] Including only necessary headers. --- README.md | 2 +- examples/cpp17_intro.cpp | 1 - examples/cpp17_intro_sync.cpp | 9 +++-- examples/cpp20_chat_room.cpp | 18 +++++---- examples/cpp20_containers.cpp | 9 +++-- examples/cpp20_echo_server.cpp | 11 ++++-- examples/cpp20_intro.cpp | 9 +++-- examples/cpp20_intro_awaitable_ops.cpp | 8 ++-- examples/cpp20_intro_tls.cpp | 12 +++--- examples/cpp20_json.cpp | 12 +++--- examples/cpp20_protobuf.cpp | 11 ++++-- examples/cpp20_resolve_with_sentinel.cpp | 9 +++-- examples/cpp20_subscriber.cpp | 13 ++++--- examples/json.hpp | 4 +- examples/main.cpp | 7 ++-- examples/start.cpp | 9 +++-- examples/start.hpp | 2 +- include/boost/redis/adapter/ignore.hpp | 1 + include/boost/redis/check_health.hpp | 1 + include/boost/redis/detail/connection_ops.hpp | 21 ++++++----- include/boost/redis/detail/helper.hpp | 37 +++++++++++++++++++ include/boost/redis/detail/read_ops.hpp | 25 ++----------- include/boost/redis/detail/runner.hpp | 9 +++-- include/boost/redis/resp3/parser.hpp | 4 +- include/boost/redis/resp3/type.hpp | 1 + include/boost/redis/run.hpp | 1 + include/boost/redis/ssl/connection.hpp | 1 + tests/common.hpp | 4 +- tests/conn_check_health.cpp | 12 ++---- tests/conn_echo_stress.cpp | 12 +++--- tests/conn_exec.cpp | 10 ++--- tests/conn_exec_cancel.cpp | 10 ++--- tests/conn_exec_error.cpp | 10 ++--- tests/conn_push.cpp | 15 ++++---- tests/conn_quit.cpp | 9 ++--- tests/conn_reconnect.cpp | 13 +++---- tests/conn_run_cancel.cpp | 13 +++---- tests/conn_tls.cpp | 9 ++--- tests/cpp17_low_level_sync.cpp | 9 +++-- tests/cpp20_low_level_async.cpp | 9 +++-- tests/issue_50.cpp | 14 +++---- tests/low_level.cpp | 14 ++++--- tests/run.cpp | 4 +- 43 files changed, 226 insertions(+), 188 deletions(-) create mode 100644 include/boost/redis/detail/helper.hpp diff --git a/README.md b/README.md index ae682a4c..0dfb7dc6 100644 --- a/README.md +++ b/README.md @@ -527,7 +527,7 @@ void boost_redis_from_bulk(mystruct& obj, char const* p, std::size_t size, boost These functions are accessed over ADL and therefore they must be imported in the global namespace by the user. In the -[Examples](#Examples) section the reader can find examples showing how +[Examples](#examples) section the reader can find examples showing how to serialize using json and [protobuf](https://protobuf.dev/). diff --git a/examples/cpp17_intro.cpp b/examples/cpp17_intro.cpp index d53ee587..d7be48d6 100644 --- a/examples/cpp17_intro.cpp +++ b/examples/cpp17_intro.cpp @@ -5,7 +5,6 @@ */ #include -#include #include #include diff --git a/examples/cpp17_intro_sync.cpp b/examples/cpp17_intro_sync.cpp index 5621b665..c89d7648 100644 --- a/examples/cpp17_intro_sync.cpp +++ b/examples/cpp17_intro_sync.cpp @@ -4,14 +4,17 @@ * accompanying file LICENSE.txt) */ +#include +#include +#include +#include +#include +#include #include #include #include #include #include -#include -#include -#include // Include this in no more than one .cpp file. #include diff --git a/examples/cpp20_chat_room.cpp b/examples/cpp20_chat_room.cpp index f02bb541..0f88f1ba 100644 --- a/examples/cpp20_chat_room.cpp +++ b/examples/cpp20_chat_room.cpp @@ -4,16 +4,18 @@ * accompanying file LICENSE.txt) */ -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) -#include -namespace net = boost::asio; -#if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR) -#include -#include +#include #include +#include +#include +#include +#include #include +#include +#if defined(BOOST_ASIO_HAS_CO_AWAIT) +#if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +namespace net = boost::asio; using namespace net::experimental::awaitable_operators; using stream_descriptor = net::use_awaitable_t<>::as_default_on_t; using signal_set = net::use_awaitable_t<>::as_default_on_t; @@ -21,7 +23,7 @@ using boost::redis::request; using boost::redis::generic_response; using boost::redis::async_check_health; using boost::redis::async_run; -using connection = boost::asio::use_awaitable_t<>::as_default_on_t; +using connection = net::use_awaitable_t<>::as_default_on_t; // Chat over Redis pubsub. To test, run this program from multiple // terminals and type messages to stdin. diff --git a/examples/cpp20_containers.cpp b/examples/cpp20_containers.cpp index f000a6ef..670c6f8e 100644 --- a/examples/cpp20_containers.cpp +++ b/examples/cpp20_containers.cpp @@ -4,13 +4,16 @@ * accompanying file LICENSE.txt) */ -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) -#include +#include +#include +#include +#include #include #include #include +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + namespace net = boost::asio; namespace redis = boost::redis; using boost::redis::request; diff --git a/examples/cpp20_echo_server.cpp b/examples/cpp20_echo_server.cpp index 0be953c4..60d507e9 100644 --- a/examples/cpp20_echo_server.cpp +++ b/examples/cpp20_echo_server.cpp @@ -4,11 +4,14 @@ * accompanying file LICENSE.txt) */ -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) -#include -#include +#include #include +#include +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_CO_AWAIT) namespace net = boost::asio; using namespace net::experimental::awaitable_operators; diff --git a/examples/cpp20_intro.cpp b/examples/cpp20_intro.cpp index fc75a724..14b81762 100644 --- a/examples/cpp20_intro.cpp +++ b/examples/cpp20_intro.cpp @@ -4,11 +4,14 @@ * accompanying file LICENSE.txt) */ -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) -#include +#include +#include +#include +#include #include +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + namespace net = boost::asio; using boost::redis::request; using boost::redis::response; diff --git a/examples/cpp20_intro_awaitable_ops.cpp b/examples/cpp20_intro_awaitable_ops.cpp index 2c303e48..c60a1bb6 100644 --- a/examples/cpp20_intro_awaitable_ops.cpp +++ b/examples/cpp20_intro_awaitable_ops.cpp @@ -4,11 +4,11 @@ * accompanying file LICENSE.txt) */ -#include -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) +#include +#include #include -#include +#include +#if defined(BOOST_ASIO_HAS_CO_AWAIT) namespace net = boost::asio; using namespace net::experimental::awaitable_operators; diff --git a/examples/cpp20_intro_tls.cpp b/examples/cpp20_intro_tls.cpp index 5d607337..f24aab81 100644 --- a/examples/cpp20_intro_tls.cpp +++ b/examples/cpp20_intro_tls.cpp @@ -4,17 +4,17 @@ * accompanying file LICENSE.txt) */ +#include +#include +#include +#include +#include +#include #include #include #include -#include #if defined(BOOST_ASIO_HAS_CO_AWAIT) -#include -#include - -#include -#include namespace net = boost::asio; namespace redis = boost::redis; diff --git a/examples/cpp20_json.cpp b/examples/cpp20_json.cpp index 8a922259..a66e5e43 100644 --- a/examples/cpp20_json.cpp +++ b/examples/cpp20_json.cpp @@ -4,17 +4,19 @@ * accompanying file LICENSE.txt) */ -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) -#define BOOST_JSON_NO_LIB -#define BOOST_CONTAINER_NO_LIB -#include +#include +#include +#include +#include #include #include #include #include "json.hpp" +#if defined(BOOST_ASIO_HAS_CO_AWAIT) // Include this in no more than one .cpp file. +#define BOOST_JSON_NO_LIB +#define BOOST_CONTAINER_NO_LIB #include namespace net = boost::asio; diff --git a/examples/cpp20_protobuf.cpp b/examples/cpp20_protobuf.cpp index 9bc89264..799daa47 100644 --- a/examples/cpp20_protobuf.cpp +++ b/examples/cpp20_protobuf.cpp @@ -4,9 +4,10 @@ * accompanying file LICENSE.txt) */ -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) -#include +#include +#include +#include +#include #include #include "protobuf.hpp" @@ -14,6 +15,8 @@ // generated by CMakeLists.txt. #include "person.pb.h" +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + namespace net = boost::asio; namespace redis = boost::redis; using boost::redis::request; @@ -21,7 +24,7 @@ using boost::redis::response; using boost::redis::operation; using boost::redis::ignore_t; using boost::redis::async_run; -using connection = boost::asio::use_awaitable_t<>::as_default_on_t; +using connection = net::use_awaitable_t<>::as_default_on_t; // The protobuf type described in examples/person.proto using tutorial::person; diff --git a/examples/cpp20_resolve_with_sentinel.cpp b/examples/cpp20_resolve_with_sentinel.cpp index 71cc1d87..8ed6c7b9 100644 --- a/examples/cpp20_resolve_with_sentinel.cpp +++ b/examples/cpp20_resolve_with_sentinel.cpp @@ -4,11 +4,12 @@ * accompanying file LICENSE.txt) */ -#include -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) +#include +#include +#include #include -#include +#include +#if defined(BOOST_ASIO_HAS_CO_AWAIT) namespace net = boost::asio; using namespace net::experimental::awaitable_operators; diff --git a/examples/cpp20_subscriber.cpp b/examples/cpp20_subscriber.cpp index b34c5e8f..d70960a0 100644 --- a/examples/cpp20_subscriber.cpp +++ b/examples/cpp20_subscriber.cpp @@ -4,12 +4,13 @@ * accompanying file LICENSE.txt) */ -#include -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) -#include -#include +#include #include +#include +#include +#include + +#if defined(BOOST_ASIO_HAS_CO_AWAIT) namespace net = boost::asio; using namespace net::experimental::awaitable_operators; @@ -18,7 +19,7 @@ using boost::redis::request; using boost::redis::async_run; using boost::redis::generic_response; using boost::redis::async_check_health; -using connection = boost::asio::use_awaitable_t<>::as_default_on_t; +using connection = net::use_awaitable_t<>::as_default_on_t; /* This example will subscribe and read pushes indefinitely. * diff --git a/examples/json.hpp b/examples/json.hpp index af9d333c..ca7e26f8 100644 --- a/examples/json.hpp +++ b/examples/json.hpp @@ -7,7 +7,9 @@ #ifndef BOOST_REDIS_JSON_HPP #define BOOST_REDIS_JSON_HPP -#include +#include +#include +#include #include namespace boost::redis::json diff --git a/examples/main.cpp b/examples/main.cpp index f86a0949..22dbdadf 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -4,12 +4,13 @@ * accompanying file LICENSE.txt) */ -#include +#include "start.hpp" +#include +#include +#include #if defined(BOOST_ASIO_HAS_CO_AWAIT) -#include "start.hpp" - extern boost::asio::awaitable co_main(std::string, std::string); auto main(int argc, char * argv[]) -> int diff --git a/examples/start.cpp b/examples/start.cpp index 7cceb56b..eb8674ac 100644 --- a/examples/start.cpp +++ b/examples/start.cpp @@ -4,10 +4,13 @@ * accompanying file LICENSE.txt) */ -#include "start.hpp" -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) +#include +#include +#include #include +#include "start.hpp" + +#if defined(BOOST_ASIO_HAS_CO_AWAIT) namespace net = boost::asio; diff --git a/examples/start.hpp b/examples/start.hpp index 6388686d..a4ee0ef5 100644 --- a/examples/start.hpp +++ b/examples/start.hpp @@ -7,7 +7,7 @@ #ifndef BOOST_REDIS_EXAMPLES_START_HPP #define BOOST_REDIS_EXAMPLES_START_HPP -#include +#include #if defined(BOOST_ASIO_HAS_CO_AWAIT) diff --git a/include/boost/redis/adapter/ignore.hpp b/include/boost/redis/adapter/ignore.hpp index a468e966..29a5502c 100644 --- a/include/boost/redis/adapter/ignore.hpp +++ b/include/boost/redis/adapter/ignore.hpp @@ -8,6 +8,7 @@ #define BOOST_REDIS_ADAPTER_IGNORE_HPP #include +#include #include #include diff --git a/include/boost/redis/check_health.hpp b/include/boost/redis/check_health.hpp index a18960f0..1b63b578 100644 --- a/include/boost/redis/check_health.hpp +++ b/include/boost/redis/check_health.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/include/boost/redis/detail/connection_ops.hpp b/include/boost/redis/detail/connection_ops.hpp index 36ee4336..1452341b 100644 --- a/include/boost/redis/detail/connection_ops.hpp +++ b/include/boost/redis/detail/connection_ops.hpp @@ -8,6 +8,7 @@ #define BOOST_REDIS_CONNECTION_OPS_HPP #include +#include #include #include #include @@ -37,11 +38,11 @@ struct wait_receive_op { { BOOST_ASIO_CORO_YIELD conn->channel_.async_send(system::error_code{}, 0, std::move(self)); - AEDIS_CHECK_OP0(;); + BOOST_REDIS_CHECK_OP0(;); BOOST_ASIO_CORO_YIELD conn->channel_.async_send(system::error_code{}, 0, std::move(self)); - AEDIS_CHECK_OP0(;); + BOOST_REDIS_CHECK_OP0(;); self.complete({}); } @@ -80,7 +81,7 @@ struct exec_read_op { conn->next_layer(), conn->make_dynamic_buffer(), "\r\n", std::move(self)); - AEDIS_CHECK_OP1(conn->cancel(operation::run);); + BOOST_REDIS_CHECK_OP1(conn->cancel(operation::run);); } // If the next request is a push we have to handle it to @@ -88,7 +89,7 @@ struct exec_read_op { if (resp3::to_type(conn->read_buffer_.front()) == resp3::type::push) { BOOST_ASIO_CORO_YIELD conn->async_wait_receive(std::move(self)); - AEDIS_CHECK_OP1(conn->cancel(operation::run);); + BOOST_REDIS_CHECK_OP1(conn->cancel(operation::run);); continue; } //----------------------------------- @@ -102,7 +103,7 @@ struct exec_read_op { ++index; - AEDIS_CHECK_OP1(conn->cancel(operation::run);); + BOOST_REDIS_CHECK_OP1(conn->cancel(operation::run);); read_size += n; @@ -132,7 +133,7 @@ struct receive_op { { BOOST_ASIO_CORO_YIELD conn->channel_.async_receive(std::move(self)); - AEDIS_CHECK_OP1(;); + BOOST_REDIS_CHECK_OP1(;); BOOST_ASIO_CORO_YIELD redis::detail::async_read(conn->next_layer(), conn->make_dynamic_buffer(), adapter, std::move(self)); @@ -147,7 +148,7 @@ struct receive_op { BOOST_ASIO_CORO_YIELD conn->channel_.async_receive(std::move(self)); - AEDIS_CHECK_OP1(;); + BOOST_REDIS_CHECK_OP1(;); self.complete({}, read_size); return; @@ -228,7 +229,7 @@ EXEC_OP_WAIT: BOOST_ASSERT(conn->reqs_.front() != nullptr); BOOST_ASIO_CORO_YIELD conn->async_exec_read(adapter, conn->reqs_.front()->get_number_of_commands(), std::move(self)); - AEDIS_CHECK_OP1(;); + BOOST_REDIS_CHECK_OP1(;); read_size = n; @@ -302,7 +303,7 @@ struct writer_op { while (conn->coalesce_requests()) { BOOST_ASIO_CORO_YIELD asio::async_write(conn->next_layer(), asio::buffer(conn->write_buffer_), std::move(self)); - AEDIS_CHECK_OP0(conn->cancel(operation::run);); + BOOST_REDIS_CHECK_OP0(conn->cancel(operation::run);); conn->on_write(); @@ -353,7 +354,7 @@ struct reader_op { return self.complete({}); // EOFINAE: EOF is not an error. } - AEDIS_CHECK_OP0(conn->cancel(operation::run);); + BOOST_REDIS_CHECK_OP0(conn->cancel(operation::run);); // We handle unsolicited events in the following way // diff --git a/include/boost/redis/detail/helper.hpp b/include/boost/redis/detail/helper.hpp new file mode 100644 index 00000000..a8a21efe --- /dev/null +++ b/include/boost/redis/detail/helper.hpp @@ -0,0 +1,37 @@ +/* Copyright (c) 2018-2022 Marcelo Zimbres Silva (mzimbres@gmail.com) + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE.txt) + */ + +#ifndef BOOST_REDIS_HELPER_HPP +#define BOOST_REDIS_HELPER_HPP + +#include + +namespace boost::redis::detail +{ + +template +auto is_cancelled(T const& self) +{ + return self.get_cancellation_state().cancelled() != asio::cancellation_type_t::none; +} + +#define BOOST_REDIS_CHECK_OP0(X)\ + if (ec || redis::detail::is_cancelled(self)) {\ + X\ + self.complete(!!ec ? ec : asio::error::operation_aborted);\ + return;\ + } + +#define BOOST_REDIS_CHECK_OP1(X)\ + if (ec || redis::detail::is_cancelled(self)) {\ + X\ + self.complete(!!ec ? ec : asio::error::operation_aborted, {});\ + return;\ + } + +} // boost::redis::detail + +#endif // BOOST_REDIS_HELPER_HPP diff --git a/include/boost/redis/detail/read_ops.hpp b/include/boost/redis/detail/read_ops.hpp index c99af843..70d1546f 100644 --- a/include/boost/redis/detail/read_ops.hpp +++ b/include/boost/redis/detail/read_ops.hpp @@ -8,6 +8,7 @@ #define BOOST_REDIS_READ_OPS_HPP #include +#include #include #include #include @@ -18,26 +19,6 @@ namespace boost::redis::detail { -template -auto is_cancelled(T const& self) -{ - return self.get_cancellation_state().cancelled() != asio::cancellation_type_t::none; -} - -#define AEDIS_CHECK_OP0(X)\ - if (ec || redis::detail::is_cancelled(self)) {\ - X\ - self.complete(!!ec ? ec : asio::error::operation_aborted);\ - return;\ - } - -#define AEDIS_CHECK_OP1(X)\ - if (ec || redis::detail::is_cancelled(self)) {\ - X\ - self.complete(!!ec ? ec : asio::error::operation_aborted, {});\ - return;\ - } - template < class AsyncReadStream, class DynamicBuffer, @@ -68,7 +49,7 @@ public: if (!parser_.bulk_expected()) { BOOST_ASIO_CORO_YIELD asio::async_read_until(stream_, buf_, "\r\n", std::move(self)); - AEDIS_CHECK_OP1(;); + BOOST_REDIS_CHECK_OP1(;); } else { // On a bulk read we can't read until delimiter since the // payload may contain the delimiter itself so we have to @@ -87,7 +68,7 @@ public: buf_.data(buffer_size_, parser_.bulk_length() + 2 - buffer_size_), asio::transfer_all(), std::move(self)); - AEDIS_CHECK_OP1(;); + BOOST_REDIS_CHECK_OP1(;); } n = parser_.bulk_length() + 2; diff --git a/include/boost/redis/detail/runner.hpp b/include/boost/redis/detail/runner.hpp index 33bfae9d..121bb6e6 100644 --- a/include/boost/redis/detail/runner.hpp +++ b/include/boost/redis/detail/runner.hpp @@ -8,12 +8,13 @@ #define BOOST_REDIS_RUNNER_HPP // Has to included before promise.hpp to build on msvc. -#include +#include #include #include #include #include #include +#include #include #include #include @@ -144,16 +145,16 @@ struct runner_op { runner->timer_.expires_after(resolve_timeout); BOOST_ASIO_CORO_YIELD runner->async_resolve(host, port, std::move(self)); - AEDIS_CHECK_OP0(;) + BOOST_REDIS_CHECK_OP0(;) runner->timer_.expires_after(connect_timeout); BOOST_ASIO_CORO_YIELD runner->async_connect(conn->next_layer(), std::move(self)); - AEDIS_CHECK_OP0(;) + BOOST_REDIS_CHECK_OP0(;) BOOST_ASIO_CORO_YIELD conn->async_run(std::move(self)); - AEDIS_CHECK_OP0(;) + BOOST_REDIS_CHECK_OP0(;) self.complete({}); } } diff --git a/include/boost/redis/resp3/parser.hpp b/include/boost/redis/resp3/parser.hpp index 07517f3d..5db0b81c 100644 --- a/include/boost/redis/resp3/parser.hpp +++ b/include/boost/redis/resp3/parser.hpp @@ -8,7 +8,7 @@ #define BOOST_REDIS_RESP3_PARSER_HPP #include - +#include #include #include #include @@ -48,7 +48,7 @@ public: consume( char const* data, std::size_t n, - boost::system::error_code& ec) -> std::pair; + system::error_code& ec) -> std::pair; // Returns true when the parser is done with the current message. [[nodiscard]] auto done() const noexcept diff --git a/include/boost/redis/resp3/type.hpp b/include/boost/redis/resp3/type.hpp index 4ea37432..32913750 100644 --- a/include/boost/redis/resp3/type.hpp +++ b/include/boost/redis/resp3/type.hpp @@ -7,6 +7,7 @@ #ifndef BOOST_REDIS_RESP3_TYPE_HPP #define BOOST_REDIS_RESP3_TYPE_HPP +#include #include #include #include diff --git a/include/boost/redis/run.hpp b/include/boost/redis/run.hpp index 1ca54fe1..7464fa63 100644 --- a/include/boost/redis/run.hpp +++ b/include/boost/redis/run.hpp @@ -25,6 +25,7 @@ namespace boost::redis { * 2. Connects to one of the endpoints from 1. * 3. Calls async_run on the underlying connection. * + * @param conn A connection to Redis. * @param host Redis host to connect to. * @param port Redis port to connect to. * @param resolve_timeout Time the resolve operation is allowed to take. diff --git a/include/boost/redis/ssl/connection.hpp b/include/boost/redis/ssl/connection.hpp index b9e983f2..e1a895ac 100644 --- a/include/boost/redis/ssl/connection.hpp +++ b/include/boost/redis/ssl/connection.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include diff --git a/tests/common.hpp b/tests/common.hpp index 362cc9c3..c7d1e5c3 100644 --- a/tests/common.hpp +++ b/tests/common.hpp @@ -1,6 +1,8 @@ #pragma once -#include +#include +#include +#include #ifdef BOOST_ASIO_HAS_CO_AWAIT namespace net = boost::asio; diff --git a/tests/conn_check_health.cpp b/tests/conn_check_health.cpp index 096a7c52..4a7f8272 100644 --- a/tests/conn_check_health.cpp +++ b/tests/conn_check_health.cpp @@ -4,18 +4,14 @@ * accompanying file LICENSE.txt) */ -#include -#include +#include +#include #include - #define BOOST_TEST_MODULE check-health #include - -#include -#include -#include - +#include #include "common.hpp" +#include namespace net = boost::asio; using error_code = boost::system::error_code; diff --git a/tests/conn_echo_stress.cpp b/tests/conn_echo_stress.cpp index ffbd3b5d..ef2b8af4 100644 --- a/tests/conn_echo_stress.cpp +++ b/tests/conn_echo_stress.cpp @@ -4,16 +4,18 @@ * accompanying file LICENSE.txt) */ -#include -#include -#ifdef BOOST_ASIO_HAS_CO_AWAIT +#include +#include +#include #include #define BOOST_TEST_MODULE echo-stress #include -#include -#include +#include #include "common.hpp" #include "../examples/start.hpp" +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT namespace net = boost::asio; using error_code = boost::system::error_code; diff --git a/tests/conn_exec.cpp b/tests/conn_exec.cpp index 37606271..858589c5 100644 --- a/tests/conn_exec.cpp +++ b/tests/conn_exec.cpp @@ -4,17 +4,13 @@ * accompanying file LICENSE.txt) */ -#include -#include +#include #include - #define BOOST_TEST_MODULE conn-exec #include - -#include -#include - +#include #include "common.hpp" +#include // TODO: Test whether HELLO won't be inserted passt commands that have // been already writen. diff --git a/tests/conn_exec_cancel.cpp b/tests/conn_exec_cancel.cpp index ee195f5d..3896d2fb 100644 --- a/tests/conn_exec_cancel.cpp +++ b/tests/conn_exec_cancel.cpp @@ -4,17 +4,17 @@ * accompanying file LICENSE.txt) */ -#include -#include -#ifdef BOOST_ASIO_HAS_CO_AWAIT +#include #include #include #define BOOST_TEST_MODULE conn-exec-cancel #include -#include -#include #include "common.hpp" #include "../examples/start.hpp" +#include +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT // NOTE1: Sends hello separately. I have observed that if hello and // blpop are sent toguether, Redis will send the response of hello diff --git a/tests/conn_exec_error.cpp b/tests/conn_exec_error.cpp index 61b0a94e..b06d96fb 100644 --- a/tests/conn_exec_error.cpp +++ b/tests/conn_exec_error.cpp @@ -4,17 +4,13 @@ * accompanying file LICENSE.txt) */ -#include -#include +#include #include - #define BOOST_TEST_MODULE conn-exec-error #include - -#include -#include - #include "common.hpp" +#include +#include namespace net = boost::asio; namespace redis = boost::redis; diff --git a/tests/conn_push.cpp b/tests/conn_push.cpp index 53c969a7..025fcfb2 100644 --- a/tests/conn_push.cpp +++ b/tests/conn_push.cpp @@ -4,21 +4,20 @@ * accompanying file LICENSE.txt) */ -#include -#include -#ifdef BOOST_ASIO_HAS_CO_AWAIT +#include #include +#include +#include #include - #define BOOST_TEST_MODULE conn-push #include - -#include -#include +#include #include "common.hpp" +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT namespace net = boost::asio; -namespace resp3 = boost::redis::resp3; using boost::redis::operation; using connection = boost::redis::connection; diff --git a/tests/conn_quit.cpp b/tests/conn_quit.cpp index 2d1f57c7..79fb2ab9 100644 --- a/tests/conn_quit.cpp +++ b/tests/conn_quit.cpp @@ -4,16 +4,13 @@ * accompanying file LICENSE.txt) */ -#include -#include +#include #include - #define BOOST_TEST_MODULE conn-quit #include - -#include -#include #include "common.hpp" +#include +#include namespace net = boost::asio; diff --git a/tests/conn_reconnect.cpp b/tests/conn_reconnect.cpp index 813c2d7c..b501a18f 100644 --- a/tests/conn_reconnect.cpp +++ b/tests/conn_reconnect.cpp @@ -4,17 +4,16 @@ * accompanying file LICENSE.txt) */ -#include -#include -#ifdef BOOST_ASIO_HAS_CO_AWAIT - +#include +#include #define BOOST_TEST_MODULE conn-reconnect #include - -#include -#include +#include #include "common.hpp" #include "../examples/start.hpp" +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT namespace net = boost::asio; using error_code = boost::system::error_code; diff --git a/tests/conn_run_cancel.cpp b/tests/conn_run_cancel.cpp index edc971d0..09749bce 100644 --- a/tests/conn_run_cancel.cpp +++ b/tests/conn_run_cancel.cpp @@ -4,18 +4,17 @@ * accompanying file LICENSE.txt) */ -#include -#include -#ifdef BOOST_ASIO_HAS_CO_AWAIT +#include +#include #include #include - #define BOOST_TEST_MODULE conn-run-cancel #include - -#include -#include +#include #include "common.hpp" +#include + +#ifdef BOOST_ASIO_HAS_CO_AWAIT namespace net = boost::asio; diff --git a/tests/conn_tls.cpp b/tests/conn_tls.cpp index 56b85b84..38fcbfde 100644 --- a/tests/conn_tls.cpp +++ b/tests/conn_tls.cpp @@ -4,17 +4,14 @@ * accompanying file LICENSE.txt) */ -#include -#include +#include #include - #define BOOST_TEST_MODULE conn-tls #include - -#include #include -#include +#include #include "common.hpp" +#include namespace net = boost::asio; diff --git a/tests/cpp17_low_level_sync.cpp b/tests/cpp17_low_level_sync.cpp index 434441af..81cd5949 100644 --- a/tests/cpp17_low_level_sync.cpp +++ b/tests/cpp17_low_level_sync.cpp @@ -4,12 +4,13 @@ * accompanying file LICENSE.txt) */ +#include +#include +#include +#include +#include #include #include - -#include -#include -#include #include namespace net = boost::asio; diff --git a/tests/cpp20_low_level_async.cpp b/tests/cpp20_low_level_async.cpp index f357eb16..21614377 100644 --- a/tests/cpp20_low_level_async.cpp +++ b/tests/cpp20_low_level_async.cpp @@ -4,12 +4,15 @@ * accompanying file LICENSE.txt) */ -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) -#include +#include +#include #include +#include +#include +#include #include #include +#if defined(BOOST_ASIO_HAS_CO_AWAIT) namespace net = boost::asio; namespace redis = boost::redis; diff --git a/tests/issue_50.cpp b/tests/issue_50.cpp index cb87ca18..b0ec4751 100644 --- a/tests/issue_50.cpp +++ b/tests/issue_50.cpp @@ -5,17 +5,17 @@ */ // Must come before any asio header, otherwise build fails on msvc. + +#include +#include +#include +#include #include #include - -#include -#if defined(BOOST_ASIO_HAS_CO_AWAIT) -#include -#include -#include - #include "../examples/start.hpp" +#if defined(BOOST_ASIO_HAS_CO_AWAIT) + namespace net = boost::asio; using namespace net::experimental::awaitable_operators; using steady_timer = net::use_awaitable_t<>::as_default_on_t; diff --git a/tests/low_level.cpp b/tests/low_level.cpp index 1e57e3fd..9902aedc 100644 --- a/tests/low_level.cpp +++ b/tests/low_level.cpp @@ -4,11 +4,10 @@ * accompanying file LICENSE.txt) */ -#include -#include -#include -#include - +#include +#include +#include +#include #include #include #include @@ -18,8 +17,11 @@ #include #define BOOST_TEST_MODULE low level #include +#include +#include +#include +#include -#include #include // TODO: Test with empty strings. diff --git a/tests/run.cpp b/tests/run.cpp index 4b3edc1e..f5cc507a 100644 --- a/tests/run.cpp +++ b/tests/run.cpp @@ -4,12 +4,10 @@ * accompanying file LICENSE.txt) */ +#include #define BOOST_TEST_MODULE run #include - #include -#include -#include #include namespace net = boost::asio;