From 4fdfc6d6caa5a1072b8b5886e142a47b4179ec36 Mon Sep 17 00:00:00 2001 From: Takatoshi Kondo Date: Fri, 7 Oct 2022 21:26:53 +0900 Subject: [PATCH] Added move_only_handler. --- .github/workflows/gha.yml | 5 + example/bench.cpp | 12 +- example/client_cli.cpp | 45 +- example/logging.cpp | 14 - example/long_lived_client.cpp | 6 - example/no_tls_async_client.cpp | 6 - example/no_tls_async_client_reconnect.cpp | 1 - example/no_tls_both.cpp | 14 - example/no_tls_client.cpp | 6 - example/no_tls_server.cpp | 8 - example/no_tls_ws_both.cpp | 14 - example/no_tls_ws_client.cpp | 6 - example/no_tls_ws_server.cpp | 8 - example/redirect.cpp | 19 +- example/tls_both.cpp | 14 - example/tls_both_client_cert.cpp | 14 - example/tls_client.cpp | 6 - example/tls_server.cpp | 8 - example/tls_ws_both.cpp | 14 - example/tls_ws_client.cpp | 6 - example/tls_ws_server.cpp | 8 - example/v5_no_tls_both.cpp | 14 - example/v5_no_tls_client.cpp | 6 - example/v5_no_tls_prop.cpp | 2 - example/v5_no_tls_server.cpp | 8 - include/mqtt/apply.hpp | 56 + include/mqtt/async_handler.hpp | 22 + include/mqtt/broker/broker.hpp | 144 +- include/mqtt/broker/session_state.hpp | 6 +- include/mqtt/callable_overlay.hpp | 338 ++-- include/mqtt/client.hpp | 2 - include/mqtt/copyable_function.hpp | 30 + include/mqtt/copyable_handler.hpp | 66 + include/mqtt/endpoint.hpp | 614 +++---- include/mqtt/move_only_handler.hpp | 66 + include/mqtt/server.hpp | 34 +- include/mqtt/store.hpp | 2 +- include/mqtt/tcp_endpoint.hpp | 18 +- include/mqtt/type_erased_socket.hpp | 14 +- include/mqtt/ws_endpoint.hpp | 26 +- test/system/st_as_buffer_async_pubsub_1.cpp | 84 - test/system/st_as_buffer_async_pubsub_2.cpp | 84 - test/system/st_as_buffer_pubsub.cpp | 154 -- test/system/st_as_buffer_sub.cpp | 36 - test/system/st_async_pubsub_1.cpp | 84 - test/system/st_async_pubsub_2.cpp | 150 -- test/system/st_broker_offline_message.cpp | 21 - test/system/st_connect.cpp | 48 - test/system/st_issue_749.cpp | 1 - test/system/st_length_check.cpp | 3 - test/system/st_manual_publish.cpp | 14 - test/system/st_maximum_packet_size.cpp | 3 - test/system/st_multi_sub.cpp | 40 - test/system/st_offline.cpp | 18 - test/system/st_pubsub_1.cpp | 1700 ------------------ test/system/st_pubsub_2.cpp | 1489 ++++++++++++++- test/system/st_pubsub_no_strand.cpp | 70 - test/system/st_receive_maximum.cpp | 8 - test/system/st_remaining_length.cpp | 21 - test/system/st_reqres.cpp | 7 - test/system/st_resend.cpp | 68 - test/system/st_resend_new_client.cpp | 28 - test/system/st_resend_serialize.cpp | 28 - test/system/st_resend_serialize_ptr_size.cpp | 28 - test/system/st_retain_1.cpp | 28 - test/system/st_retain_2.cpp | 63 - test/system/st_shared_sub.cpp | 20 - test/system/st_sub.cpp | 54 - test/system/st_topic_alias.cpp | 30 - test/system/st_utf8string_validate.cpp | 13 - test/system/st_will.cpp | 39 - 71 files changed, 2245 insertions(+), 3891 deletions(-) create mode 100644 include/mqtt/apply.hpp create mode 100644 include/mqtt/async_handler.hpp create mode 100644 include/mqtt/copyable_function.hpp create mode 100644 include/mqtt/copyable_handler.hpp create mode 100644 include/mqtt/move_only_handler.hpp diff --git a/.github/workflows/gha.yml b/.github/workflows/gha.yml index 8953f1b3c..12142191f 100644 --- a/.github/workflows/gha.yml +++ b/.github/workflows/gha.yml @@ -51,6 +51,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Set up GCC + uses: egor-tensin/setup-gcc@v1 + with: + version: 11 + platform: x64 - name: Cache boost id: cache-boost uses: actions/cache@v1 diff --git a/example/bench.cpp b/example/bench.cpp index 35571e75c..5f7a0af5b 100644 --- a/example/bench.cpp +++ b/example/bench.cpp @@ -709,7 +709,7 @@ int main(int argc, char **argv) { MQTT_NS::v5::properties /*props*/) { if (pubopts.get_retain() == MQTT_NS::retain::yes) { locked_cout() << "retained publish received and ignored topic:" << topic_name << std::endl; - return true; + return; } BOOST_ASSERT(rest_times > 0); --rest_times; @@ -742,8 +742,6 @@ int main(int argc, char **argv) { --ci.recv_times; if (rest_times == 0) finish_proc(); } - - return true; }; // ==== end local lambda expressions @@ -764,7 +762,6 @@ int main(int argc, char **argv) { else { std::cout << "connack error:" << connack_return_code << std::endl; } - return true; } ); ci.c->set_v5_connack_handler( @@ -776,7 +773,6 @@ int main(int argc, char **argv) { else { std::cout << "connack error:" << reason_code << std::endl; } - return true; } ); @@ -796,7 +792,6 @@ int main(int argc, char **argv) { } } } - return true; } ); ci.c->set_v5_suback_handler( @@ -817,7 +812,6 @@ int main(int argc, char **argv) { } } } - return true; } ); @@ -827,7 +821,7 @@ int main(int argc, char **argv) { MQTT_NS::publish_options pubopts, MQTT_NS::buffer topic_name, MQTT_NS::buffer contents) { - return publish_handler(ci, packet_id, pubopts, topic_name, contents, MQTT_NS::v5::properties{}); + publish_handler(ci, packet_id, pubopts, topic_name, contents, MQTT_NS::v5::properties{}); } ); ci.c->set_v5_publish_handler( @@ -837,7 +831,7 @@ int main(int argc, char **argv) { MQTT_NS::buffer topic_name, MQTT_NS::buffer contents, MQTT_NS::v5::properties props) { - return publish_handler(ci, packet_id, pubopts, topic_name, contents, MQTT_NS::force_move(props)); + publish_handler(ci, packet_id, pubopts, topic_name, contents, MQTT_NS::force_move(props)); } ); } diff --git a/example/client_cli.cpp b/example/client_cli.cpp index 0a641b7dd..5e2bd6943 100644 --- a/example/client_cli.cpp +++ b/example/client_cli.cpp @@ -591,7 +591,6 @@ int main(int argc, char* argv[]) { std::cout << "< props:" << std::endl; print_props("< ", props); print_menu(); - return true; }; client.set_connack_handler( @@ -615,7 +614,6 @@ int main(int argc, char* argv[]) { } ); } - return true; } ); client.set_v5_connack_handler( @@ -641,7 +639,6 @@ int main(int argc, char* argv[]) { } ); } - return true; } ); client.set_publish_handler( @@ -651,14 +648,13 @@ int main(int argc, char* argv[]) { MQTT_NS::buffer topic_name, MQTT_NS::buffer contents) { std::cout << "< publish (v3.1.1)" << std::endl; - return - publish_handler( - packet_id, - pubopts, - topic_name, - contents, - MQTT_NS::v5::properties{} - ); + publish_handler( + packet_id, + pubopts, + topic_name, + contents, + MQTT_NS::v5::properties{} + ); } ); client.set_v5_publish_handler( @@ -669,14 +665,13 @@ int main(int argc, char* argv[]) { MQTT_NS::buffer contents, MQTT_NS::v5::properties props) { std::cout << "< publish (v5)" << std::endl; - return - publish_handler( - packet_id, - pubopts, - topic_name, - contents, - MQTT_NS::force_move(props) - ); + publish_handler( + packet_id, + pubopts, + topic_name, + contents, + MQTT_NS::force_move(props) + ); } ); client.set_puback_handler( @@ -684,7 +679,6 @@ int main(int argc, char* argv[]) { (packet_id_t packet_id){ std::cout << "< puback (v3.1.1)" << std::endl; std::cout << "< packet_id:" << packet_id << std::endl; - return true; } ); client.set_v5_puback_handler( // use v5 handler @@ -695,7 +689,6 @@ int main(int argc, char* argv[]) { std::cout << "< reason_code:" << reason_code << std::endl; std::cout << "< props:" << std::endl; print_props("< ", props); - return true; } ); client.set_pubrec_handler( @@ -703,7 +696,6 @@ int main(int argc, char* argv[]) { (packet_id_t packet_id){ std::cout << "< pubrec (v3.1.1)" << std::endl; std::cout << "< packet_id:" << packet_id << std::endl; - return true; } ); client.set_v5_pubrec_handler( // use v5 handler @@ -714,7 +706,6 @@ int main(int argc, char* argv[]) { std::cout << "< reason_code:" << reason_code << std::endl; std::cout << "< props:" << std::endl; print_props("< ", props); - return true; } ); client.set_pubrel_handler( @@ -722,7 +713,6 @@ int main(int argc, char* argv[]) { (packet_id_t packet_id){ std::cout << "< pubrel (v3.1.1)" << std::endl; std::cout << "< packet_id:" << packet_id << std::endl; - return true; } ); client.set_v5_pubrel_handler( // use v5 handler @@ -733,7 +723,6 @@ int main(int argc, char* argv[]) { std::cout << "< reason_code:" << reason_code << std::endl; std::cout << "< props:" << std::endl; print_props("< ", props); - return true; } ); client.set_pubcomp_handler( @@ -741,7 +730,6 @@ int main(int argc, char* argv[]) { (packet_id_t packet_id){ std::cout << "< pubcomp (v3.1.1)" << std::endl; std::cout << "< packet_id:" << packet_id << std::endl; - return true; } ); client.set_v5_pubcomp_handler( // use v5 handler @@ -752,7 +740,6 @@ int main(int argc, char* argv[]) { std::cout << "< reason_code:" << reason_code << std::endl; std::cout << "< props:" << std::endl; print_props("< ", props); - return true; } ); client.set_suback_handler( @@ -765,7 +752,6 @@ int main(int argc, char* argv[]) { std::cout << "< " << e << std::endl; } print_menu(); - return true; } ); client.set_v5_suback_handler( @@ -782,7 +768,6 @@ int main(int argc, char* argv[]) { std::cout << "< props:" << std::endl; print_props("< ", props); print_menu(); - return true; } ); client.set_unsuback_handler( @@ -791,7 +776,6 @@ int main(int argc, char* argv[]) { std::cout << "< unsuback (v3.1.1)" << std::endl; std::cout << "< packet_id: " << packet_id << std::endl; print_menu(); - return true; } ); client.set_v5_unsuback_handler( @@ -808,7 +792,6 @@ int main(int argc, char* argv[]) { std::cout << "< props:" << std::endl; print_props("< ", props); print_menu(); - return true; } ); diff --git a/example/logging.cpp b/example/logging.cpp index b2079e059..195d35039 100644 --- a/example/logging.cpp +++ b/example/logging.cpp @@ -47,7 +47,6 @@ void client_proc( } ); } - return true; }); c->set_close_handler( [] @@ -64,20 +63,17 @@ void client_proc( (packet_id_t packet_id){ locked_cout() << "[client] puback received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_pubrec_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubcomp received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_suback_handler( [&] @@ -93,7 +89,6 @@ void client_proc( c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_publish_handler( [&] @@ -110,7 +105,6 @@ void client_proc( locked_cout() << "[client] topic_name: " << topic_name << std::endl; locked_cout() << "[client] contents: " << contents << std::endl; disconnect(); - return true; }); // Connect @@ -225,7 +219,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::connect_return_code::accepted); - return true; } ); ep.set_disconnect_handler( @@ -240,25 +233,21 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { [] (packet_id_t packet_id){ locked_cout() << "[server] puback received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrec_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrel_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrel received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubcomp_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubcomp received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_publish_handler( [&subs] @@ -283,7 +272,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { std::min(r.first->qos_value, pubopts.get_qos()) ); } - return true; }); ep.set_subscribe_handler( [&subs, wp] @@ -300,7 +288,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos()); } sp->suback(packet_id, res); - return true; } ); ep.set_unsubscribe_handler( @@ -314,7 +301,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { auto sp = wp.lock(); BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/long_lived_client.cpp b/example/long_lived_client.cpp index e810e72ce..01d97f041 100644 --- a/example/long_lived_client.cpp +++ b/example/long_lived_client.cpp @@ -120,7 +120,6 @@ int main(int argc, char** argv) { ); publish_message(publish_timer, c, packet_counter); - return true; }); c->set_close_handler( [] @@ -139,13 +138,11 @@ int main(int argc, char** argv) { [&] (packet_id_t packet_id){ std::cout << "puback received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubrec_handler( [] (packet_id_t packet_id){ std::cout << "pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] @@ -157,7 +154,6 @@ int main(int argc, char** argv) { } packet_counter += 1; - return true; }); c->set_suback_handler( [&] @@ -166,7 +162,6 @@ int main(int argc, char** argv) { for (auto const& e : results) { std::cout << "[client] subscribe result: " << e << std::endl; } - return true; }); c->set_publish_handler( [&] @@ -183,7 +178,6 @@ int main(int argc, char** argv) { std::cout << "topic_name: " << topic_name << std::endl; std::cout << "contents: " << contents << std::endl; - return true; }); // Connect diff --git a/example/no_tls_async_client.cpp b/example/no_tls_async_client.cpp index 3b50764de..c8abc69b1 100644 --- a/example/no_tls_async_client.cpp +++ b/example/no_tls_async_client.cpp @@ -80,7 +80,6 @@ int main(int argc, char** argv) { ); } - return true; }); c->set_close_handler( [] @@ -97,20 +96,17 @@ int main(int argc, char** argv) { (packet_id_t packet_id){ std::cout << "puback received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_pubrec_handler( [] (packet_id_t packet_id){ std::cout << "pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] (packet_id_t packet_id){ std::cout << "pubcomp received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_suback_handler( [&] @@ -153,7 +149,6 @@ int main(int argc, char** argv) { } ); } - return true; }); c->set_publish_handler( [&] @@ -170,7 +165,6 @@ int main(int argc, char** argv) { std::cout << "topic_name: " << topic_name << std::endl; std::cout << "contents: " << contents << std::endl; disconnect(); - return true; }); // Connect diff --git a/example/no_tls_async_client_reconnect.cpp b/example/no_tls_async_client_reconnect.cpp index 7179dc2e6..19508f73a 100644 --- a/example/no_tls_async_client_reconnect.cpp +++ b/example/no_tls_async_client_reconnect.cpp @@ -85,7 +85,6 @@ int main(int argc, char** argv) { else { reconnect(); } - return true; }); c->set_close_handler( [&] diff --git a/example/no_tls_both.cpp b/example/no_tls_both.cpp index 121cf90c1..2659c3dad 100644 --- a/example/no_tls_both.cpp +++ b/example/no_tls_both.cpp @@ -46,7 +46,6 @@ void client_proc( } ); } - return true; }); c->set_close_handler( [] @@ -63,20 +62,17 @@ void client_proc( (packet_id_t packet_id){ locked_cout() << "[client] puback received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_pubrec_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubcomp received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_suback_handler( [&] @@ -92,7 +88,6 @@ void client_proc( c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_publish_handler( [&] @@ -109,7 +104,6 @@ void client_proc( locked_cout() << "[client] topic_name: " << topic_name << std::endl; locked_cout() << "[client] contents: " << contents << std::endl; disconnect(); - return true; }); // Connect @@ -234,7 +228,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::connect_return_code::accepted); - return true; } ); ep.set_disconnect_handler( @@ -249,25 +242,21 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { [] (packet_id_t packet_id){ locked_cout() << "[server] puback received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrec_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrel_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrel received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubcomp_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubcomp received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_publish_handler( [&subs] @@ -292,7 +281,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { std::min(r.first->qos_value, pubopts.get_qos()) ); } - return true; }); ep.set_subscribe_handler( [&subs, wp] @@ -309,7 +297,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos()); } sp->suback(packet_id, res); - return true; } ); ep.set_unsubscribe_handler( @@ -326,7 +313,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { } BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/no_tls_client.cpp b/example/no_tls_client.cpp index bed78188c..680b0b469 100644 --- a/example/no_tls_client.cpp +++ b/example/no_tls_client.cpp @@ -54,7 +54,6 @@ int main(int argc, char** argv) { } ); } - return true; }); c->set_close_handler( [] @@ -71,20 +70,17 @@ int main(int argc, char** argv) { (packet_id_t packet_id){ std::cout << "puback received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_pubrec_handler( [] (packet_id_t packet_id){ std::cout << "pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] (packet_id_t packet_id){ std::cout << "pubcomp received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_suback_handler( [&] @@ -100,7 +96,6 @@ int main(int argc, char** argv) { c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_publish_handler( [&] @@ -117,7 +112,6 @@ int main(int argc, char** argv) { std::cout << "topic_name: " << topic_name << std::endl; std::cout << "contents: " << contents << std::endl; disconnect(); - return true; }); // Connect diff --git a/example/no_tls_server.cpp b/example/no_tls_server.cpp index 06446f02c..13689eaba 100644 --- a/example/no_tls_server.cpp +++ b/example/no_tls_server.cpp @@ -141,7 +141,6 @@ int main(int argc, char** argv) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::connect_return_code::accepted); - return true; } ); ep.set_disconnect_handler( @@ -156,25 +155,21 @@ int main(int argc, char** argv) { [] (packet_id_t packet_id){ std::cout << "[server] puback received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrec_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrel_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubrel received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubcomp_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubcomp received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_publish_handler( [&subs] @@ -199,7 +194,6 @@ int main(int argc, char** argv) { std::min(r.first->qos_value, pubopts.get_qos()) ); } - return true; }); ep.set_subscribe_handler( [&subs, wp] @@ -216,7 +210,6 @@ int main(int argc, char** argv) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos()); } sp->suback(packet_id, res); - return true; } ); ep.set_unsubscribe_handler( @@ -233,7 +226,6 @@ int main(int argc, char** argv) { } BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/no_tls_ws_both.cpp b/example/no_tls_ws_both.cpp index 21f60ae21..6e17486a9 100644 --- a/example/no_tls_ws_both.cpp +++ b/example/no_tls_ws_both.cpp @@ -46,7 +46,6 @@ void client_proc( } ); } - return true; }); c->set_close_handler( [] @@ -63,20 +62,17 @@ void client_proc( (packet_id_t packet_id){ locked_cout() << "[client] puback received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_pubrec_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubcomp received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_suback_handler( [&] @@ -92,7 +88,6 @@ void client_proc( c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_publish_handler( [&] @@ -109,7 +104,6 @@ void client_proc( locked_cout() << "[client] topic_name: " << topic_name << std::endl; locked_cout() << "[client] contents: " << contents << std::endl; disconnect(); - return true; }); // Connect @@ -233,7 +227,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::connect_return_code::accepted); - return true; } ); ep.set_disconnect_handler( @@ -248,25 +241,21 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { [] (packet_id_t packet_id){ locked_cout() << "[server] puback received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrec_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrel_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrel received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubcomp_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubcomp received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_publish_handler( [&subs] @@ -291,7 +280,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { std::min(r.first->qos_value, pubopts.get_qos()) ); } - return true; }); ep.set_subscribe_handler( [&subs, wp] @@ -308,7 +296,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos()); } sp->suback(packet_id, res); - return true; } ); ep.set_unsubscribe_handler( @@ -325,7 +312,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { } BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/no_tls_ws_client.cpp b/example/no_tls_ws_client.cpp index 838d34078..587e57b42 100644 --- a/example/no_tls_ws_client.cpp +++ b/example/no_tls_ws_client.cpp @@ -54,7 +54,6 @@ int main(int argc, char** argv) { } ); } - return true; }); c->set_close_handler( [] @@ -71,20 +70,17 @@ int main(int argc, char** argv) { (packet_id_t packet_id){ std::cout << "puback received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_pubrec_handler( [&] (packet_id_t packet_id){ std::cout << "pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] (packet_id_t packet_id){ std::cout << "pubcomp received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_suback_handler( [&] @@ -100,7 +96,6 @@ int main(int argc, char** argv) { c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_publish_handler( [&] @@ -117,7 +112,6 @@ int main(int argc, char** argv) { std::cout << "topic_name: " << topic_name << std::endl; std::cout << "contents: " << contents << std::endl; disconnect(); - return true; }); // Connect diff --git a/example/no_tls_ws_server.cpp b/example/no_tls_ws_server.cpp index e8a481469..5438ccbf7 100644 --- a/example/no_tls_ws_server.cpp +++ b/example/no_tls_ws_server.cpp @@ -141,7 +141,6 @@ int main(int argc, char** argv) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::connect_return_code::accepted); - return true; } ); ep.set_disconnect_handler( @@ -156,25 +155,21 @@ int main(int argc, char** argv) { [] (packet_id_t packet_id){ std::cout << "[server] puback received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrec_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrel_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubrel received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubcomp_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubcomp received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_publish_handler( [&subs] @@ -199,7 +194,6 @@ int main(int argc, char** argv) { std::min(r.first->qos_value, pubopts.get_qos()) ); } - return true; }); ep.set_subscribe_handler( [&subs, wp] @@ -216,7 +210,6 @@ int main(int argc, char** argv) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos()); } sp->suback(packet_id, res); - return true; } ); ep.set_unsubscribe_handler( @@ -233,7 +226,6 @@ int main(int argc, char** argv) { } BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/redirect.cpp b/example/redirect.cpp index a78214c93..4100e3cd3 100644 --- a/example/redirect.cpp +++ b/example/redirect.cpp @@ -66,12 +66,12 @@ void set_client_handlers( } if (server_reference.empty()) { locked_cout() << "[client] redirect requested but no server_reference" << std::endl; - return false; + return; } auto pos = server_reference.find(':'); if (pos == std::string::npos) { locked_cout() << "[client] no port specified in server_reference" << std::endl; - return false; + return; } auto host = server_reference.substr(0, pos); auto port = server_reference.substr(pos + 1); @@ -98,7 +98,6 @@ void set_client_handlers( default: locked_cout() << "[client] handler not implemented" << std::endl; } - return true; }); c.set_close_handler( // this handler doesn't depend on MQTT protocol version [] @@ -117,7 +116,6 @@ void set_client_handlers( "[client] puback received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; disconnect(c); - return true; }); c.set_v5_pubrec_handler( // use v5 handler [&] @@ -125,7 +123,6 @@ void set_client_handlers( locked_cout() << "[client] pubrec received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); c.set_v5_pubcomp_handler( // use v5 handler [&] @@ -134,7 +131,6 @@ void set_client_handlers( "[client] pubcomp received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; disconnect(c); - return true; }); c.set_v5_suback_handler( // use v5 handler [&] @@ -165,7 +161,6 @@ void set_client_handlers( c.publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c.publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c.set_v5_publish_handler( // use v5 handler [&] @@ -183,7 +178,6 @@ void set_client_handlers( locked_cout() << "[client] topic_name: " << topic_name << std::endl; locked_cout() << "[client] contents: " << contents << std::endl; disconnect(c); - return true; }); } @@ -305,7 +299,6 @@ void server_proc(Server1& s1, Server2& s2, std::set& connections, mi_s { MQTT_NS::v5::property::server_reference(MQTT_NS::allocate_buffer("localhost:" + std::to_string(s2.port()))) } ); sp->force_disconnect(); - return false; } ); } @@ -376,7 +369,6 @@ void server_proc(Server1& s1, Server2& s2, std::set& connections, mi_s false, MQTT_NS::v5::connect_reason_code::success ); - return true; } ); ep.set_v5_disconnect_handler( // use v5 handler @@ -395,7 +387,6 @@ void server_proc(Server1& s1, Server2& s2, std::set& connections, mi_s locked_cout() << "[server] puback received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_pubrec_handler( // use v5 handler [] @@ -403,7 +394,6 @@ void server_proc(Server1& s1, Server2& s2, std::set& connections, mi_s locked_cout() << "[server] pubrec received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_pubrel_handler( // use v5 handler [] @@ -411,7 +401,6 @@ void server_proc(Server1& s1, Server2& s2, std::set& connections, mi_s locked_cout() << "[server] pubrel received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_pubcomp_handler( // use v5 handler [] @@ -419,7 +408,6 @@ void server_proc(Server1& s1, Server2& s2, std::set& connections, mi_s locked_cout() << "[server] pubcomp received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_publish_handler( // use v5 handler [&subs] @@ -453,7 +441,6 @@ void server_proc(Server1& s1, Server2& s2, std::set& connections, mi_s std::move(props) ); } - return true; }); ep.set_v5_subscribe_handler( // use v5 handler [&subs, wp] @@ -474,7 +461,6 @@ void server_proc(Server1& s1, Server2& s2, std::set& connections, mi_s subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos(), e.subopts.get_rap()); } sp->suback(packet_id, res); - return true; } ); ep.set_v5_unsubscribe_handler( // use v5 handler @@ -489,7 +475,6 @@ void server_proc(Server1& s1, Server2& s2, std::set& connections, mi_s auto sp = wp.lock(); BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/tls_both.cpp b/example/tls_both.cpp index 991b769b1..e82ab9a8b 100644 --- a/example/tls_both.cpp +++ b/example/tls_both.cpp @@ -47,7 +47,6 @@ void client_proc( } ); } - return true; }); c->set_close_handler( [] @@ -64,20 +63,17 @@ void client_proc( (packet_id_t packet_id){ locked_cout() << "[client] puback received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_pubrec_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubcomp received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_suback_handler( [&] @@ -93,7 +89,6 @@ void client_proc( c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_publish_handler( [&] @@ -110,7 +105,6 @@ void client_proc( locked_cout() << "[client] topic_name: " << topic_name << std::endl; locked_cout() << "[client] contents: " << contents << std::endl; disconnect(); - return true; }); // Connect @@ -235,7 +229,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::connect_return_code::accepted); - return true; } ); ep.set_disconnect_handler( @@ -250,25 +243,21 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { [] (packet_id_t packet_id){ locked_cout() << "[server] puback received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrec_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrel_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrel received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubcomp_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubcomp received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_publish_handler( [&subs] @@ -293,7 +282,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { std::min(r.first->qos_value, pubopts.get_qos()) ); } - return true; }); ep.set_subscribe_handler( [&subs, wp] @@ -310,7 +298,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos()); } sp->suback(packet_id, res); - return true; } ); ep.set_unsubscribe_handler( @@ -327,7 +314,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { } BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/tls_both_client_cert.cpp b/example/tls_both_client_cert.cpp index 09b0ae7e0..a8227c178 100644 --- a/example/tls_both_client_cert.cpp +++ b/example/tls_both_client_cert.cpp @@ -47,7 +47,6 @@ void client_proc( } ); } - return true; }); c->set_close_handler( [] @@ -64,20 +63,17 @@ void client_proc( (packet_id_t packet_id){ locked_cout() << "[client] puback received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_pubrec_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubcomp received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_suback_handler( [&] @@ -93,7 +89,6 @@ void client_proc( c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_publish_handler( [&] @@ -110,7 +105,6 @@ void client_proc( locked_cout() << "[client] topic_name: " << topic_name << std::endl; locked_cout() << "[client] contents: " << contents << std::endl; disconnect(); - return true; }); // Connect @@ -225,7 +219,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::connect_return_code::accepted); - return true; } ); ep.set_disconnect_handler( @@ -240,25 +233,21 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { [] (packet_id_t packet_id){ locked_cout() << "[server] puback received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrec_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrel_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrel received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubcomp_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubcomp received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_publish_handler( [&subs] @@ -283,7 +272,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { std::min(r.first->qos_value, pubopts.get_qos()) ); } - return true; }); ep.set_subscribe_handler( [&subs, wp] @@ -300,7 +288,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos()); } sp->suback(packet_id, res); - return true; } ); ep.set_unsubscribe_handler( @@ -314,7 +301,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { auto sp = wp.lock(); BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/tls_client.cpp b/example/tls_client.cpp index 1e066277f..abf5c566b 100644 --- a/example/tls_client.cpp +++ b/example/tls_client.cpp @@ -70,7 +70,6 @@ int main(int argc, char** argv) { } ); } - return true; }); c->set_close_handler( [] @@ -87,20 +86,17 @@ int main(int argc, char** argv) { (packet_id_t packet_id){ std::cout << "puback received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_pubrec_handler( [&] (packet_id_t packet_id){ std::cout << "pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] (packet_id_t packet_id){ std::cout << "pubcomp received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_suback_handler( [&] @@ -116,7 +112,6 @@ int main(int argc, char** argv) { c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_publish_handler( [&] @@ -133,7 +128,6 @@ int main(int argc, char** argv) { std::cout << "topic_name: " << topic_name << std::endl; std::cout << "contents: " << contents << std::endl; disconnect(); - return true; }); // Connect diff --git a/example/tls_server.cpp b/example/tls_server.cpp index 266d45598..c2a9e5dd5 100644 --- a/example/tls_server.cpp +++ b/example/tls_server.cpp @@ -153,7 +153,6 @@ int main(int argc, char** argv) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::connect_return_code::accepted); - return true; } ); ep.set_disconnect_handler( @@ -168,25 +167,21 @@ int main(int argc, char** argv) { [] (packet_id_t packet_id){ std::cout << "[server] puback received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrec_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrel_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubrel received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubcomp_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubcomp received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_publish_handler( [&subs] @@ -211,7 +206,6 @@ int main(int argc, char** argv) { std::min(r.first->qos_value, pubopts.get_qos()) ); } - return true; }); ep.set_subscribe_handler( [&subs, wp] @@ -228,7 +222,6 @@ int main(int argc, char** argv) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos()); } sp->suback(packet_id, res); - return true; } ); ep.set_unsubscribe_handler( @@ -245,7 +238,6 @@ int main(int argc, char** argv) { } BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/tls_ws_both.cpp b/example/tls_ws_both.cpp index ae3ca04d2..d263335cc 100644 --- a/example/tls_ws_both.cpp +++ b/example/tls_ws_both.cpp @@ -46,7 +46,6 @@ void client_proc( } ); } - return true; }); c->set_close_handler( [] @@ -63,20 +62,17 @@ void client_proc( (packet_id_t packet_id){ locked_cout() << "[client] puback received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_pubrec_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] (packet_id_t packet_id){ locked_cout() << "[client] pubcomp received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_suback_handler( [&] @@ -92,7 +88,6 @@ void client_proc( c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_publish_handler( [&] @@ -109,7 +104,6 @@ void client_proc( locked_cout() << "[client] topic_name: " << topic_name << std::endl; locked_cout() << "[client] contents: " << contents << std::endl; disconnect(); - return true; }); // Connect @@ -234,7 +228,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::connect_return_code::accepted); - return true; } ); ep.set_disconnect_handler( @@ -249,25 +242,21 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { [] (packet_id_t packet_id){ locked_cout() << "[server] puback received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrec_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrel_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubrel received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubcomp_handler( [] (packet_id_t packet_id){ locked_cout() << "[server] pubcomp received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_publish_handler( [&subs] @@ -292,7 +281,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { std::min(r.first->qos_value, pubopts.get_qos()) ); } - return true; }); ep.set_subscribe_handler( [&subs, wp] @@ -309,7 +297,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos()); } sp->suback(packet_id, res); - return true; } ); ep.set_unsubscribe_handler( @@ -326,7 +313,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { } BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/tls_ws_client.cpp b/example/tls_ws_client.cpp index 98d3ea614..563a45a94 100644 --- a/example/tls_ws_client.cpp +++ b/example/tls_ws_client.cpp @@ -60,7 +60,6 @@ int main(int argc, char** argv) { } ); } - return true; }); c->set_close_handler( [] @@ -77,20 +76,17 @@ int main(int argc, char** argv) { (packet_id_t packet_id){ std::cout << "puback received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_pubrec_handler( [&] (packet_id_t packet_id){ std::cout << "pubrec received. packet_id: " << packet_id << std::endl; - return true; }); c->set_pubcomp_handler( [&] (packet_id_t packet_id){ std::cout << "pubcomp received. packet_id: " << packet_id << std::endl; disconnect(); - return true; }); c->set_suback_handler( [&] @@ -106,7 +102,6 @@ int main(int argc, char** argv) { c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_publish_handler( [&] @@ -123,7 +118,6 @@ int main(int argc, char** argv) { std::cout << "topic_name: " << topic_name << std::endl; std::cout << "contents: " << contents << std::endl; disconnect(); - return true; }); // Connect diff --git a/example/tls_ws_server.cpp b/example/tls_ws_server.cpp index 5cab8c323..7941c0509 100644 --- a/example/tls_ws_server.cpp +++ b/example/tls_ws_server.cpp @@ -153,7 +153,6 @@ int main(int argc, char** argv) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::connect_return_code::accepted); - return true; } ); ep.set_disconnect_handler( @@ -168,25 +167,21 @@ int main(int argc, char** argv) { [] (packet_id_t packet_id){ std::cout << "[server] puback received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrec_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubrec received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubrel_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubrel received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_pubcomp_handler( [] (packet_id_t packet_id){ std::cout << "[server] pubcomp received. packet_id: " << packet_id << std::endl; - return true; }); ep.set_publish_handler( [&subs] @@ -211,7 +206,6 @@ int main(int argc, char** argv) { std::min(r.first->qos_value, pubopts.get_qos()) ); } - return true; }); ep.set_subscribe_handler( [&subs, wp] @@ -228,7 +222,6 @@ int main(int argc, char** argv) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos()); } sp->suback(packet_id, res); - return true; } ); ep.set_unsubscribe_handler( @@ -245,7 +238,6 @@ int main(int argc, char** argv) { } BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/v5_no_tls_both.cpp b/example/v5_no_tls_both.cpp index 8089ba175..f9c517d71 100644 --- a/example/v5_no_tls_both.cpp +++ b/example/v5_no_tls_both.cpp @@ -45,7 +45,6 @@ void client_proc( } ); } - return true; }); c->set_close_handler( // this handler doesn't depend on MQTT protocol version [] @@ -64,7 +63,6 @@ void client_proc( "[client] puback received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; disconnect(); - return true; }); c->set_v5_pubrec_handler( // use v5 handler [&] @@ -72,7 +70,6 @@ void client_proc( locked_cout() << "[client] pubrec received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); c->set_v5_pubcomp_handler( // use v5 handler [&] @@ -81,7 +78,6 @@ void client_proc( "[client] pubcomp received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; disconnect(); - return true; }); c->set_v5_suback_handler( // use v5 handler [&] @@ -112,7 +108,6 @@ void client_proc( c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_v5_publish_handler( // use v5 handler [&] @@ -130,7 +125,6 @@ void client_proc( locked_cout() << "[client] topic_name: " << topic_name << std::endl; locked_cout() << "[client] contents: " << contents << std::endl; disconnect(); - return true; }); // Connect @@ -256,7 +250,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::v5::connect_reason_code::success); - return true; } ); ep.set_v5_disconnect_handler( // use v5 handler @@ -275,7 +268,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { locked_cout() << "[server] puback received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_pubrec_handler( // use v5 handler [] @@ -283,7 +275,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { locked_cout() << "[server] pubrec received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_pubrel_handler( // use v5 handler [] @@ -291,7 +282,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { locked_cout() << "[server] pubrel received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_pubcomp_handler( // use v5 handler [] @@ -299,7 +289,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { locked_cout() << "[server] pubcomp received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_publish_handler( // use v5 handler [&subs] @@ -333,7 +322,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { std::move(props) ); } - return true; }); ep.set_v5_subscribe_handler( // use v5 handler [&subs, wp] @@ -354,7 +342,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos(), e.subopts.get_rap()); } sp->suback(packet_id, res); - return true; } ); ep.set_v5_unsubscribe_handler( // use v5 handler @@ -372,7 +359,6 @@ void server_proc(Server& s, std::set& connections, mi_sub_con& subs) { } BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/example/v5_no_tls_client.cpp b/example/v5_no_tls_client.cpp index e37b7e3e6..02f2f649f 100644 --- a/example/v5_no_tls_client.cpp +++ b/example/v5_no_tls_client.cpp @@ -54,7 +54,6 @@ int main(int argc, char** argv) { } ); } - return true; }); c->set_close_handler( // this handler doesn't depend on MQTT protocol version [] @@ -73,7 +72,6 @@ int main(int argc, char** argv) { "[client] puback received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; disconnect(); - return true; }); c->set_v5_pubrec_handler( // use v5 handler [&] @@ -81,7 +79,6 @@ int main(int argc, char** argv) { std::cout << "[client] pubrec received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); c->set_v5_pubcomp_handler( // use v5 handler [&] @@ -90,7 +87,6 @@ int main(int argc, char** argv) { "[client] pubcomp received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; disconnect(); - return true; }); c->set_v5_suback_handler( // use v5 handler [&] @@ -121,7 +117,6 @@ int main(int argc, char** argv) { c->publish("mqtt_client_cpp/topic2_1", "test2_1", MQTT_NS::qos::at_least_once); c->publish("mqtt_client_cpp/topic2_2", "test2_2", MQTT_NS::qos::exactly_once); } - return true; }); c->set_v5_publish_handler( // use v5 handler [&] @@ -139,7 +134,6 @@ int main(int argc, char** argv) { std::cout << "[client] topic_name: " << topic_name << std::endl; std::cout << "[client] contents: " << contents << std::endl; disconnect(); - return true; }); // Connect diff --git a/example/v5_no_tls_prop.cpp b/example/v5_no_tls_prop.cpp index f92ef4542..05acb503f 100644 --- a/example/v5_no_tls_prop.cpp +++ b/example/v5_no_tls_prop.cpp @@ -97,7 +97,6 @@ void client_proc(Client& c) { c->disconnect(); - return true; }); c->set_close_handler( // this handler doesn't depend on MQTT protocol version [] @@ -265,7 +264,6 @@ void server_proc(Server& s, std::set& connections) { MQTT_NS::v5::property::authentication_data("test authentication data"_mb) }; sp->connack(false, MQTT_NS::v5::connect_reason_code::success, std::move(connack_ps)); - return true; } ); ep.set_v5_disconnect_handler( // use v5 handler diff --git a/example/v5_no_tls_server.cpp b/example/v5_no_tls_server.cpp index 929847802..fb8605f8a 100644 --- a/example/v5_no_tls_server.cpp +++ b/example/v5_no_tls_server.cpp @@ -142,7 +142,6 @@ int main(int argc, char** argv) { BOOST_ASSERT(sp); connections.insert(sp); sp->connack(false, MQTT_NS::v5::connect_reason_code::success); - return true; } ); ep.set_v5_disconnect_handler( // use v5 handler @@ -161,7 +160,6 @@ int main(int argc, char** argv) { std::cout << "[server] puback received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_pubrec_handler( // use v5 handler [] @@ -169,7 +167,6 @@ int main(int argc, char** argv) { std::cout << "[server] pubrec received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_pubrel_handler( // use v5 handler [] @@ -177,7 +174,6 @@ int main(int argc, char** argv) { std::cout << "[server] pubrel received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_pubcomp_handler( // use v5 handler [] @@ -185,7 +181,6 @@ int main(int argc, char** argv) { std::cout << "[server] pubcomp received. packet_id: " << packet_id << " reason_code: " << reason_code << std::endl; - return true; }); ep.set_v5_publish_handler( // use v5 handler [&subs] @@ -219,7 +214,6 @@ int main(int argc, char** argv) { std::move(props) ); } - return true; }); ep.set_v5_subscribe_handler( // use v5 handler [&subs, wp] @@ -240,7 +234,6 @@ int main(int argc, char** argv) { subs.emplace(std::move(e.topic_filter), sp, e.subopts.get_qos(), e.subopts.get_rap()); } sp->suback(packet_id, res); - return true; } ); ep.set_v5_unsubscribe_handler( // use v5 handler @@ -258,7 +251,6 @@ int main(int argc, char** argv) { } BOOST_ASSERT(sp); sp->unsuback(packet_id); - return true; } ); } diff --git a/include/mqtt/apply.hpp b/include/mqtt/apply.hpp new file mode 100644 index 000000000..fef2ac1f6 --- /dev/null +++ b/include/mqtt/apply.hpp @@ -0,0 +1,56 @@ +// Copyright Takatoshi Kondo 2022 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(MQTT_APPLY_HPP) +#define MQTT_APPLY_HPP + +#include +#include +#include + +#include + +namespace MQTT_NS { + +#if cplusplus >= 201703L + +template +decltype(auto) apply(F&& f, Tuple&& t) { + return std::apply(std::forward(f), std::forward(t)); +} + +#else // __cplusplus >= 201703L + +namespace detail { + +template < typename F, typename Tuple, std::size_t... Idx> +constexpr decltype(auto) +apply_impl(F&& f, Tuple&& t, std::index_sequence) { + return static_cast(f)(std::get(static_cast(t))...); +} + +} // namespace detail + +template +constexpr decltype(auto) apply(F&& f, Tuple&& t) { + return + detail::apply_impl( + static_cast(f), + static_cast(t), + std::make_index_sequence< + std::tuple_size< + std::remove_reference_t + >::value + >{} + ); +} + + +#endif // __cplusplus >= 201703L + +} // namespace MQTT_NS + +#endif // MQTT_APPLY_HPP diff --git a/include/mqtt/async_handler.hpp b/include/mqtt/async_handler.hpp new file mode 100644 index 000000000..b23d8d20b --- /dev/null +++ b/include/mqtt/async_handler.hpp @@ -0,0 +1,22 @@ +// Copyright Takatoshi Kondo 2022 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(MQTT_ASYNC_HANDLER_HPP) +#define MQTT_ASYNC_HANDLER_HPP + +#include + +#include +#include +#include + +namespace MQTT_NS { + +using async_handler_t = move_only_handler; + +} // namespace MQTT_NS + +#endif // MQTT_ASYNC_HANDLER_HPP diff --git a/include/mqtt/broker/broker.hpp b/include/mqtt/broker/broker.hpp index a326dfc03..06c80dc1f 100644 --- a/include/mqtt/broker/broker.hpp +++ b/include/mqtt/broker/broker.hpp @@ -236,7 +236,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return connect_handler( + connect_handler( force_move(sp), force_move(client_id), force_move(username), @@ -251,7 +251,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -268,7 +267,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return connect_handler( + connect_handler( force_move(sp), force_move(client_id), force_move(username), @@ -283,7 +282,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -327,7 +325,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return puback_handler( + puback_handler( force_move(sp), packet_id, v5::puback_reason_code::success, @@ -338,7 +336,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -351,7 +348,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return puback_handler( + puback_handler( force_move(sp), packet_id, reason_code, @@ -362,7 +359,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -373,7 +369,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return pubrec_handler( + pubrec_handler( force_move(sp), packet_id, v5::pubrec_reason_code::success, @@ -384,7 +380,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -397,7 +392,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return pubrec_handler( + pubrec_handler( force_move(sp), packet_id, reason_code, @@ -408,7 +403,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -419,7 +413,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return pubrel_handler( + pubrel_handler( force_move(sp), packet_id, v5::pubrel_reason_code::success, @@ -430,7 +424,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -443,7 +436,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return pubrel_handler( + pubrel_handler( force_move(sp), packet_id, reason_code, @@ -454,7 +447,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -465,7 +457,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return pubcomp_handler( + pubcomp_handler( force_move(sp), packet_id, v5::pubcomp_reason_code::success, @@ -476,7 +468,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -489,7 +480,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return pubcomp_handler( + pubcomp_handler( force_move(sp), packet_id, reason_code, @@ -500,7 +491,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -514,7 +504,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return publish_handler( + publish_handler( force_move(sp), packet_id, pubopts, @@ -527,7 +517,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -544,7 +533,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return publish_handler( + publish_handler( force_move(sp), packet_id, pubopts, @@ -557,7 +546,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -569,7 +557,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return subscribe_handler( + subscribe_handler( force_move(sp), packet_id, force_move(entries), @@ -580,7 +568,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -594,7 +581,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return subscribe_handler( + subscribe_handler( force_move(sp), packet_id, force_move(entries), @@ -605,7 +592,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -617,7 +603,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return unsubscribe_handler( + unsubscribe_handler( force_move(sp), packet_id, force_move(entries), @@ -628,7 +614,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -642,7 +627,7 @@ class broker_t { BOOST_ASSERT(sp); auto p = sp.get(); try { - return unsubscribe_handler( + unsubscribe_handler( force_move(sp), packet_id, force_move(entries), @@ -653,7 +638,6 @@ class broker_t { MQTT_LOG("mqtt_broker", error) << MQTT_ADD_VALUE(address, p) << ex.what(); - return true; } } ); @@ -674,7 +658,6 @@ class broker_t { } ); } - return true; } ); ep.set_v5_auth_handler( @@ -683,7 +666,6 @@ class broker_t { v5::properties props ) { if (h_auth_props_) h_auth_props_(force_move(props)); - return true; } ); @@ -721,43 +703,43 @@ class broker_t { pubcomp_props_ = force_move(props); } - void set_connect_props_handler(move_only_function h) { + void set_connect_props_handler(move_only_handler h) { h_connect_props_ = force_move(h); } - void set_disconnect_props_handler(move_only_function h) { + void set_disconnect_props_handler(move_only_handler h) { h_disconnect_props_ = force_move(h); } - void set_publish_props_handler(move_only_function h) { + void set_publish_props_handler(move_only_handler h) { h_publish_props_ = force_move(h); } - void set_puback_props_handler(move_only_function h) { + void set_puback_props_handler(move_only_handler h) { h_puback_props_ = force_move(h); } - void set_pubrec_props_handler(move_only_function h) { + void set_pubrec_props_handler(move_only_handler h) { h_pubrec_props_ = force_move(h); } - void set_pubrel_props_handler(move_only_function h) { + void set_pubrel_props_handler(move_only_handler h) { h_pubrel_props_ = force_move(h); } - void set_pubcomp_props_handler(move_only_function h) { + void set_pubcomp_props_handler(move_only_handler h) { h_pubcomp_props_ = force_move(h); } - void set_subscribe_props_handler(move_only_function h) { + void set_subscribe_props_handler(move_only_handler h) { h_subscribe_props_ = force_move(h); } - void set_unsubscribe_props_handler(move_only_function h) { + void set_unsubscribe_props_handler(move_only_handler h) { h_unsubscribe_props_ = force_move(h); } - void set_auth_props_handler(move_only_function h) { + void set_auth_props_handler(move_only_handler h) { h_auth_props_ = force_move(h); } @@ -815,7 +797,7 @@ class broker_t { * @param req_client_id - the id that the client wants to use (username will be prepended) * @param will - the last-will-and-testiment of the connection, if any. */ - bool connect_handler( + void connect_handler( con_sp_t spep, buffer client_id, optional noauth_username, @@ -862,12 +844,12 @@ class broker_t { } ); - return true; + return; } if (client_id.empty()) { if (!handle_empty_client_id(spep, client_id, clean_start, connack_props)) { - return false; + return; } // A new client id was generated client_id = buffer(string_view(spep->get_client_id())); @@ -1125,8 +1107,6 @@ class broker_t { ); } } - - return true; } struct connect_param { @@ -1174,7 +1154,7 @@ class broker_t { bool session_present, bool authenticated, v5::properties props, - move_only_function finish = [](error_code){} + move_only_handler finish = [](error_code){} ) { // Reply to the connect message. switch (ep.get_protocol_version()) { @@ -1462,7 +1442,7 @@ class broker_t { return close_proc_no_lock(force_move(spep), send_will, rc); } - bool publish_handler( + void publish_handler( con_sp_t spep, optional packet_id, publish_options pubopts, @@ -1481,7 +1461,7 @@ class broker_t { // and/or async_force_disconnect () is called. // During async operation, spep is valid but it has already been // erased from sessions_ - if (it == idx.end()) return true; + if (it == idx.end()) return; auto send_pubres = [&] (bool authorized = true) { @@ -1528,7 +1508,7 @@ class broker_t { // Publish not authorized send_pubres(false); - return true; + return; } v5::properties forward_props; @@ -1564,10 +1544,9 @@ class broker_t { ); send_pubres(); - return true; } - bool puback_handler( + void puback_handler( con_sp_t spep, packet_id_t packet_id, v5::puback_reason_code /*reason_code*/, @@ -1581,18 +1560,16 @@ class broker_t { // and/or async_force_disconnect () is called. // During async operation, spep is valid but it has already been // erased from sessions_ - if (it == idx.end()) return true; + if (it == idx.end()) return; // const_cast is appropriate here // See https://github.com/boostorg/multi_index/issues/50 auto& ss = const_cast(*it); ss.erase_inflight_message_by_packet_id(packet_id); ss.send_offline_messages_by_packet_id_release(); - - return true; } - bool pubrec_handler( + void pubrec_handler( con_sp_t spep, packet_id_t packet_id, v5::pubrec_reason_code reason_code, @@ -1606,14 +1583,14 @@ class broker_t { // and/or async_force_disconnect () is called. // During async operation, spep is valid but it has already been // erased from sessions_ - if (it == idx.end()) return true; + if (it == idx.end()) return; // const_cast is appropriate here // See https://github.com/boostorg/multi_index/issues/50 auto& ss = const_cast(*it); ss.erase_inflight_message_by_packet_id(packet_id); - if (is_error(reason_code)) return true; + if (is_error(reason_code)) return; auto& ep = *spep; @@ -1650,10 +1627,9 @@ class broker_t { BOOST_ASSERT(false); break; } - return true; } - bool pubrel_handler( + void pubrel_handler( con_sp_t spep, packet_id_t packet_id, v5::pubrel_reason_code reason_code, @@ -1667,7 +1643,7 @@ class broker_t { // and/or async_force_disconnect () is called. // During async operation, spep is valid but it has already been // erased from sessions_ - if (it == idx.end()) return true; + if (it == idx.end()) return; auto& ep = *spep; @@ -1705,10 +1681,9 @@ class broker_t { BOOST_ASSERT(false); break; } - return true; } - bool pubcomp_handler( + void pubcomp_handler( con_sp_t spep, packet_id_t packet_id, v5::pubcomp_reason_code /*reason_code*/, @@ -1722,18 +1697,16 @@ class broker_t { // and/or async_force_disconnect () is called. // During async operation, spep is valid but it has already been // erased from sessions_ - if (it == idx.end()) return true; + if (it == idx.end()) return; // const_cast is appropriate here // See https://github.com/boostorg/multi_index/issues/50 auto& ss = const_cast(*it); ss.erase_inflight_message_by_packet_id(packet_id); ss.send_offline_messages_by_packet_id_release(); - - return true; } - bool subscribe_handler( + void subscribe_handler( con_sp_t spep, packet_id_t packet_id, std::vector entries, @@ -1750,7 +1723,7 @@ class broker_t { // and/or async_force_disconnect () is called. // During async operation, spep is valid but it has already been // erased from sessions_ - if (it == idx.end()) return true; + if (it == idx.end()) return; // The element of sessions_ must have longer lifetime // than corresponding subscription. @@ -1792,7 +1765,7 @@ class broker_t { ); }; - std::vector> retain_deliver; + std::vector> retain_deliver; retain_deliver.reserve(entries.size()); // subscription identifier @@ -1909,10 +1882,9 @@ class broker_t { for (auto& f : retain_deliver) { f(); } - return true; } - bool unsubscribe_handler( + void unsubscribe_handler( con_sp_t spep, packet_id_t packet_id, std::vector entries, @@ -1929,7 +1901,7 @@ class broker_t { // and/or async_force_disconnect () is called. // During async operation, spep is valid but it has already been // erased from sessions_ - if (it == idx.end()) return true; + if (it == idx.end()) return; // The element of sessions_ must have longer lifetime // than corresponding subscription. @@ -1988,8 +1960,6 @@ class broker_t { BOOST_ASSERT(false); break; } - - return true; } /** @@ -2175,16 +2145,16 @@ class broker_t { v5::properties pubrec_props_; v5::properties pubrel_props_; v5::properties pubcomp_props_; - move_only_function h_connect_props_; - move_only_function h_disconnect_props_; - move_only_function h_publish_props_; - move_only_function h_puback_props_; - move_only_function h_pubrec_props_; - move_only_function h_pubrel_props_; - move_only_function h_pubcomp_props_; - move_only_function h_subscribe_props_; - move_only_function h_unsubscribe_props_; - move_only_function h_auth_props_; + move_only_handler h_connect_props_; + move_only_handler h_disconnect_props_; + move_only_handler h_publish_props_; + move_only_handler h_puback_props_; + move_only_handler h_pubrec_props_; + move_only_handler h_pubrel_props_; + move_only_handler h_pubcomp_props_; + move_only_handler h_subscribe_props_; + move_only_handler h_unsubscribe_props_; + move_only_handler h_auth_props_; bool pingresp_ = true; bool connack_ = true; }; diff --git a/include/mqtt/broker/session_state.hpp b/include/mqtt/broker/session_state.hpp index 7bcf2bc8e..158645d4b 100644 --- a/include/mqtt/broker/session_state.hpp +++ b/include/mqtt/broker/session_state.hpp @@ -52,7 +52,7 @@ class session_states; * Retained messages do not form part of the Session State in the Server, they are not deleted as a result of a Session ending. */ struct session_state { - using will_sender_t = move_only_function< + using will_sender_t = move_only_handler< void( session_state const& source_ss, buffer topic, @@ -283,7 +283,7 @@ struct session_state { } } - void set_clean_handler(move_only_function handler) { + void set_clean_handler(move_only_handler handler) { clean_handler_ = force_move(handler); } @@ -601,7 +601,7 @@ struct session_state { std::set qos2_publish_handled_; optional response_topic_; - move_only_function clean_handler_; + move_only_handler clean_handler_; }; class session_states { diff --git a/include/mqtt/callable_overlay.hpp b/include/mqtt/callable_overlay.hpp index 01648fb5d..41ca3d83f 100644 --- a/include/mqtt/callable_overlay.hpp +++ b/include/mqtt/callable_overlay.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include namespace MQTT_NS { template @@ -38,20 +38,18 @@ struct callable_overlay final : public Impl * @brief Pingreq handler * See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718086
* 3.13 PINGREQ – PING request - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_pingreq() noexcept override final { - return ! h_pingreq_ || h_pingreq_(); + MQTT_ALWAYS_INLINE void on_pingreq() noexcept override final { + if ( h_pingreq_) h_pingreq_(); } /** * @brief Pingresp handler * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901200
* 3.13 PINGRESP – PING response - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_pingresp() noexcept override final { - return ! h_pingresp_ || h_pingresp_(); + MQTT_ALWAYS_INLINE void on_pingresp() noexcept override final { + if (h_pingresp_) h_pingresp_(); } // MQTT v3_1_1 handlers @@ -90,22 +88,23 @@ struct callable_overlay final : public Impl * Keep Alive
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc385349237
* 3.1.2.10 Keep Alive - * @return if the handler returns true, then continue receiving, otherwise quit. * */ - MQTT_ALWAYS_INLINE bool on_connect(buffer client_id, + MQTT_ALWAYS_INLINE void on_connect(buffer client_id, optional user_name, optional password, optional will, bool clean_session, std::uint16_t keep_alive) noexcept override final { - return ! h_connect_ - || h_connect_(force_move(client_id), - force_move(user_name), - force_move(password), - force_move(will), - clean_session, - keep_alive); + if (h_connect_) + h_connect_( + force_move(client_id), + force_move(user_name), + force_move(password), + force_move(will), + clean_session, + keep_alive + ); } /** @@ -118,11 +117,9 @@ struct callable_overlay final : public Impl * connect_return_code
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718036
* 3.2.2.3 Connect Return code - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_connack(bool session_present, connect_return_code return_code) noexcept override final { - return ! h_connack_ - || h_connack_(session_present, return_code); + MQTT_ALWAYS_INLINE void on_connack(bool session_present, connect_return_code return_code) noexcept override final { + if (h_connack_) h_connack_(session_present, return_code); } /** @@ -140,17 +137,18 @@ struct callable_overlay final : public Impl * Topic name * @param contents * Published contents - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_publish(optional packet_id, + MQTT_ALWAYS_INLINE void on_publish(optional packet_id, publish_options pubopts, buffer topic_name, buffer contents) noexcept override final { - return ! h_publish_ - || h_publish_(packet_id, - pubopts, - force_move(topic_name), - force_move(contents)); + if (h_publish_) + h_publish_( + packet_id, + pubopts, + force_move(topic_name), + force_move(contents) + ); } /** @@ -159,11 +157,9 @@ struct callable_overlay final : public Impl * packet identifier
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718045
* 3.4.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_puback(packet_id_t packet_id) noexcept override final { - return ! h_puback_ - || h_puback_(packet_id); + MQTT_ALWAYS_INLINE void on_puback(packet_id_t packet_id) noexcept override final { + if (h_puback_) h_puback_(packet_id); } /** @@ -172,11 +168,9 @@ struct callable_overlay final : public Impl * packet identifier
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718050
* 3.5.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_pubrec(packet_id_t packet_id) noexcept override final { - return ! h_pubrec_ - || h_pubrec_(packet_id); + MQTT_ALWAYS_INLINE void on_pubrec(packet_id_t packet_id) noexcept override final { + if (h_pubrec_) h_pubrec_(packet_id); } /** @@ -185,11 +179,9 @@ struct callable_overlay final : public Impl * packet identifier
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc385349791
* 3.6.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_pubrel(packet_id_t packet_id) noexcept override final { - return ! h_pubrel_ - || h_pubrel_(packet_id); + MQTT_ALWAYS_INLINE void on_pubrel(packet_id_t packet_id) noexcept override final { + if (h_pubrel_) h_pubrel_(packet_id); } /** @@ -198,11 +190,9 @@ struct callable_overlay final : public Impl * packet identifier
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718060
* 3.7.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_pubcomp(packet_id_t packet_id) noexcept override final { - return ! h_pubcomp_ - || h_pubcomp_(packet_id); + MQTT_ALWAYS_INLINE void on_pubcomp(packet_id_t packet_id) noexcept override final { + if (h_pubcomp_) h_pubcomp_(packet_id); } /** @@ -213,12 +203,10 @@ struct callable_overlay final : public Impl * @param entries * Collection of Share Name, Topic Filter, and QoS.
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc385349802
- * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_subscribe(packet_id_t packet_id, + MQTT_ALWAYS_INLINE void on_subscribe(packet_id_t packet_id, std::vector entries) noexcept override final { - return ! h_subscribe_ - || h_subscribe_(packet_id, force_move(entries)); + if (h_subscribe_) h_subscribe_(packet_id, force_move(entries)); } /** @@ -230,12 +218,10 @@ struct callable_overlay final : public Impl * Collection of QoS that is corresponding to subscribed topic order.
* If subscription is failure, the value is nullopt.
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718071
- * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_suback(packet_id_t packet_id, + MQTT_ALWAYS_INLINE void on_suback(packet_id_t packet_id, std::vector reasons) noexcept override final { - return ! h_suback_ - || h_suback_(packet_id, force_move(reasons)); + if (h_suback_) h_suback_(packet_id, force_move(reasons)); } /** @@ -246,12 +232,10 @@ struct callable_overlay final : public Impl * @param topics * Collection of Share Name and Topic Filter
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc384800448
- * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_unsubscribe(packet_id_t packet_id, + MQTT_ALWAYS_INLINE void on_unsubscribe(packet_id_t packet_id, std::vector entries) noexcept override final { - return ! h_unsubscribe_ - || h_unsubscribe_(packet_id, force_move(entries)); + if (h_unsubscribe_) h_unsubscribe_(packet_id, force_move(entries)); } /** @@ -259,11 +243,9 @@ struct callable_overlay final : public Impl * @param packet_id packet identifier
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718045
* 3.11.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_unsuback(packet_id_t packet_id) noexcept override final { - return ! h_unsuback_ - || h_unsuback_(packet_id); + MQTT_ALWAYS_INLINE void on_unsuback(packet_id_t packet_id) noexcept override final { + if (h_unsuback_) h_unsuback_(packet_id); } /** @@ -272,7 +254,7 @@ struct callable_overlay final : public Impl * 3.14 DISCONNECT – Disconnect notification */ MQTT_ALWAYS_INLINE void on_disconnect() noexcept override final { - if(h_disconnect_) h_disconnect_(); + if (h_disconnect_) h_disconnect_(); } // MQTT v5 handlers @@ -317,24 +299,25 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
* 3.1.2.11 CONNECT Properties - * @return if the handler returns true, then continue receiving, otherwise quit. * */ - MQTT_ALWAYS_INLINE bool on_v5_connect(buffer client_id, + MQTT_ALWAYS_INLINE void on_v5_connect(buffer client_id, optional user_name, optional password, optional will, bool clean_start, std::uint16_t keep_alive, v5::properties props) noexcept override final { - return ! h_v5_connect_ - || h_v5_connect_(force_move(client_id), - force_move(user_name), - force_move(password), - force_move(will), - clean_start, - keep_alive, - force_move(props)); + if (h_v5_connect_) + h_v5_connect_( + force_move(client_id), + force_move(user_name), + force_move(password), + force_move(will), + clean_start, + keep_alive, + force_move(props) + ); } /** @@ -351,13 +334,11 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901080
* 3.2.2.3 CONNACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_v5_connack(bool session_present, + MQTT_ALWAYS_INLINE void on_v5_connack(bool session_present, v5::connect_reason_code reason_code, v5::properties props) noexcept override final { - return ! h_v5_connack_ - || h_v5_connack_(session_present, reason_code, force_move(props)); + if (h_v5_connack_) h_v5_connack_(session_present, reason_code, force_move(props)); } /** @@ -383,19 +364,20 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901109
* 3.3.2.3 PUBLISH Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_v5_publish(optional packet_id, + MQTT_ALWAYS_INLINE void on_v5_publish(optional packet_id, publish_options pubopts, buffer topic_name, buffer contents, v5::properties props) noexcept override final { - return ! h_v5_publish_ - || h_v5_publish_(packet_id, - pubopts, - force_move(topic_name), - force_move(contents), - force_move(props)); + if (h_v5_publish_) + h_v5_publish_( + packet_id, + pubopts, + force_move(topic_name), + force_move(contents), + force_move(props) + ); } /** @@ -412,13 +394,16 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901125
* 3.4.2.2 PUBACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_v5_puback(packet_id_t packet_id, + MQTT_ALWAYS_INLINE void on_v5_puback(packet_id_t packet_id, v5::puback_reason_code reason_code, v5::properties props) noexcept override final { - return ! h_v5_puback_ - || h_v5_puback_(packet_id, reason_code, force_move(props)); + if (h_v5_puback_) + h_v5_puback_( + packet_id, + reason_code, + force_move(props) + ); } /** @@ -435,13 +420,11 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901135
* 3.5.2.2 PUBREC Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_v5_pubrec(packet_id_t packet_id, + MQTT_ALWAYS_INLINE void on_v5_pubrec(packet_id_t packet_id, v5::pubrec_reason_code reason_code, v5::properties props) noexcept override final { - return ! h_v5_pubrec_ - || h_v5_pubrec_(packet_id, reason_code, force_move(props)); + if (h_v5_pubrec_) h_v5_pubrec_(packet_id, reason_code, force_move(props)); } /** @@ -458,13 +441,11 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901145
* 3.6.2.2 PUBREL Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_v5_pubrel(packet_id_t packet_id, + MQTT_ALWAYS_INLINE void on_v5_pubrel(packet_id_t packet_id, v5::pubrel_reason_code reason_code, v5::properties props) noexcept override final { - return ! h_v5_pubrel_ - || h_v5_pubrel_(packet_id, reason_code, force_move(props)); + if (h_v5_pubrel_) h_v5_pubrel_(packet_id, reason_code, force_move(props)); } /** @@ -481,13 +462,11 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901155
* 3.7.2.2 PUBCOMP Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_v5_pubcomp(packet_id_t packet_id, + MQTT_ALWAYS_INLINE void on_v5_pubcomp(packet_id_t packet_id, v5::pubcomp_reason_code reason_code, v5::properties props) noexcept override final { - return ! h_v5_pubcomp_ - || h_v5_pubcomp_(packet_id, reason_code, force_move(props)); + if (h_v5_pubcomp_) h_v5_pubcomp_(packet_id, reason_code, force_move(props)); } /** @@ -502,13 +481,11 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901164
* 3.8.2.1 SUBSCRIBE Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_v5_subscribe(packet_id_t packet_id, + MQTT_ALWAYS_INLINE void on_v5_subscribe(packet_id_t packet_id, std::vector entries, v5::properties props) noexcept override final { - return ! h_v5_subscribe_ - || h_v5_subscribe_(packet_id, force_move(entries), force_move(props)); + if (h_v5_subscribe_) h_v5_subscribe_(packet_id, force_move(entries), force_move(props)); } /** @@ -524,13 +501,11 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901174
* 3.9.2.1 SUBACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_v5_suback(packet_id_t packet_id, + MQTT_ALWAYS_INLINE void on_v5_suback(packet_id_t packet_id, std::vector reasons, v5::properties props) noexcept override final { - return ! h_v5_suback_ - || h_v5_suback_(packet_id, force_move(reasons), force_move(props)); + if (h_v5_suback_) h_v5_suback_(packet_id, force_move(reasons), force_move(props)); } /** @@ -546,13 +521,11 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901182
* 3.10.2.1 UNSUBSCRIBE Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_v5_unsubscribe(packet_id_t packet_id, + MQTT_ALWAYS_INLINE void on_v5_unsubscribe(packet_id_t packet_id, std::vector entries, v5::properties props) noexcept override final { - return ! h_v5_unsubscribe_ - || h_v5_unsubscribe_(packet_id, force_move(entries), force_move(props)); + if (h_v5_unsubscribe_) h_v5_unsubscribe_(packet_id, force_move(entries), force_move(props)); } /** @@ -568,13 +541,11 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901190
* 3.11.2.1 UNSUBACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_v5_unsuback(packet_id_t packet_id, + MQTT_ALWAYS_INLINE void on_v5_unsuback(packet_id_t packet_id, std::vector reasons, v5::properties props) noexcept override final { - return ! h_v5_unsuback_ - || h_v5_unsuback_(packet_id, force_move(reasons), force_move(props)); + if (h_v5_unsuback_) h_v5_unsuback_(packet_id, force_move(reasons), force_move(props)); } /** @@ -607,12 +578,10 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901221
* 3.15.2.2 AUTH Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - MQTT_ALWAYS_INLINE bool on_v5_auth(v5::auth_reason_code reason_code, + MQTT_ALWAYS_INLINE void on_v5_auth(v5::auth_reason_code reason_code, v5::properties props) noexcept override final { - return ! h_v5_auth_ - || h_v5_auth_(reason_code, force_move(props)); + if (h_v5_auth_) h_v5_auth_(reason_code, force_move(props)); } @@ -757,17 +726,15 @@ struct callable_overlay final : public Impl * @brief Pingreq handler * See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718086
* 3.13 PINGREQ – PING request - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using pingreq_handler = move_only_function; + using pingreq_handler = copyable_handler; /** * @brief Pingresp handler * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901200
* 3.13 PINGRESP – PING response - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using pingresp_handler = move_only_function; + using pingresp_handler = copyable_handler; // MQTT v3_1_1 handlers @@ -806,11 +773,10 @@ struct callable_overlay final : public Impl * Keep Alive
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc385349237
* 3.1.2.10 Keep Alive - * @return if the handler returns true, then continue receiving, otherwise quit. * */ - using connect_handler = move_only_function< - bool(buffer client_id, + using connect_handler = copyable_handler< + void(buffer client_id, optional user_name, optional password, optional will, @@ -827,9 +793,8 @@ struct callable_overlay final : public Impl * connect_return_code
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718036
* 3.2.2.3 Connect Return code - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using connack_handler = move_only_function; + using connack_handler = copyable_handler; /** * @brief Publish handler @@ -846,9 +811,8 @@ struct callable_overlay final : public Impl * Topic name * @param contents * Published contents - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using publish_handler = move_only_function packet_id, + using publish_handler = copyable_handler packet_id, publish_options pubopts, buffer topic_name, buffer contents)>; @@ -859,9 +823,8 @@ struct callable_overlay final : public Impl * packet identifier
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718045
* 3.4.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using puback_handler = move_only_function; + using puback_handler = copyable_handler; /** * @brief Pubrec handler @@ -869,9 +832,8 @@ struct callable_overlay final : public Impl * packet identifier
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718050
* 3.5.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using pubrec_handler = move_only_function; + using pubrec_handler = copyable_handler; /** * @brief Pubrel handler @@ -879,9 +841,8 @@ struct callable_overlay final : public Impl * packet identifier
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc385349791
* 3.6.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using pubrel_handler = move_only_function; + using pubrel_handler = copyable_handler; /** * @brief Pubcomp handler @@ -889,9 +850,8 @@ struct callable_overlay final : public Impl * packet identifier
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718060
* 3.7.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using pubcomp_handler = move_only_function; + using pubcomp_handler = copyable_handler; /** * @brief Subscribe handler @@ -901,9 +861,8 @@ struct callable_overlay final : public Impl * @param entries * Collection of Share Name, Topic Filter, and QoS.
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc385349802
- * @return if the handler returns true, then continue receiving, otherwise quit. */ - using subscribe_handler = move_only_function entries)>; /** @@ -915,9 +874,8 @@ struct callable_overlay final : public Impl * Collection of QoS that is corresponding to subscribed topic order.
* If subscription is failure, the value is nullopt.
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718071
- * @return if the handler returns true, then continue receiving, otherwise quit. */ - using suback_handler = move_only_function qoss)>; /** @@ -928,9 +886,8 @@ struct callable_overlay final : public Impl * @param entries * Collection of Share Name and Topic Filter
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc384800448
- * @return if the handler returns true, then continue receiving, otherwise quit. */ - using unsubscribe_handler = move_only_function entries)>; /** @@ -938,16 +895,15 @@ struct callable_overlay final : public Impl * @param packet_id packet identifier
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718045
* 3.11.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using unsuback_handler = move_only_function; + using unsuback_handler = copyable_handler; /** * @brief Disconnect handler * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc384800463
* 3.14 DISCONNECT – Disconnect notification */ - using disconnect_handler = move_only_function; + using disconnect_handler = copyable_handler; // MQTT v5 handlers @@ -991,11 +947,10 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
* 3.1.2.11 CONNECT Properties - * @return if the handler returns true, then continue receiving, otherwise quit. * */ - using v5_connect_handler = move_only_function< - bool(buffer client_id, + using v5_connect_handler = copyable_handler< + void(buffer client_id, optional user_name, optional password, optional will, @@ -1018,10 +973,9 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901080
* 3.2.2.3 CONNACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using v5_connack_handler = move_only_function< - bool(bool session_present, + using v5_connack_handler = copyable_handler< + void(bool session_present, v5::connect_reason_code reason_code, v5::properties props) >; @@ -1049,10 +1003,9 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901109
* 3.3.2.3 PUBLISH Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using v5_publish_handler = move_only_function< - bool(optional packet_id, + using v5_publish_handler = copyable_handler< + void(optional packet_id, publish_options pubopts, buffer topic_name, buffer contents, @@ -1073,10 +1026,9 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901125
* 3.4.2.2 PUBACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using v5_puback_handler = move_only_function< - bool(packet_id_t packet_id, + using v5_puback_handler = copyable_handler< + void(packet_id_t packet_id, v5::puback_reason_code reason_code, v5::properties props) >; @@ -1095,10 +1047,9 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901135
* 3.5.2.2 PUBREC Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using v5_pubrec_handler = move_only_function< - bool(packet_id_t packet_id, + using v5_pubrec_handler = copyable_handler< + void(packet_id_t packet_id, v5::pubrec_reason_code reason_code, v5::properties props) >; @@ -1117,10 +1068,9 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901145
* 3.6.2.2 PUBREL Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using v5_pubrel_handler = move_only_function< - bool(packet_id_t packet_id, + using v5_pubrel_handler = copyable_handler< + void(packet_id_t packet_id, v5::pubrel_reason_code reason_code, v5::properties props) >; @@ -1139,10 +1089,9 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901155
* 3.7.2.2 PUBCOMP Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using v5_pubcomp_handler = move_only_function< - bool(packet_id_t packet_id, + using v5_pubcomp_handler = copyable_handler< + void(packet_id_t packet_id, v5::pubcomp_reason_code reason_code, v5::properties props) >; @@ -1159,10 +1108,9 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901164
* 3.8.2.1 SUBSCRIBE Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using v5_subscribe_handler = move_only_function< - bool(packet_id_t packet_id, + using v5_subscribe_handler = copyable_handler< + void(packet_id_t packet_id, std::vector entries, v5::properties props) >; @@ -1180,10 +1128,9 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901174
* 3.9.2.1 SUBACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using v5_suback_handler = move_only_function< - bool(packet_id_t packet_id, + using v5_suback_handler = copyable_handler< + void(packet_id_t packet_id, std::vector reasons, v5::properties props) >; @@ -1201,10 +1148,9 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901182
* 3.10.2.1 UNSUBSCRIBE Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using v5_unsubscribe_handler = move_only_function< - bool(packet_id_t packet_id, + using v5_unsubscribe_handler = copyable_handler< + void(packet_id_t packet_id, std::vector entries, v5::properties props) >; @@ -1222,10 +1168,9 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901190
* 3.11.2.1 UNSUBACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using v5_unsuback_handler = move_only_function< - bool(packet_id_t, + using v5_unsuback_handler = copyable_handler< + void(packet_id_t, std::vector reasons, v5::properties props) >; @@ -1243,7 +1188,7 @@ struct callable_overlay final : public Impl * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901209
* 3.14.2.2 DISCONNECT Properties */ - using v5_disconnect_handler = move_only_function< + using v5_disconnect_handler = copyable_handler< void(v5::disconnect_reason_code reason_code, v5::properties props) >; @@ -1260,10 +1205,9 @@ struct callable_overlay final : public Impl * Properties
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901221
* 3.15.2.2 AUTH Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - using v5_auth_handler = move_only_function< - bool(v5::auth_reason_code reason_code, + using v5_auth_handler = copyable_handler< + void(v5::auth_reason_code reason_code, v5::properties props) >; @@ -1276,7 +1220,7 @@ struct callable_overlay final : public Impl * This handler is called if the client called `disconnect()` and the server closed the socket cleanly. * If the socket is closed by other reasons, error_handler is called. */ - using close_handler = move_only_function; + using close_handler = copyable_handler; /** * @brief Error handler @@ -1285,7 +1229,7 @@ struct callable_overlay final : public Impl * * @param ec error code */ - using error_handler = move_only_function; + using error_handler = copyable_handler; /** * @brief Publish response sent handler @@ -1295,7 +1239,7 @@ struct callable_overlay final : public Impl * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901026
* 2.2.1 Packet Identifier */ - using pub_res_sent_handler = move_only_function; + using pub_res_sent_handler = copyable_handler; /** * @brief Serialize publish handler @@ -1303,7 +1247,7 @@ struct callable_overlay final : public Impl * To restore the message, use restore_serialized_message(). * @param msg publish message */ - using serialize_publish_message_handler = move_only_function msg)>; + using serialize_publish_message_handler = copyable_handler msg)>; /** * @brief Serialize publish handler @@ -1311,7 +1255,7 @@ struct callable_overlay final : public Impl * To restore the message, use restore_serialized_message(). * @param msg v5::publish message */ - using serialize_v5_publish_message_handler = move_only_function msg)>; + using serialize_v5_publish_message_handler = copyable_handler msg)>; /** * @brief Serialize publish handler @@ -1321,7 +1265,7 @@ struct callable_overlay final : public Impl * @param data pointer to the serializing message * @param size size of the serializing message */ - using serialize_publish_handler = move_only_function; + using serialize_publish_handler = copyable_handler; /** * @brief Serialize pubrel handler @@ -1331,7 +1275,7 @@ struct callable_overlay final : public Impl * To restore the message, use restore_serialized_message(). * @param msg pubrel message */ - using serialize_pubrel_message_handler = move_only_function msg)>; + using serialize_pubrel_message_handler = copyable_handler msg)>; /** * @brief Serialize pubrel handler @@ -1341,7 +1285,7 @@ struct callable_overlay final : public Impl * To restore the message, use restore_serialized_message(). * @param msg pubrel message */ - using serialize_v5_pubrel_message_handler = move_only_function msg)>; + using serialize_v5_pubrel_message_handler = copyable_handler msg)>; /** * @brief Serialize pubrel handler @@ -1353,19 +1297,19 @@ struct callable_overlay final : public Impl * @param data pointer to the serializing message * @param size size of the serializing message */ - using serialize_pubrel_handler = move_only_function; + using serialize_pubrel_handler = copyable_handler; /** * @brief Remove serialized message * @param packet_id packet identifier of the removing message */ - using serialize_remove_handler = move_only_function; + using serialize_remove_handler = copyable_handler; /** * @brief Pre-send handler * This handler is called when any mqtt control packet is decided to send. */ - using pre_send_handler = move_only_function; + using pre_send_handler = copyable_handler; /** * @brief is valid length handler @@ -1375,7 +1319,7 @@ struct callable_overlay final : public Impl * @return true if check is success, otherwise false */ using is_valid_length_handler = - move_only_function; + copyable_function; /** * @brief next read handler @@ -1383,7 +1327,7 @@ struct callable_overlay final : public Impl * @param func A callback function that is called when async operation will finish. */ using mqtt_message_processed_handler = - move_only_function; + copyable_handler; @@ -2075,7 +2019,7 @@ struct callable_overlay final : public Impl * @brief Get error handler * @return handler */ - error_handler const& get_error_handler() const { + error_handler get_error_handler() const { return h_error_; } diff --git a/include/mqtt/client.hpp b/include/mqtt/client.hpp index 527bf303d..b4185db58 100644 --- a/include/mqtt/client.hpp +++ b/include/mqtt/client.hpp @@ -501,8 +501,6 @@ class client : public endpoint { protected: struct constructor_access{}; public: - using async_handler_t = typename base::async_handler_t; - /** * Constructor used by factory functions at the end of this file. */ diff --git a/include/mqtt/copyable_function.hpp b/include/mqtt/copyable_function.hpp new file mode 100644 index 000000000..f59e66e64 --- /dev/null +++ b/include/mqtt/copyable_function.hpp @@ -0,0 +1,30 @@ +// Copyright Takatoshi Kondo 2022 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(MQTT_COPYABLE_FUNCTION_HPP) +#define MQTT_COPYABLE_FUNCTION_HPP + +#pragma GCC diagnostic push +#if defined(__GNUC__) +#pragma GCC diagnostic ignored "-Waddress" +#endif // defined(__GNUC__) + +#include + +#include + +namespace MQTT_NS { + +template +using copyable_function = fu2::function; + +} // namespace MQTT_NS + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif // defined(__GNUC__) + +#endif // MQTT_COPYABLE_FUNCTION_HPP diff --git a/include/mqtt/copyable_handler.hpp b/include/mqtt/copyable_handler.hpp new file mode 100644 index 000000000..919a63885 --- /dev/null +++ b/include/mqtt/copyable_handler.hpp @@ -0,0 +1,66 @@ +// Copyright Takatoshi Kondo 2022 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(MQTT_COPYABLE_HANDLER_HPP) +#define MQTT_COPYABLE_HANDLER_HPP + +#include + +#include + +#include +#include +#include +#include + +namespace MQTT_NS { + +namespace as = boost::asio; + +template +struct copyable_handler { + using executor_type = as::any_io_executor; + + copyable_handler() = default; + + template < + typename Func, + typename std::enable_if_t< + std::is_convertible>::value + >* = nullptr + > + copyable_handler(Func&& f) + : exe_{as::get_associated_executor(f)}, + func_{std::forward(f)} + { + } + + executor_type get_executor() const { return exe_; } + + template + void operator()(Params&&... params) { + if (exe_ == as::system_executor()) { + func_(std::forward(params)...); + return; + } + as::dispatch( + exe_, + [func = func_, pt = std::tuple(std::forward(params)...)] () mutable { + MQTT_NS::apply(force_move(func), std::move(pt)); + } + ); + } + + operator bool() const { return static_cast(func_); } + +private: + executor_type exe_; + copyable_function func_; +}; + +} // namespace MQTT_NS + +#endif // MQTT_COPYABLE_HANDLER_HPP diff --git a/include/mqtt/endpoint.hpp b/include/mqtt/endpoint.hpp index 49dd21e25..82271cc9c 100644 --- a/include/mqtt/endpoint.hpp +++ b/include/mqtt/endpoint.hpp @@ -71,7 +71,7 @@ #include #include #include -#include +#include #if defined(MQTT_USE_WS) #include @@ -174,7 +174,6 @@ class endpoint : public std::enable_shared_from_this; public: - using async_handler_t = move_only_function; using packet_id_t = typename packet_id_type::type; /** @@ -239,15 +238,14 @@ class endpoint : public std::enable_shared_from_this * 3.13 PINGRESP – PING response - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_pingresp() noexcept = 0; + virtual void on_pingresp() noexcept = 0; // MQTT v3_1_1 handlers @@ -286,10 +284,9 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc385349237
* 3.1.2.10 Keep Alive - * @return if the handler returns true, then continue receiving, otherwise quit. * */ - virtual bool on_connect(buffer client_id, + virtual void on_connect(buffer client_id, optional user_name, optional password, optional will, @@ -306,9 +303,8 @@ class endpoint : public std::enable_shared_from_this * See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718036
* 3.2.2.3 Connect Return code - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_connack(bool session_present, connect_return_code return_code) noexcept = 0; + virtual void on_connack(bool session_present, connect_return_code return_code) noexcept = 0; /** * @brief Publish handler @@ -325,9 +321,8 @@ class endpoint : public std::enable_shared_from_this packet_id, + virtual void on_publish(optional packet_id, publish_options pubopts, buffer topic_name, buffer contents) noexcept = 0; @@ -338,9 +333,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718045
* 3.4.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_puback(packet_id_t packet_id) noexcept = 0; + virtual void on_puback(packet_id_t packet_id) noexcept = 0; /** * @brief Pubrec handler @@ -348,9 +342,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718050
* 3.5.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_pubrec(packet_id_t packet_id) noexcept = 0; + virtual void on_pubrec(packet_id_t packet_id) noexcept = 0; /** * @brief Pubrel handler @@ -358,9 +351,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc385349791
* 3.6.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_pubrel(packet_id_t packet_id) noexcept = 0; + virtual void on_pubrel(packet_id_t packet_id) noexcept = 0; /** * @brief Pubcomp handler @@ -368,9 +360,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718060
* 3.7.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_pubcomp(packet_id_t packet_id) noexcept = 0; + virtual void on_pubcomp(packet_id_t packet_id) noexcept = 0; /** * @brief Subscribe handler @@ -380,9 +371,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc385349802
- * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_subscribe(packet_id_t packet_id, + virtual void on_subscribe(packet_id_t packet_id, std::vector entries) noexcept = 0; /** @@ -394,9 +384,8 @@ class endpoint : public std::enable_shared_from_this * If subscription is failure, the value is nullopt.
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718071
- * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_suback(packet_id_t packet_id, std::vector returns) noexcept = 0; + virtual void on_suback(packet_id_t packet_id, std::vector returns) noexcept = 0; /** * @brief Unsubscribe handler @@ -406,18 +395,16 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc384800448
- * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_unsubscribe(packet_id_t packet_id, std::vector entries) noexcept = 0; + virtual void on_unsubscribe(packet_id_t packet_id, std::vector entries) noexcept = 0; /** * @brief Unsuback handler * @param packet_id packet identifier
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718045
* 3.11.2 Variable header - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_unsuback(packet_id_t) noexcept = 0; + virtual void on_unsuback(packet_id_t) noexcept = 0; /** * @brief Disconnect handler @@ -468,10 +455,9 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
* 3.1.2.11 CONNECT Properties - * @return if the handler returns true, then continue receiving, otherwise quit. * */ - virtual bool on_v5_connect(buffer client_id, + virtual void on_v5_connect(buffer client_id, optional user_name, optional password, optional will, @@ -493,9 +479,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901080
* 3.2.2.3 CONNACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_v5_connack(bool session_present, + virtual void on_v5_connack(bool session_present, v5::connect_reason_code reason_code, v5::properties props) noexcept = 0; @@ -522,9 +507,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901109
* 3.3.2.3 PUBLISH Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_v5_publish(optional packet_id, + virtual void on_v5_publish(optional packet_id, publish_options pubopts, buffer topic_name, buffer contents, @@ -544,9 +528,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901125
* 3.4.2.2 PUBACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_v5_puback(packet_id_t packet_id, + virtual void on_v5_puback(packet_id_t packet_id, v5::puback_reason_code reason_code, v5::properties props) noexcept = 0; @@ -564,9 +547,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901135
* 3.5.2.2 PUBREC Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_v5_pubrec(packet_id_t packet_id, + virtual void on_v5_pubrec(packet_id_t packet_id, v5::pubrec_reason_code reason_code, v5::properties props) noexcept = 0; @@ -584,9 +566,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901145
* 3.6.2.2 PUBREL Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_v5_pubrel(packet_id_t packet_id, + virtual void on_v5_pubrel(packet_id_t packet_id, v5::pubrel_reason_code reason_code, v5::properties props) noexcept = 0; @@ -604,9 +585,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901155
* 3.7.2.2 PUBCOMP Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_v5_pubcomp(packet_id_t packet_id, + virtual void on_v5_pubcomp(packet_id_t packet_id, v5::pubcomp_reason_code reason_code, v5::properties props) noexcept = 0; @@ -622,9 +602,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901164
* 3.8.2.1 SUBSCRIBE Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_v5_subscribe(packet_id_t packet_id, + virtual void on_v5_subscribe(packet_id_t packet_id, std::vector entries, v5::properties props) noexcept = 0; @@ -641,9 +620,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901174
* 3.9.2.1 SUBACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_v5_suback(packet_id_t packet_id, + virtual void on_v5_suback(packet_id_t packet_id, std::vector reasons, v5::properties props) noexcept = 0; @@ -660,9 +638,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901182
* 3.10.2.1 UNSUBSCRIBE Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_v5_unsubscribe(packet_id_t packet_id, + virtual void on_v5_unsubscribe(packet_id_t packet_id, std::vector entries, v5::properties props) noexcept = 0; @@ -679,9 +656,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901190
* 3.11.2.1 UNSUBACK Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_v5_unsuback(packet_id_t, + virtual void on_v5_unsuback(packet_id_t, std::vector reasons, v5::properties props) noexcept = 0; @@ -713,9 +689,8 @@ class endpoint : public std::enable_shared_from_this * See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901221
* 3.15.2.2 AUTH Properties - * @return if the handler returns true, then continue receiving, otherwise quit. */ - virtual bool on_v5_auth(v5::auth_reason_code reason_code, + virtual void on_v5_auth(v5::auth_reason_code reason_code, v5::properties props) noexcept = 0; // Original handlers @@ -4323,7 +4298,7 @@ class endpoint : public std::enable_shared_from_this f) { + void for_each_store(move_only_handler f) { MQTT_LOG("mqtt_api", info) << MQTT_ADD_VALUE(address, this) << "for_each_store(ptr, size)"; @@ -4345,7 +4320,7 @@ class endpoint : public std::enable_shared_from_this)> f) { + void for_each_store(move_only_handler)> f) { MQTT_LOG("mqtt_api", info) << MQTT_ADD_VALUE(address, this) << "for_each_store(store_message_variant)"; @@ -4366,7 +4341,7 @@ class endpoint : public std::enable_shared_from_this, any)> f) { + void for_each_store_with_life_keeper(move_only_handler, any)> f) { MQTT_LOG("mqtt_api", info) << MQTT_ADD_VALUE(address, this) @@ -5749,7 +5724,7 @@ class endpoint : public std::enable_shared_from_this; using parse_handler = - move_only_function< + move_only_handler< void( this_type_sp&& spep, any&& session_life_keeper, @@ -7370,58 +7345,56 @@ class endpoint : public std::enable_shared_from_this(in_place_init, - force_move(will_topic_), - force_move(will_payload_), - connect_flags::has_will_retain(connect_flag_) | connect_flags::will_qos(connect_flag_)) + ep_.on_connect( + force_move(client_id_), + force_move(user_name_), + force_move(password_), + connect_flags::has_will_flag(connect_flag_) + ? optional( + in_place_init, + force_move(will_topic_), + force_move(will_payload_), + connect_flags::has_will_retain(connect_flag_) | connect_flags::will_qos(connect_flag_)) : optional(nullopt), - ep_.clean_session(), - keep_alive_ - ) - ) { - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.clean_session(), + keep_alive_ + ); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; case protocol_version::v5: - if (ep_.on_v5_connect( - force_move(client_id_), - force_move(user_name_), - force_move(password_), - connect_flags::has_will_flag(connect_flag_) - ? optional(in_place_init, - force_move(will_topic_), - force_move(will_payload_), - connect_flags::has_will_retain(connect_flag_) | connect_flags::will_qos(connect_flag_), - force_move(will_props_)) + ep_.on_v5_connect( + force_move(client_id_), + force_move(user_name_), + force_move(password_), + connect_flags::has_will_flag(connect_flag_) + ? optional( + in_place_init, + force_move(will_topic_), + force_move(will_payload_), + connect_flags::has_will_retain(connect_flag_) | connect_flags::will_qos(connect_flag_), + force_move(will_props_)) : optional(nullopt), - ep_.clean_start(), - keep_alive_, - force_move(props_) - ) - ) { - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.clean_start(), + keep_alive_, + force_move(props_) + ); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; default: BOOST_ASSERT(false); @@ -7543,39 +7516,35 @@ class endpoint : public std::enable_shared_from_this(reason_code_) - ) - ) { - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_connack( + session_present_, + variant_get(reason_code_) + ); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; case protocol_version::v5: - if (ep_.on_v5_connack( - session_present_, - variant_get(reason_code_), - force_move(props_) - ) - ) { - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_v5_connack( + session_present_, + variant_get(reason_code_), + force_move(props_) + ); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; default: BOOST_ASSERT(false); @@ -7775,12 +7744,13 @@ class endpoint : public std::enable_shared_from_this(var)) ); + return true; case protocol_version::v5: switch (qos_value_) { case qos::at_most_once: @@ -7809,7 +7779,7 @@ class endpoint : public std::enable_shared_from_this( any_cast< - std::tuple + std::tuple >(session_life_keeper) ) ) @@ -7838,7 +7808,7 @@ class endpoint : public std::enable_shared_from_this( any_cast< - std::tuple + std::tuple >(session_life_keeper) ) ) @@ -7884,16 +7854,14 @@ class endpoint : public std::enable_shared_from_this(var)), - force_move(props_) - ); - return ret; - } + ep_.on_v5_publish( + packet_id_, + publish_options(ep_.fixed_header_), + force_move(topic_name_), + force_move(variant_get(var)), + force_move(props_) + ); + return true; default: BOOST_ASSERT(false); } @@ -7906,7 +7874,7 @@ class endpoint : public std::enable_shared_from_this( any_cast< - std::tuple + std::tuple >(session_life_keeper) ) ) @@ -7919,7 +7887,7 @@ class endpoint : public std::enable_shared_from_this( any_cast< - std::tuple + std::tuple >(session_life_keeper) ) ) @@ -7954,7 +7922,7 @@ class endpoint : public std::enable_shared_from_this( any_cast< - std::tuple + std::tuple >(session_life_keeper) ) ) @@ -7989,7 +7957,7 @@ class endpoint : public std::enable_shared_from_this( any_cast< - std::tuple + std::tuple >(session_life_keeper) ) ) @@ -8130,31 +8098,29 @@ class endpoint : public std::enable_shared_from_this( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_puback(packet_id_); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; case protocol_version::v5: if (erased) ep_.send_publish_queue_one(); - if (ep_.on_v5_puback(packet_id_, reason_code_, force_move(props_))) { - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_v5_puback(packet_id_, reason_code_, force_move(props_)); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; default: BOOST_ASSERT(false); @@ -8325,36 +8291,34 @@ class endpoint : public std::enable_shared_from_this( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_pubrec(packet_id_); + res(); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; case protocol_version::v5: if (erased && is_error(reason_code_)) { ep_.on_serialize_remove(packet_id_); ep_.send_publish_queue_one(); } - if (ep_.on_v5_pubrec(packet_id_, reason_code_, force_move(props_))) { - if (!is_error(reason_code_)) res(); - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_v5_pubrec(packet_id_, reason_code_, force_move(props_)); + if (!is_error(reason_code_)) res(); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; default: BOOST_ASSERT(false); @@ -8488,32 +8452,30 @@ class endpoint : public std::enable_shared_from_this( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_pubrel(packet_id_); + res(); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; case protocol_version::v5: - if (ep_.on_v5_pubrel(packet_id_, reason_code_, force_move(props_))) { - res(); - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_v5_pubrel(packet_id_, reason_code_, force_move(props_)); + res(); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; default: BOOST_ASSERT(false); @@ -8634,17 +8596,16 @@ class endpoint : public std::enable_shared_from_this( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_pubcomp(packet_id_); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; case protocol_version::v5: if ( @@ -8656,17 +8617,16 @@ class endpoint : public std::enable_shared_from_this( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_v5_pubcomp(packet_id_, reason_code_, force_move(props_)); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; default: BOOST_ASSERT(false); @@ -8802,30 +8762,28 @@ class endpoint : public std::enable_shared_from_this( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_subscribe(packet_id_, force_move(entries_)); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; case protocol_version::v5: - if (ep_.on_v5_subscribe(packet_id_, force_move(entries_), force_move(props_))) { - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_v5_subscribe(packet_id_, force_move(entries_), force_move(props_)); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; default: BOOST_ASSERT(false); @@ -8953,17 +8911,16 @@ class endpoint : public std::enable_shared_from_this(e); } ); - if (ep_.on_suback(packet_id_, force_move(results))) { - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_suback(packet_id_, force_move(results)); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; } case protocol_version::v5: @@ -8989,17 +8946,16 @@ class endpoint : public std::enable_shared_from_this(e); } ); - if (ep_.on_v5_suback(packet_id_, force_move(reasons), force_move(props_))) { - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_v5_suback(packet_id_, force_move(reasons), force_move(props_)); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; } default: @@ -9113,30 +9069,28 @@ class endpoint : public std::enable_shared_from_this( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_unsubscribe(packet_id_, force_move(entries_)); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; case protocol_version::v5: - if (ep_.on_v5_unsubscribe(packet_id_, force_move(entries_), force_move(props_))) { - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_v5_unsubscribe(packet_id_, force_move(entries_), force_move(props_)); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; default: BOOST_ASSERT(false); @@ -9252,30 +9206,28 @@ class endpoint : public std::enable_shared_from_this( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_unsuback(packet_id_); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; case protocol_version::v5: - if (ep_.on_v5_unsuback(packet_id_, force_move(reasons_), force_move(props_))) { - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) + ep_.on_v5_unsuback(packet_id_, force_move(reasons_), force_move(props_)); + ep_.on_mqtt_message_processed( + force_move( + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) ) - ); - } + ) + ); break; default: BOOST_ASSERT(false); @@ -9306,9 +9258,8 @@ class endpoint : public std::enable_shared_from_this(var)); BOOST_ASSERT(ep_.version_ == protocol_version::v5); - if (ep_.on_v5_auth(reason_code_, force_move(props_))) { - ep_.on_mqtt_message_processed( - force_move( - std::get<0>( - any_cast< - std::tuple - >(session_life_keeper) - ) - ) - ); - } - return; - } - BOOST_ASSERT(ep_.version_ == protocol_version::v5); - if (ep_.on_v5_auth(reason_code_, force_move(props_))) { + ep_.on_v5_auth(reason_code_, force_move(props_)); ep_.on_mqtt_message_processed( force_move( - session_life_keeper + std::get<0>( + any_cast< + std::tuple + >(session_life_keeper) + ) ) ); + return; } + BOOST_ASSERT(ep_.version_ == protocol_version::v5); + ep_.on_v5_auth(reason_code_, force_move(props_)); + ep_.on_mqtt_message_processed( + force_move( + session_life_keeper + ) + ); } } diff --git a/include/mqtt/move_only_handler.hpp b/include/mqtt/move_only_handler.hpp new file mode 100644 index 000000000..03e041bd4 --- /dev/null +++ b/include/mqtt/move_only_handler.hpp @@ -0,0 +1,66 @@ +// Copyright Takatoshi Kondo 2022 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(MQTT_MOVE_ONLY_HANDLER_HPP) +#define MQTT_MOVE_ONLY_HANDLER_HPP + +#include + +#include + +#include +#include +#include +#include + +namespace MQTT_NS { + +namespace as = boost::asio; + +template +struct move_only_handler { + using executor_type = as::any_io_executor; + + move_only_handler() = default; + + template < + typename Func, + typename std::enable_if_t< + std::is_convertible>::value + >* = nullptr + > + move_only_handler(Func&& f) + : exe_{as::get_associated_executor(f)}, + func_{std::forward(f)} + { + } + + executor_type get_executor() const { return exe_; } + + template + void operator()(Params&&... params) { + if (exe_ == as::system_executor()) { + func_(std::forward(params)...); + return; + } + as::dispatch( + exe_, + [func = force_move(func_), pt = std::tuple(std::forward(params)...)] () mutable { + MQTT_NS::apply(force_move(func), std::move(pt)); + } + ); + } + + operator bool() const { return static_cast(func_); } + +private: + executor_type exe_; + move_only_function func_; +}; + +} // namespace MQTT_NS + +#endif // MQTT_MOVE_ONLY_HANDLER_HPP diff --git a/include/mqtt/server.hpp b/include/mqtt/server.hpp index 1e8c85fdc..b44b10a28 100644 --- a/include/mqtt/server.hpp +++ b/include/mqtt/server.hpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace MQTT_NS { @@ -54,7 +54,7 @@ class server { * After this handler called, the next accept will automatically start. * @param ep endpoint of the connecting client */ - using accept_handler = move_only_function ep)>; + using accept_handler = move_only_handler ep)>; /** * @brief Error handler during after accepted before connection established @@ -62,7 +62,7 @@ class server { * @param ec error code * @param ioc_con io_context for incoming connection */ - using connection_error_handler = move_only_function; + using connection_error_handler = move_only_handler; /** * @brief Error handler for listen and accpet @@ -70,7 +70,7 @@ class server { * You need to call listen() again if you want to restart accepting. * @param ec error code */ - using error_handler = move_only_function; + using error_handler = move_only_handler; /** * @brief Error handler for listen and accpet @@ -79,7 +79,7 @@ class server { * @param ec error code * @param ioc_con io_context for listen or accept */ - using error_handler_with_ioc = move_only_function; + using error_handler_with_ioc = move_only_handler; template server( @@ -259,7 +259,7 @@ class server_tls { * After this handler called, the next accept will automatically start. * @param ep endpoint of the connecting client */ - using accept_handler = move_only_function ep)>; + using accept_handler = move_only_handler ep)>; /** * @brief Error handler during after accepted before connection established @@ -267,7 +267,7 @@ class server_tls { * @param ec error code * @param ioc_con io_context for incoming connection */ - using connection_error_handler = move_only_function; + using connection_error_handler = move_only_handler; /** * @brief Error handler for listen and accpet @@ -275,7 +275,7 @@ class server_tls { * You need to call listen() again if you want to restart accepting. * @param ec error code */ - using error_handler = move_only_function; + using error_handler = move_only_handler; /** * @brief Error handler for listen and accpet @@ -284,7 +284,7 @@ class server_tls { * @param ec error code * @param ioc_con io_context for listen or accept */ - using error_handler_with_ioc = move_only_function; + using error_handler_with_ioc = move_only_handler; template server_tls( @@ -583,7 +583,7 @@ class server_ws { * @brief Accept handler * @param ep endpoint of the connecting client */ - using accept_handler = move_only_function ep)>; + using accept_handler = move_only_handler ep)>; /** * @brief Error handler during after accepted before connection established @@ -591,7 +591,7 @@ class server_ws { * @param ec error code * @param ioc_con io_context for incoming connection */ - using connection_error_handler = move_only_function; + using connection_error_handler = move_only_handler; /** * @brief Error handler for listen and accpet @@ -599,7 +599,7 @@ class server_ws { * You need to call listen() again if you want to restart accepting. * @param ec error code */ - using error_handler = move_only_function; + using error_handler = move_only_handler; /** * @brief Error handler for listen and accpet @@ -608,7 +608,7 @@ class server_ws { * @param ec error code * @param ioc_con io_context for listen or accept */ - using error_handler_with_ioc = move_only_function; + using error_handler_with_ioc = move_only_handler; template server_ws( @@ -947,7 +947,7 @@ class server_tls_ws { * @brief Accept handler * @param ep endpoint of the connecting client */ - using accept_handler = move_only_function ep)>; + using accept_handler = move_only_handler ep)>; /** * @brief Error handler during after accepted before connection established @@ -955,7 +955,7 @@ class server_tls_ws { * @param ec error code * @param ioc_con io_context for incoming connection */ - using connection_error_handler = move_only_function; + using connection_error_handler = move_only_handler; /** * @brief Error handler for listen and accpet @@ -963,7 +963,7 @@ class server_tls_ws { * You need to call listen() again if you want to restart accepting. * @param ec error code */ - using error_handler = move_only_function; + using error_handler = move_only_handler; /** * @brief Error handler for listen and accpet @@ -972,7 +972,7 @@ class server_tls_ws { * @param ec error code * @param ioc_con io_context for listen or accept */ - using error_handler_with_ioc = move_only_function; + using error_handler_with_ioc = move_only_handler; template server_tls_ws( diff --git a/include/mqtt/store.hpp b/include/mqtt/store.hpp index 3fa0cdcc9..d947eb5db 100644 --- a/include/mqtt/store.hpp +++ b/include/mqtt/store.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include namespace MQTT_NS { diff --git a/include/mqtt/tcp_endpoint.hpp b/include/mqtt/tcp_endpoint.hpp index 295294d71..4331d322c 100644 --- a/include/mqtt/tcp_endpoint.hpp +++ b/include/mqtt/tcp_endpoint.hpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include namespace MQTT_NS { @@ -33,7 +33,7 @@ class tcp_endpoint : public socket { MQTT_ALWAYS_INLINE void async_read( as::mutable_buffer buffers, - move_only_function handler + move_only_handler handler ) override final { as::async_read( tcp_, @@ -47,7 +47,7 @@ class tcp_endpoint : public socket { MQTT_ALWAYS_INLINE void async_write( std::vector buffers, - move_only_function handler + move_only_handler handler ) override final { as::async_write( tcp_, @@ -66,21 +66,21 @@ class tcp_endpoint : public socket { return as::write(tcp_,force_move(buffers), ec); } - MQTT_ALWAYS_INLINE void post(move_only_function handler) override final { + MQTT_ALWAYS_INLINE void post(move_only_handler handler) override final { as::post( strand_, force_move(handler) ); } - MQTT_ALWAYS_INLINE void dispatch(move_only_function handler) override final { + MQTT_ALWAYS_INLINE void dispatch(move_only_handler handler) override final { as::dispatch( strand_, force_move(handler) ); } - MQTT_ALWAYS_INLINE void defer(move_only_function handler) override final { + MQTT_ALWAYS_INLINE void defer(move_only_handler handler) override final { as::defer( strand_, force_move(handler) @@ -103,7 +103,7 @@ class tcp_endpoint : public socket { shutdown_and_close_impl(tcp_, ec); } - MQTT_ALWAYS_INLINE void async_clean_shutdown_and_close(move_only_function handler) override final { + MQTT_ALWAYS_INLINE void async_clean_shutdown_and_close(move_only_handler handler) override final { async_shutdown_and_close_impl(tcp_, force_move(handler)); } @@ -157,7 +157,7 @@ class tcp_endpoint : public socket { << ec.message(); } - void async_shutdown_and_close_impl(as::basic_socket& s, move_only_function handler) { + void async_shutdown_and_close_impl(as::basic_socket& s, move_only_handler handler) { post( [this, &s, handler = force_move(handler)] () mutable { error_code ec; @@ -176,7 +176,7 @@ class tcp_endpoint : public socket { << ec.message(); shutdown_and_close_impl(lowest_layer(), ec); } - void async_shutdown_and_close_impl(tls::stream& s, move_only_function handler) { + void async_shutdown_and_close_impl(tls::stream& s, move_only_handler handler) { s.async_shutdown( as::bind_executor( strand_, diff --git a/include/mqtt/type_erased_socket.hpp b/include/mqtt/type_erased_socket.hpp index 4041311dc..c77fdf34d 100644 --- a/include/mqtt/type_erased_socket.hpp +++ b/include/mqtt/type_erased_socket.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace MQTT_NS { @@ -23,17 +23,17 @@ namespace as = boost::asio; class socket { public: virtual ~socket() = default; - virtual void async_read(as::mutable_buffer, move_only_function) = 0; - virtual void async_write(std::vector, move_only_function) = 0; + virtual void async_read(as::mutable_buffer, move_only_handler) = 0; + virtual void async_write(std::vector, move_only_handler) = 0; virtual std::size_t write(std::vector, boost::system::error_code&) = 0; - virtual void post(move_only_function) = 0; - virtual void dispatch(move_only_function) = 0; - virtual void defer(move_only_function) = 0; + virtual void post(move_only_handler) = 0; + virtual void dispatch(move_only_handler) = 0; + virtual void defer(move_only_handler) = 0; virtual bool running_in_this_thread() const = 0; virtual as::ip::tcp::socket::lowest_layer_type& lowest_layer() = 0; virtual any native_handle() = 0; virtual void clean_shutdown_and_close(boost::system::error_code&) = 0; - virtual void async_clean_shutdown_and_close(move_only_function) = 0; + virtual void async_clean_shutdown_and_close(move_only_handler) = 0; virtual void force_shutdown_and_close(boost::system::error_code&) = 0; virtual as::any_io_executor get_executor() = 0; }; diff --git a/include/mqtt/ws_endpoint.hpp b/include/mqtt/ws_endpoint.hpp index 9d784ea86..595937676 100644 --- a/include/mqtt/ws_endpoint.hpp +++ b/include/mqtt/ws_endpoint.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include namespace MQTT_NS { @@ -45,12 +45,12 @@ class ws_endpoint : public socket { MQTT_ALWAYS_INLINE void async_read( as::mutable_buffer buffers, - move_only_function handler + move_only_handler handler ) override final { auto req_size = as::buffer_size(buffers); using beast_read_handler_t = - move_only_function)>; + move_only_handler)>; std::shared_ptr beast_read_handler; if (req_size <= buffer_.size()) { @@ -65,13 +65,13 @@ class ws_endpoint : public socket { [this, req_size, buffers, handler = force_move(handler)] (error_code ec, std::shared_ptr const& v) mutable { if (ec) { - force_move(handler)(ec, 0); + force_move(handler)(ec, std::size_t(0)); return; } if (!ws_.got_binary()) { buffer_.consume(buffer_.size()); force_move(handler) - (boost::system::errc::make_error_code(boost::system::errc::bad_message), 0); + (boost::system::errc::make_error_code(boost::system::errc::bad_message), std::size_t(0)); return; } if (req_size > buffer_.size()) { @@ -108,7 +108,7 @@ class ws_endpoint : public socket { MQTT_ALWAYS_INLINE void async_write( std::vector buffers, - move_only_function handler + move_only_handler handler ) override final { ws_.async_write( buffers, @@ -127,21 +127,21 @@ class ws_endpoint : public socket { return as::buffer_size(buffers); } - MQTT_ALWAYS_INLINE void post(move_only_function handler) override final { + MQTT_ALWAYS_INLINE void post(move_only_handler handler) override final { as::post( strand_, force_move(handler) ); } - MQTT_ALWAYS_INLINE void dispatch(move_only_function handler) override final { + MQTT_ALWAYS_INLINE void dispatch(move_only_handler handler) override final { as::dispatch( strand_, force_move(handler) ); } - MQTT_ALWAYS_INLINE void defer(move_only_function handler) override final { + MQTT_ALWAYS_INLINE void defer(move_only_handler handler) override final { as::defer( strand_, force_move(handler) @@ -188,7 +188,7 @@ class ws_endpoint : public socket { shutdown_and_close_impl(next_layer(), ec); } - MQTT_ALWAYS_INLINE void async_clean_shutdown_and_close(move_only_function handler) override final { + MQTT_ALWAYS_INLINE void async_clean_shutdown_and_close(move_only_handler handler) override final { if (ws_.is_open()) { // WebSocket closing process MQTT_LOG("mqtt_impl", trace) @@ -273,7 +273,7 @@ class ws_endpoint : public socket { } private: - void async_read_until_closed(move_only_function handler) { + void async_read_until_closed(move_only_handler handler) { auto buffer = std::make_shared(); ws_.async_read( *buffer, @@ -312,7 +312,7 @@ class ws_endpoint : public socket { << ec.message(); } - void async_shutdown_and_close_impl(as::basic_socket& s, move_only_function handler) { + void async_shutdown_and_close_impl(as::basic_socket& s, move_only_handler handler) { post( [this, &s, handler = force_move(handler)] () mutable { error_code ec; @@ -331,7 +331,7 @@ class ws_endpoint : public socket { << ec.message(); shutdown_and_close_impl(lowest_layer(), ec); } - void async_shutdown_and_close_impl(tls::stream& s, move_only_function handler) { + void async_shutdown_and_close_impl(tls::stream& s, move_only_handler handler) { s.async_shutdown( as::bind_executor( strand_, diff --git a/test/system/st_as_buffer_async_pubsub_1.cpp b/test/system/st_as_buffer_async_pubsub_1.cpp index 0a34a7ffc..f252c2ad3 100644 --- a/test/system/st_as_buffer_async_pubsub_1.cpp +++ b/test/system/st_as_buffer_async_pubsub_1.cpp @@ -56,25 +56,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { MQTT_NS::qos::at_most_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -89,7 +85,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { MQTT_NS::qos::at_most_once | MQTT_NS::retain::no, MQTT_NS::any{} ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -97,7 +92,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -119,7 +113,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -137,25 +130,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { MQTT_NS::qos::at_most_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -170,7 +159,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { MQTT_NS::qos::at_most_once | MQTT_NS::retain::no, MQTT_NS::any{} ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -180,7 +168,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -203,7 +190,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); break; default: @@ -275,7 +261,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { MQTT_NS::qos::at_most_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_puback_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -289,19 +274,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_pub, &pid_sub] @@ -320,7 +302,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { MQTT_NS::qos::at_least_once, std::make_pair(topic1, contents) ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -328,7 +309,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -343,7 +323,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -361,7 +340,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { MQTT_NS::qos::at_most_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -375,19 +353,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_pub, &pid_sub] @@ -406,7 +381,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { MQTT_NS::qos::at_least_once, std::make_pair(topic1, contents) ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -416,7 +390,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -432,7 +405,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -505,20 +477,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { MQTT_NS::qos::at_most_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_unsub, &pid_pub] @@ -532,7 +501,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_suback_handler( [&chk, &c, &pid_pub] @@ -551,7 +519,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { MQTT_NS::qos::exactly_once, std::make_pair(topic1, contents) ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -559,7 +526,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -574,7 +540,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_CHECK(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -592,20 +557,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { MQTT_NS::qos::at_most_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_unsub, &pid_pub] @@ -619,7 +581,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_pub] @@ -638,7 +599,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { MQTT_NS::qos::exactly_once, std::make_pair(topic1, contents) ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -648,7 +608,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -664,7 +623,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_CHECK(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -733,25 +691,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { MQTT_NS::qos::at_least_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -766,7 +720,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { MQTT_NS::qos::at_most_once | MQTT_NS::retain::no, MQTT_NS::any{} ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -774,7 +727,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -796,7 +748,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -814,25 +765,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { MQTT_NS::qos::at_least_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -847,7 +794,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { MQTT_NS::qos::at_most_once | MQTT_NS::retain::no, MQTT_NS::any{} ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -857,7 +803,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -880,7 +825,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); break; default: @@ -967,26 +911,22 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { MQTT_NS::qos::at_least_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_puback_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1005,7 +945,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { MQTT_NS::qos::at_least_once, std::make_pair(topic1, contents) ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1013,7 +952,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -1029,7 +967,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1047,26 +984,22 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { MQTT_NS::qos::at_least_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_puback_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1085,7 +1018,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { MQTT_NS::qos::at_least_once, std::make_pair(topic1, contents) ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1095,7 +1027,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -1112,7 +1043,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1188,20 +1118,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { MQTT_NS::qos::at_least_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -1215,7 +1142,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1234,7 +1160,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { MQTT_NS::qos::exactly_once, std::make_pair(topic1, contents) ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1242,7 +1167,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -1258,7 +1182,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1276,20 +1199,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { MQTT_NS::qos::at_least_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -1303,7 +1223,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1322,7 +1241,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { MQTT_NS::qos::exactly_once, std::make_pair(topic1, contents) ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1332,7 +1250,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -1348,7 +1265,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: diff --git a/test/system/st_as_buffer_async_pubsub_2.cpp b/test/system/st_as_buffer_async_pubsub_2.cpp index f0134d84a..a574f4e73 100644 --- a/test/system/st_as_buffer_async_pubsub_2.cpp +++ b/test/system/st_as_buffer_async_pubsub_2.cpp @@ -57,25 +57,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { MQTT_NS::qos::exactly_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -92,7 +88,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { MQTT_NS::qos::at_most_once | MQTT_NS::retain::no, std::make_pair(topic1, contents) ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -100,7 +95,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -122,7 +116,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -140,25 +133,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { MQTT_NS::qos::exactly_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -175,7 +164,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { MQTT_NS::qos::at_most_once | MQTT_NS::retain::no, std::make_pair(topic1, contents) ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -185,7 +173,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -208,7 +195,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); break; default: @@ -289,7 +275,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { MQTT_NS::qos::exactly_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_puback_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -303,19 +288,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -334,7 +316,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { MQTT_NS::qos::at_least_once, std::make_pair(topic1, contents) ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -342,7 +323,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -358,7 +338,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -376,7 +355,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { MQTT_NS::qos::exactly_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -390,19 +368,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -421,7 +396,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { MQTT_NS::qos::at_least_once, std::make_pair(topic1, contents) ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -431,7 +405,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -448,7 +421,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -526,20 +498,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { MQTT_NS::qos::exactly_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -553,7 +522,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -572,7 +540,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { MQTT_NS::qos::exactly_once, std::make_pair(topic1, contents) ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -580,7 +547,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -596,7 +562,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -614,20 +579,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { MQTT_NS::qos::exactly_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -641,7 +603,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -660,7 +621,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { MQTT_NS::qos::exactly_once, std::make_pair(topic1, contents) ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -670,7 +630,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -687,7 +646,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -751,25 +709,21 @@ BOOST_AUTO_TEST_CASE( publish_function ) { MQTT_NS::qos::at_most_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -786,7 +740,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { MQTT_NS::qos::at_most_once, std::make_pair(topic1, contents) ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -794,7 +747,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -816,7 +768,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -834,25 +785,21 @@ BOOST_AUTO_TEST_CASE( publish_function ) { MQTT_NS::qos::at_most_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -869,7 +816,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { MQTT_NS::qos::at_most_once, std::make_pair(topic1, contents) ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -879,7 +825,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -902,7 +847,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); break; default: @@ -965,25 +909,21 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { std::move(topic1), MQTT_NS::qos::at_most_once ); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -999,7 +939,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { std::move(contents), MQTT_NS::qos::at_most_once ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1007,7 +946,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -1028,7 +966,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { pid_unsub, std::move(topic1) ); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1045,25 +982,21 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { std::move(topic1), MQTT_NS::qos::at_most_once ); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -1079,7 +1012,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { std::move(contents), MQTT_NS::qos::at_most_once ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1089,7 +1021,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -1111,7 +1042,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { pid_unsub, std::move(topic1) ); - return true; }); break; default: @@ -1176,7 +1106,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { MQTT_NS::qos::at_least_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_puback_handler( [&chk, &c, &pid_unsub] @@ -1190,19 +1119,16 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -1221,7 +1147,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes, std::make_pair(topic1, contents) ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1229,7 +1154,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -1244,7 +1168,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1262,7 +1185,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { MQTT_NS::qos::at_least_once, [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_unsub] @@ -1276,19 +1198,16 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { as::buffer(*topic1), [topic1](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -1307,7 +1226,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes, std::make_pair(topic1, contents) ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1317,7 +1235,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -1333,7 +1250,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: diff --git a/test/system/st_as_buffer_pubsub.cpp b/test/system/st_as_buffer_pubsub.cpp index 4bfc773e7..571aafe28 100644 --- a/test/system/st_as_buffer_pubsub.cpp +++ b/test/system/st_as_buffer_pubsub.cpp @@ -47,25 +47,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -75,7 +71,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -83,7 +78,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -99,7 +93,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -110,25 +103,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -138,7 +127,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -148,7 +136,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -165,7 +152,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; default: @@ -233,7 +219,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe(std::vector> { { "topic1", MQTT_NS::qos::at_most_once } }); - return true; }); c->set_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -242,19 +227,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe(std::vector{ "topic1" }); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_pub, &pid_sub] @@ -264,7 +246,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -272,7 +253,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -287,7 +267,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -299,7 +278,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe(std::vector> { { "topic1", MQTT_NS::qos::at_most_once } }); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -308,19 +286,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe(std::vector{ "topic1" }); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_pub, &pid_sub] @@ -330,7 +305,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -340,7 +314,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -356,7 +329,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -425,20 +397,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_unsub, &pid_pub] @@ -447,7 +416,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_suback_handler( [&chk, &c, &pid_pub] @@ -457,7 +425,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -465,7 +432,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -480,7 +446,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_CHECK(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -491,20 +456,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_unsub, &pid_pub] @@ -513,7 +475,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_pub] @@ -523,7 +484,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -533,7 +493,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -549,7 +508,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_CHECK(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -611,25 +569,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -639,7 +593,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -647,7 +600,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -663,7 +615,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -674,25 +625,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -702,7 +649,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -712,7 +658,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -729,7 +674,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; default: @@ -806,7 +750,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -815,19 +758,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -837,7 +777,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -845,7 +784,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -861,7 +799,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -872,7 +809,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -881,19 +817,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -903,7 +836,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -913,7 +845,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -930,7 +861,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1003,20 +933,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1025,7 +952,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1035,7 +961,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1043,7 +968,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -1059,7 +983,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1070,20 +993,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1092,7 +1012,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1102,7 +1021,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1112,7 +1030,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -1129,7 +1046,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1188,25 +1104,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -1216,7 +1128,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1224,7 +1135,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -1240,7 +1150,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1251,25 +1160,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -1279,7 +1184,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1289,7 +1193,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -1306,7 +1209,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; default: @@ -1383,7 +1285,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1392,19 +1293,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1414,7 +1312,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1422,7 +1319,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -1438,7 +1334,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1449,7 +1344,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1458,19 +1352,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1480,7 +1371,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1490,7 +1380,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -1507,7 +1396,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1580,20 +1468,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1602,7 +1487,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1612,7 +1496,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1620,7 +1503,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -1636,7 +1518,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1647,20 +1528,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1669,7 +1547,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1679,7 +1556,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1689,7 +1565,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -1706,7 +1581,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1765,25 +1639,21 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -1793,7 +1663,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1801,7 +1670,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -1817,7 +1685,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1828,25 +1695,21 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -1856,7 +1719,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1866,7 +1728,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -1883,7 +1744,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; default: @@ -1943,7 +1803,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [&chk, &c, &pid_unsub] @@ -1951,19 +1810,16 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == 1); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -1974,7 +1830,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); BOOST_TEST(c->register_packet_id(1) == true); c->publish(1, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1982,7 +1837,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -1997,7 +1851,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -2008,7 +1861,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_unsub] @@ -2016,19 +1868,16 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == 1); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -2039,7 +1888,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); BOOST_TEST(c->register_packet_id(1) == true); c->publish(1, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -2049,7 +1897,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -2065,7 +1912,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: diff --git a/test/system/st_as_buffer_sub.cpp b/test/system/st_as_buffer_sub.cpp index 5b42b2973..020a41db0 100644 --- a/test/system/st_as_buffer_sub.cpp +++ b/test/system/st_as_buffer_sub.cpp @@ -45,21 +45,18 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_single ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_suback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*results*/) { MQTT_CHK("h_suback"); c->unsubscribe("topic1"); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -70,21 +67,18 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_single ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_suback_handler( [&chk, &c] (packet_id_t, std::vector, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_suback"); c->unsubscribe("topic1"); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t, std::vector, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; default: @@ -145,21 +139,18 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_arg ) { {"topic2", MQTT_NS::qos::exactly_once} } ); - return true; }); c->set_suback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*results*/) { MQTT_CHK("h_suback"); c->unsubscribe( std::vector{"topic1", "topic2"} ); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -176,21 +167,18 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_arg ) { {"topic2", MQTT_NS::qos::exactly_once} } ); - return true; }); c->set_v5_suback_handler( [&chk, &c] (packet_id_t, std::vector, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_suback"); c->unsubscribe( std::vector{"topic1", "topic2"}); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t, std::vector, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; default: @@ -250,21 +238,18 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_vec ) { { "topic2", MQTT_NS::qos::exactly_once } }; c->subscribe(std::move(v)); - return true; }); c->set_suback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*results*/) { MQTT_CHK("h_suback"); c->unsubscribe(std::vector{"topic1", "topic2"}); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -280,21 +265,18 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_vec ) { { "topic2", MQTT_NS::qos::exactly_once } }; c->subscribe(std::move(v)); - return true; }); c->set_v5_suback_handler( [&chk, &c] (packet_id_t, std::vector, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_suback"); c->unsubscribe(std::vector{"topic1", "topic2"}); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t, std::vector, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; default: @@ -352,7 +334,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_single_async ) { as::buffer(*topic), MQTT_NS::qos::at_most_once, [topic](MQTT_NS::error_code) {}); - return true; }); c->set_suback_handler( [&chk, &c] @@ -362,14 +343,12 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_single_async ) { c->async_unsubscribe( as::buffer(*topic), [topic](MQTT_NS::error_code) {}); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -384,7 +363,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_single_async ) { as::buffer(*topic), MQTT_NS::qos::at_most_once, [topic](MQTT_NS::error_code) {}); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -394,14 +372,12 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_single_async ) { c->async_unsubscribe( as::buffer(*topic), [topic](MQTT_NS::error_code) {}); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t, std::vector, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; default: @@ -465,7 +441,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_arg_async ) { }, [topic1, topic2](MQTT_NS::error_code) {} ); - return true; }); c->set_suback_handler( [&chk, &c] @@ -477,14 +452,12 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_arg_async ) { std::vector{ as::buffer(*topic1), as::buffer(*topic2) }, [topic1, topic2](MQTT_NS::error_code) {} ); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -504,7 +477,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_arg_async ) { }, [topic1, topic2](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -516,14 +488,12 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_arg_async ) { std::vector{ as::buffer(*topic1), as::buffer(*topic2) }, [topic1, topic2](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t, std::vector, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; default: @@ -588,7 +558,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_vec_async ) { std::move(v), [topic1, topic2](MQTT_NS::error_code) {} ); - return true; }); c->set_suback_handler( [&chk, &c] @@ -605,14 +574,12 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_vec_async ) { std::move(v), [topic1, topic2](MQTT_NS::error_code) {} ); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -633,7 +600,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_vec_async ) { std::move(v), [topic1, topic2](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -650,14 +616,12 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_string_multi_vec_async ) { std::move(v), [topic1, topic2](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t, std::vector, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; default: diff --git a/test/system/st_async_pubsub_1.cpp b/test/system/st_async_pubsub_1.cpp index 805aead97..94393fff7 100644 --- a/test/system/st_async_pubsub_1.cpp +++ b/test/system/st_async_pubsub_1.cpp @@ -51,7 +51,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -61,7 +60,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->async_publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -69,7 +67,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -86,25 +83,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -116,7 +109,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -126,7 +118,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c->async_publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -136,7 +127,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -154,25 +144,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); break; default: @@ -244,7 +230,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { std::make_tuple("topic1", MQTT_NS::qos::at_most_once) } ); - return true; }); c->set_puback_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -253,19 +238,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(packet_id == pid_pub); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, std::vector{"topic1"}); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_pub, &pid_sub] @@ -276,7 +258,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -284,7 +265,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -299,7 +279,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -316,7 +295,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { std::make_tuple("topic1", MQTT_NS::qos::at_most_once) } ); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -325,19 +303,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(packet_id == pid_pub); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, std::vector{"topic1"}); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_pub, &pid_sub] @@ -348,7 +323,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -358,7 +332,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -374,7 +347,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -442,20 +414,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_unsub, &pid_pub] @@ -464,7 +433,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(packet_id == pid_pub); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_suback_handler( [&chk, &c, &pid_pub] @@ -475,7 +443,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -483,7 +450,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -498,7 +464,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_CHECK(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -510,20 +475,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_unsub, &pid_pub] @@ -532,7 +494,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(packet_id == pid_pub); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_pub] @@ -543,7 +504,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -553,7 +513,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -569,7 +528,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_CHECK(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -634,25 +592,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -662,7 +616,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); c->async_publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -670,7 +623,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -687,7 +639,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -699,25 +650,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -727,7 +674,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); c->async_publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -737,7 +683,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -755,7 +700,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); break; default: @@ -833,26 +777,22 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -863,7 +803,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -871,7 +810,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -887,7 +825,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -899,26 +836,22 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -929,7 +862,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -939,7 +871,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -956,7 +887,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1028,20 +958,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -1050,7 +977,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(packet_id == pid_pub); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1061,7 +987,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1069,7 +994,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -1085,7 +1009,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1097,20 +1020,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -1119,7 +1039,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(packet_id == pid_pub); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1130,7 +1049,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1140,7 +1058,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -1157,7 +1074,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: diff --git a/test/system/st_async_pubsub_2.cpp b/test/system/st_async_pubsub_2.cpp index e5dd1279b..e3043e4d7 100644 --- a/test/system/st_async_pubsub_2.cpp +++ b/test/system/st_async_pubsub_2.cpp @@ -53,25 +53,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -81,7 +77,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); c->async_publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -89,7 +84,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -106,7 +100,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -118,25 +111,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -146,7 +135,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); c->async_publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -156,7 +144,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -174,7 +161,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); break; default: @@ -250,7 +236,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_puback_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -259,19 +244,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -282,7 +264,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -290,7 +271,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -306,7 +286,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -318,7 +297,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -327,19 +305,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -350,7 +325,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -360,7 +334,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -377,7 +350,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -450,20 +422,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -472,7 +441,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -483,7 +451,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -491,7 +458,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -507,7 +473,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -519,20 +484,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -541,7 +503,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -552,7 +513,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -562,7 +522,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -579,7 +538,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -648,27 +606,23 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); auto pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &c] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); c->async_pubrel(packet_id); - return true; }); c->set_pubcomp_handler( [&chk, g] (packet_id_t) mutable { MQTT_CHK("h_pubcomp"); g.reset(); - return true; }); c->set_suback_handler( [&chk, &c] @@ -678,14 +632,12 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); auto pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &c] @@ -703,7 +655,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { // send pubrec twice c->async_pubrec(*packet_id); c->async_pubrec(*packet_id); - return true; }); c->set_pubrel_handler( [&chk, &c, g] @@ -720,7 +671,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { } ); BOOST_TEST(ret); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -732,27 +682,23 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); auto pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &c] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); c->async_pubrel(packet_id); - return true; }); c->set_v5_pubcomp_handler( [&chk, g] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) mutable { MQTT_CHK("h_pubcomp"); g.reset(); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -762,7 +708,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); auto pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] @@ -771,7 +716,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c] @@ -790,7 +734,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { // send pubrec twice c->async_pubrec(*packet_id); c->async_pubrec(*packet_id); - return true; }); c->set_v5_pubrel_handler( [&chk, &c, g] @@ -807,7 +750,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { } ); BOOST_TEST(ret); - return true; }); break; default: @@ -868,25 +810,21 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -896,7 +834,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->async_publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -904,7 +841,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -921,7 +857,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -933,25 +868,21 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -961,7 +892,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c->async_publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -971,7 +901,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -989,7 +918,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); break; default: @@ -1050,7 +978,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [&chk, &c, &pid_unsub] @@ -1059,19 +986,16 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(packet_id == 1); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -1082,7 +1006,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); c->register_packet_id(1); c->async_publish(1, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1090,7 +1013,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -1105,7 +1027,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1117,7 +1038,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_unsub] @@ -1126,19 +1046,16 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(packet_id == 1); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -1149,7 +1066,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); c->register_packet_id(1); c->async_publish(1, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1159,7 +1075,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -1175,7 +1090,6 @@ BOOST_AUTO_TEST_CASE( publish_dup_function ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1236,7 +1150,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1"_mb, MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [&chk, &c, &pid_unsub] @@ -1245,19 +1158,16 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { BOOST_TEST(packet_id == 1); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -1268,7 +1178,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); c->register_packet_id(1); c->async_publish(1, "topic1"_mb, "topic1_contents"_mb, MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1276,7 +1185,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -1291,7 +1199,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1303,7 +1210,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1"_mb, MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_unsub] @@ -1312,19 +1218,16 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { BOOST_TEST(packet_id == 1); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -1335,7 +1238,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); c->register_packet_id(1); c->async_publish(1, "topic1"_mb, "topic1_contents"_mb, MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1345,7 +1247,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -1361,7 +1262,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1422,7 +1322,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1"_mb, MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [&chk, &c, &pid_unsub] @@ -1431,19 +1330,16 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { BOOST_TEST(packet_id == 1); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -1460,7 +1356,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { "contents"_mb, }; c->async_publish(1, "topic1"_mb, MQTT_NS::force_move(bs), MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1468,7 +1363,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -1483,7 +1377,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1495,7 +1388,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1"_mb, MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_unsub] @@ -1504,19 +1396,16 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { BOOST_TEST(packet_id == 1); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -1533,7 +1422,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { "contents"_mb, }; c->async_publish(1, "topic1"_mb, MQTT_NS::force_move(bs), MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1543,7 +1431,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -1559,7 +1446,6 @@ BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1620,7 +1506,6 @@ BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1"_mb, MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [&chk, &c, &pid_unsub] @@ -1629,19 +1514,16 @@ BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { BOOST_TEST(packet_id == 1); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -1669,7 +1551,6 @@ BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes, std::make_tuple(topic_name, s1, s2, s3, s4) ); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1677,7 +1558,6 @@ BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->async_disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -1692,7 +1572,6 @@ BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1704,7 +1583,6 @@ BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1"_mb, MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_unsub] @@ -1713,19 +1591,16 @@ BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { BOOST_TEST(packet_id == 1); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -1753,7 +1628,6 @@ BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes, std::make_tuple(topic_name, s1, s2, s3, s4) ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1763,7 +1637,6 @@ BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -1779,7 +1652,6 @@ BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { BOOST_CHECK(packet_id.value() == 1); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1855,7 +1727,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_prop ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, ps = std::move(ps)] @@ -1865,7 +1736,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_prop ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c->async_publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once | MQTT_NS::retain::no, std::move(ps)); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1875,7 +1745,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_prop ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub, &user_prop_count, prop_size] @@ -1939,25 +1808,21 @@ BOOST_AUTO_TEST_CASE( pub_sub_prop ) { pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_close_handler( [&chk, &finish] @@ -2074,26 +1939,22 @@ BOOST_AUTO_TEST_CASE( puback_props ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -2104,7 +1965,6 @@ BOOST_AUTO_TEST_CASE( puback_props ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -2114,7 +1974,6 @@ BOOST_AUTO_TEST_CASE( puback_props ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &recv_packet_id, pubackps = std::move(pubackps)] @@ -2133,7 +1992,6 @@ BOOST_AUTO_TEST_CASE( puback_props ) { BOOST_TEST(contents == "topic1_contents"); // pubackps doesn't contain *_ref property, so you don't need to care the lifetime of pubackprops c->async_puback(*packet_id, MQTT_NS::v5::puback_reason_code::success, std::move(pubackps)); - return true; }); c->set_close_handler( [&chk, &finish] @@ -2339,13 +2197,11 @@ BOOST_AUTO_TEST_CASE( pubrec_rel_comp_prop ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->acquire_unique_packet_id(); c->async_subscribe(pid_sub, "topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &c, &pid_pub, pubrelps = std::move(pubrelps)] @@ -2353,7 +2209,6 @@ BOOST_AUTO_TEST_CASE( pubrec_rel_comp_prop ) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); c->async_pubrel(packet_id, MQTT_NS::v5::pubrel_reason_code::success, std::move(pubrelps)); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -2362,7 +2217,6 @@ BOOST_AUTO_TEST_CASE( pubrec_rel_comp_prop ) { BOOST_TEST(packet_id == pid_pub); pid_unsub = c->acquire_unique_packet_id(); c->async_unsubscribe(pid_unsub, "topic1"); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -2373,7 +2227,6 @@ BOOST_AUTO_TEST_CASE( pubrec_rel_comp_prop ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); pid_pub = c->acquire_unique_packet_id(); c->async_publish(pid_pub, "topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -2383,7 +2236,6 @@ BOOST_AUTO_TEST_CASE( pubrec_rel_comp_prop ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->async_disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &recv_packet_id, pubrecps = std::move(pubrecps)] @@ -2401,13 +2253,11 @@ BOOST_AUTO_TEST_CASE( pubrec_rel_comp_prop ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); c->async_pubrec(*packet_id, MQTT_NS::v5::pubrec_reason_code::success, std::move(pubrecps)); - return true; }); c->set_v5_pubrel_handler( [&c, pubcompps = std::move(pubcompps)] (packet_id_t packet_id, MQTT_NS::v5::pubrel_reason_code, MQTT_NS::v5::properties /*props*/) { c->async_pubcomp(packet_id, MQTT_NS::v5::pubcomp_reason_code::success, std::move(pubcompps)); - return true; }); c->set_close_handler( [&chk, &finish] diff --git a/test/system/st_broker_offline_message.cpp b/test/system/st_broker_offline_message.cpp index 2ba674431..8bcb287c5 100644 --- a/test/system/st_broker_offline_message.cpp +++ b/test/system/st_broker_offline_message.cpp @@ -95,7 +95,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v3_1_1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c2->connect(); - return true; } ); c2->set_connack_handler( @@ -115,7 +114,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v3_1_1 ) { } ); BOOST_TEST(ret); - return true; } ); c2->set_suback_handler( @@ -125,7 +123,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v3_1_1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); c2->disconnect(); - return true; } ); c2->set_close_handler( @@ -151,14 +148,12 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v3_1_1 ) { [&chk] (std::uint16_t) { MQTT_CHK("c1_h_puback"); - return true; } ); c1->set_pubrec_handler( [&chk] (std::uint16_t) { MQTT_CHK("c1_h_pubrec"); - return true; } ); c1->set_pubcomp_handler( @@ -166,7 +161,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v3_1_1 ) { (std::uint16_t) { MQTT_CHK("c1_h_pubcomp"); c2->connect(); - return true; } ); c2->set_publish_handler( @@ -207,7 +201,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v3_1_1 ) { } ); BOOST_TEST(ret); - return true; } ); c1->set_close_handler( @@ -341,7 +334,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5 ) { ) } ); - return true; } ); c2->set_v5_connack_handler( @@ -361,7 +353,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5 ) { } ); BOOST_TEST(ret); - return true; } ); c2->set_v5_suback_handler( @@ -371,7 +362,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); c2->disconnect(); - return true; } ); c2->set_close_handler( @@ -397,14 +387,12 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5 ) { [&chk] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("c1_h_puback"); - return true; } ); c1->set_v5_pubrec_handler( [&chk] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("c1_h_pubrec"); - return true; } ); c1->set_v5_pubcomp_handler( @@ -421,7 +409,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5 ) { } ); - return true; } ); c2->set_v5_publish_handler( @@ -511,7 +498,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5 ) { } ); BOOST_TEST(ret); - return true; } ); c1->set_close_handler( @@ -645,7 +631,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5_timeout ) { ) } ); - return true; } ); c2->set_v5_connack_handler( @@ -676,7 +661,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5_timeout ) { } ); BOOST_TEST(ret); - return true; } ); c2->set_v5_suback_handler( @@ -686,7 +670,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5_timeout ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); c2->disconnect(); - return true; } ); c2->set_close_handler( @@ -712,14 +695,12 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5_timeout ) { [&chk] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("c1_h_puback"); - return true; } ); c1->set_v5_pubrec_handler( [&chk] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("c1_h_pubrec"); - return true; } ); c1->set_v5_pubcomp_handler( @@ -743,7 +724,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5_timeout ) { } ); - return true; } ); c2->set_v5_publish_handler( @@ -755,7 +735,6 @@ BOOST_AUTO_TEST_CASE( offline_pubsub_v5_timeout ) { MQTT_NS::v5::properties) { // We should not received any published message when offline messages timeout BOOST_TEST(false); - return true; } ); c1->set_close_handler( diff --git a/test/system/st_connect.cpp b/test/system/st_connect.cpp index 9082a613f..f79686ea1 100644 --- a/test/system/st_connect.cpp +++ b/test/system/st_connect.cpp @@ -41,7 +41,6 @@ BOOST_AUTO_TEST_CASE( connect ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->disconnect(); BOOST_TEST(c->connected() == true); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -55,7 +54,6 @@ BOOST_AUTO_TEST_CASE( connect ) { c->disconnect(); BOOST_TEST(c->connected() == true); - return true; }); break; default: @@ -107,7 +105,6 @@ BOOST_AUTO_TEST_CASE( connect_no_strand ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -118,7 +115,6 @@ BOOST_AUTO_TEST_CASE( connect_no_strand ) { BOOST_TEST(sp == false); BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); c->disconnect(); - return true; }); break; default: @@ -167,7 +163,6 @@ BOOST_AUTO_TEST_CASE( keep_alive ) { MQTT_CHK("h_connack"); BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -177,7 +172,6 @@ BOOST_AUTO_TEST_CASE( keep_alive ) { MQTT_CHK("h_connack"); BOOST_TEST(sp == false); BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); - return true; }); break; default: @@ -201,7 +195,6 @@ BOOST_AUTO_TEST_CASE( keep_alive ) { () { MQTT_CHK("h_pingresp"); c->disconnect(); - return true; }); c->set_keep_alive_sec(3); c->connect(); @@ -252,7 +245,6 @@ BOOST_AUTO_TEST_CASE( keep_alive_and_send_control_packet ) { ); } ); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -277,7 +269,6 @@ BOOST_AUTO_TEST_CASE( keep_alive_and_send_control_packet ) { ); } ); - return true; }); break; default: @@ -302,7 +293,6 @@ BOOST_AUTO_TEST_CASE( keep_alive_and_send_control_packet ) { MQTT_CHK("h_pingresp"); tim.cancel(); c->disconnect(); - return true; }); c->set_keep_alive_sec(3, std::chrono::seconds(3)); c->connect(); @@ -337,7 +327,6 @@ BOOST_AUTO_TEST_CASE( pingresp_timeout ) { MQTT_CHK("h_connack"); BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -347,7 +336,6 @@ BOOST_AUTO_TEST_CASE( pingresp_timeout ) { MQTT_CHK("h_connack"); BOOST_TEST(sp == false); BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); - return true; }); break; default: @@ -408,7 +396,6 @@ BOOST_AUTO_TEST_CASE( connect_again ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -424,7 +411,6 @@ BOOST_AUTO_TEST_CASE( connect_again ) { BOOST_TEST(sp == false); BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); c->disconnect(); - return true; }); break; default: @@ -479,7 +465,6 @@ BOOST_AUTO_TEST_CASE( nocid ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -500,7 +485,6 @@ BOOST_AUTO_TEST_CASE( nocid ) { ); BOOST_TEST(times == 1); c->disconnect(); - return true; }); break; default: @@ -546,7 +530,6 @@ BOOST_AUTO_TEST_CASE( nocid_noclean ) { MQTT_CHK("h_connack"); BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::identifier_rejected); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -571,7 +554,6 @@ BOOST_AUTO_TEST_CASE( nocid_noclean ) { ); BOOST_TEST(times == 1); c->force_disconnect(); - return true; }); break; default: @@ -648,7 +630,6 @@ BOOST_AUTO_TEST_CASE( noclean ) { } BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -679,7 +660,6 @@ BOOST_AUTO_TEST_CASE( noclean ) { } BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); c->disconnect(); - return true; }); break; default: @@ -766,7 +746,6 @@ BOOST_AUTO_TEST_CASE( disconnect_timeout ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); b.set_disconnect_delay(std::chrono::seconds(2)); c->disconnect(std::chrono::seconds(1)); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -778,7 +757,6 @@ BOOST_AUTO_TEST_CASE( disconnect_timeout ) { BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); b.set_disconnect_delay(std::chrono::seconds(2)); c->disconnect(std::chrono::seconds(1)); - return true; }); break; default: @@ -828,7 +806,6 @@ BOOST_AUTO_TEST_CASE( disconnect_not_timeout ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); b.set_disconnect_delay(std::chrono::seconds(1)); c->disconnect(std::chrono::seconds(2)); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -840,7 +817,6 @@ BOOST_AUTO_TEST_CASE( disconnect_not_timeout ) { BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); b.set_disconnect_delay(std::chrono::seconds(1)); c->disconnect(std::chrono::seconds(2)); - return true; }); break; default: @@ -890,7 +866,6 @@ BOOST_AUTO_TEST_CASE( async_disconnect_timeout ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); b.set_disconnect_delay(std::chrono::seconds(2)); c->async_disconnect(std::chrono::seconds(1)); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -902,7 +877,6 @@ BOOST_AUTO_TEST_CASE( async_disconnect_timeout ) { BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); b.set_disconnect_delay(std::chrono::seconds(2)); c->async_disconnect(std::chrono::seconds(1)); - return true; }); break; default: @@ -963,7 +937,6 @@ BOOST_AUTO_TEST_CASE( async_disconnect_not_timeout ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); b.set_disconnect_delay(std::chrono::seconds(1)); c->async_disconnect(std::chrono::seconds(2)); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -975,7 +948,6 @@ BOOST_AUTO_TEST_CASE( async_disconnect_not_timeout ) { BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); b.set_disconnect_delay(std::chrono::seconds(1)); c->async_disconnect(std::chrono::seconds(2)); - return true; }); break; default: @@ -1046,7 +1018,6 @@ BOOST_AUTO_TEST_CASE( async_keep_alive ) { MQTT_CHK("h_connack"); BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1056,7 +1027,6 @@ BOOST_AUTO_TEST_CASE( async_keep_alive ) { MQTT_CHK("h_connack"); BOOST_TEST(sp == false); BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); - return true; }); break; default: @@ -1080,7 +1050,6 @@ BOOST_AUTO_TEST_CASE( async_keep_alive ) { () { MQTT_CHK("h_pingresp"); c->async_disconnect(); - return true; }); c->set_keep_alive_sec(3); c->async_connect(); @@ -1131,7 +1100,6 @@ BOOST_AUTO_TEST_CASE( async_keep_alive_and_send_control_packet ) { ); } ); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1156,7 +1124,6 @@ BOOST_AUTO_TEST_CASE( async_keep_alive_and_send_control_packet ) { ); } ); - return true; }); break; default: @@ -1181,7 +1148,6 @@ BOOST_AUTO_TEST_CASE( async_keep_alive_and_send_control_packet ) { MQTT_CHK("h_pingresp"); tim.cancel(); c->async_disconnect(); - return true; }); c->set_keep_alive_sec(3, std::chrono::seconds(3)); c->async_connect(); @@ -1216,7 +1182,6 @@ BOOST_AUTO_TEST_CASE( async_pingresp_timeout ) { MQTT_CHK("h_connack"); BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1226,7 +1191,6 @@ BOOST_AUTO_TEST_CASE( async_pingresp_timeout ) { MQTT_CHK("h_connack"); BOOST_TEST(sp == false); BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); - return true; }); break; default: @@ -1291,7 +1255,6 @@ BOOST_AUTO_TEST_CASE( async_connect_session_present_empty_store ) { } ); BOOST_TEST(ret); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1313,7 +1276,6 @@ BOOST_AUTO_TEST_CASE( async_connect_session_present_empty_store ) { } ); BOOST_TEST(ret); - return true; }); break; default: @@ -1376,7 +1338,6 @@ BOOST_AUTO_TEST_CASE( async_connect_retry_before_cb ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->async_disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1387,7 +1348,6 @@ BOOST_AUTO_TEST_CASE( async_connect_retry_before_cb ) { BOOST_TEST(sp == false); BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); c->async_disconnect(); - return true; }); break; default: @@ -1473,7 +1433,6 @@ BOOST_AUTO_TEST_CASE( async_connect_retry_broker_no_connack ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->async_disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1485,7 +1444,6 @@ BOOST_AUTO_TEST_CASE( async_connect_retry_broker_no_connack ) { BOOST_TEST(sp == false); BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); c->async_disconnect(); - return true; }); break; default: @@ -1650,7 +1608,6 @@ BOOST_AUTO_TEST_CASE( connect_prop ) { c->disconnect(MQTT_NS::v5::disconnect_reason_code::normal_disconnection, {}); BOOST_TEST(c->connected() == true); - return true; }); c->set_close_handler( @@ -1753,7 +1710,6 @@ BOOST_AUTO_TEST_CASE( disconnect_prop ) { c->disconnect(MQTT_NS::v5::disconnect_reason_code::normal_disconnection, std::move(discon_ps)); BOOST_TEST(c->connected() == true); - return true; }); c->set_close_handler( @@ -1912,7 +1868,6 @@ BOOST_AUTO_TEST_CASE( connack_prop ) { c->disconnect(); BOOST_TEST(c->connected() == true); - return true; }); c->set_close_handler( [&chk, &finish, &c] @@ -1979,7 +1934,6 @@ BOOST_AUTO_TEST_CASE( session_taken_over ) { ) } ); - return true; } ); c1->set_v5_disconnect_handler( @@ -2002,7 +1956,6 @@ BOOST_AUTO_TEST_CASE( session_taken_over ) { BOOST_TEST(sp == true); BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); c3->connect(); - return true; } ); c2->set_v5_disconnect_handler( @@ -2025,7 +1978,6 @@ BOOST_AUTO_TEST_CASE( session_taken_over ) { BOOST_TEST(sp == false); BOOST_TEST(connect_reason_code == MQTT_NS::v5::connect_reason_code::success); c3->disconnect(); - return true; } ); c3->set_close_handler( diff --git a/test/system/st_issue_749.cpp b/test/system/st_issue_749.cpp index 9266d4f24..8c94fb11c 100644 --- a/test/system/st_issue_749.cpp +++ b/test/system/st_issue_749.cpp @@ -63,7 +63,6 @@ BOOST_AUTO_TEST_CASE( broker_assertion_fail ) { c1->publish("topic1", "topic1_contents1", MQTT_NS::qos::at_most_once); } c1->disconnect(); - return true; } ); diff --git a/test/system/st_length_check.cpp b/test/system/st_length_check.cpp index 994855e46..3fc319451 100644 --- a/test/system/st_length_check.cpp +++ b/test/system/st_length_check.cpp @@ -46,7 +46,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_close_handler( [] @@ -66,7 +65,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { (packet_id_t /*packet_id*/, std::vector /*results*/) { MQTT_CHK("h_suback"); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_publish_handler( [] @@ -75,7 +73,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { MQTT_NS::buffer /*topic*/, MQTT_NS::buffer /*contents*/) { BOOST_CHECK(false); - return false; }); c->set_is_valid_length_handler( [&chk] diff --git a/test/system/st_manual_publish.cpp b/test/system/st_manual_publish.cpp index acd59be2a..62b9c0f2b 100644 --- a/test/system/st_manual_publish.cpp +++ b/test/system/st_manual_publish.cpp @@ -48,7 +48,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(c->register_packet_id(1) == true); BOOST_TEST(c->register_packet_id(1) == false); c->subscribe(1, "topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [&chk, &c] @@ -59,19 +58,16 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(c->register_packet_id(1) == true); BOOST_TEST(c->register_packet_id(1) == false); c->unsubscribe(1, "topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c] @@ -84,7 +80,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(c->register_packet_id(1) == true); BOOST_TEST(c->register_packet_id(1) == false); c->publish(1, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c] @@ -92,7 +87,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == 1); c->disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -107,7 +101,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); MQTT_CHK("h_publish"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -121,7 +114,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(c->register_packet_id(1) == true); BOOST_TEST(c->register_packet_id(1) == false); c->subscribe(1, "topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [&chk, &c] @@ -132,19 +124,16 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(c->register_packet_id(1) == true); BOOST_TEST(c->register_packet_id(1) == false); c->unsubscribe(1, "topic1"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -157,7 +146,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(c->register_packet_id(1) == true); BOOST_TEST(c->register_packet_id(1) == false); c->publish(1, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] @@ -167,7 +155,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -183,7 +170,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); MQTT_CHK("h_publish"); - return true; }); break; default: diff --git a/test/system/st_maximum_packet_size.cpp b/test/system/st_maximum_packet_size.cpp index 47f3e61a7..a3277cd31 100644 --- a/test/system/st_maximum_packet_size.cpp +++ b/test/system/st_maximum_packet_size.cpp @@ -66,7 +66,6 @@ BOOST_AUTO_TEST_CASE( sync ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_suback_handler( [&chk, &c, header_size] @@ -108,7 +107,6 @@ BOOST_AUTO_TEST_CASE( sync ) { catch (MQTT_NS::packet_size_error const&) { MQTT_CHK("publish101_exception"); } - return true; }); c->set_v5_publish_handler( [&chk, &c, header_size] @@ -130,7 +128,6 @@ BOOST_AUTO_TEST_CASE( sync ) { } ); BOOST_TEST(ret); - return true; }); c->set_close_handler( diff --git a/test/system/st_multi_sub.cpp b/test/system/st_multi_sub.cpp index 1783c6ee2..b9d6067af 100644 --- a/test/system/st_multi_sub.cpp +++ b/test/system/st_multi_sub.cpp @@ -61,7 +61,6 @@ BOOST_AUTO_TEST_CASE( multi_channel ) { } ); - return true; }); c->set_close_handler( [&chk, &finish] @@ -78,19 +77,16 @@ BOOST_AUTO_TEST_CASE( multi_channel ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -101,7 +97,6 @@ BOOST_AUTO_TEST_CASE( multi_channel ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); BOOST_TEST(results[1] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -109,7 +104,6 @@ BOOST_AUTO_TEST_CASE( multi_channel ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -142,7 +136,6 @@ BOOST_AUTO_TEST_CASE( multi_channel ) { } ); BOOST_TEST(ret); - return true; }); c->connect(); ioc.run(); @@ -221,7 +214,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub1 = c1->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c1->set_close_handler( [&chk, &server_close] @@ -238,19 +230,16 @@ BOOST_AUTO_TEST_CASE( multi_client_qos0 ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c1->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c1->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c1->set_suback_handler( [&chk, &c1, &sub_count, &pid_sub1] @@ -261,7 +250,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos0 ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); if (++sub_count == 2) c1->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c1->set_unsuback_handler( [&chk, &c1, &pid_unsub1] @@ -269,7 +257,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos0 ) { MQTT_CHK("h_unsuback_1"); BOOST_TEST(packet_id == pid_unsub1); c1->disconnect(); - return true; }); c1->set_publish_handler( [&chk, &c1, &pid_unsub1] @@ -285,7 +272,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos0 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub1 = c1->unsubscribe("topic1"); - return true; }); auto c2 = MQTT_NS::make_client(ioc, broker_url, broker_notls_port); @@ -302,7 +288,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub2 = c2->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c2->set_close_handler( [&chk, &server_close] @@ -319,19 +304,16 @@ BOOST_AUTO_TEST_CASE( multi_client_qos0 ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c2->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c2->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c2->set_suback_handler( [&chk, &c2, &sub_count, &pid_sub2] @@ -342,7 +324,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos0 ) { BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); if (++sub_count == 2) c2->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c2->set_unsuback_handler( [&chk, &c2, &pid_unsub2] @@ -350,7 +331,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos0 ) { MQTT_CHK("h_unsuback_2"); BOOST_TEST(packet_id == pid_unsub2); c2->disconnect(); - return true; }); c2->set_publish_handler( [&chk, &c2, &pid_unsub2] @@ -366,7 +346,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos0 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub2 = c2->unsubscribe("topic1"); - return true; }); c1->connect(); @@ -463,7 +442,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub1 = c1->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c1->set_close_handler( [&chk, &server_close] @@ -488,7 +466,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos1 ) { if (c1ready && c2ready && c3ready) { pid_pub3 = c3->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); } - return true; }); c1->set_unsuback_handler( [&chk, &c1, &pid_unsub1] @@ -496,7 +473,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos1 ) { MQTT_CHK("h_unsuback_1"); BOOST_TEST(packet_id == pid_unsub1); c1->disconnect(); - return true; }); c1->set_publish_handler( [&chk, &c1, &pid_unsub1] @@ -512,7 +488,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos1 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub1 = c1->unsubscribe("topic1"); - return true; }); std::uint16_t pid_sub2; @@ -525,7 +500,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub2 = c2->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c2->set_close_handler( [&chk, &server_close] @@ -550,7 +524,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos1 ) { if (c1ready && c2ready && c3ready) { pid_pub3 = c3->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); } - return true; }); c2->set_unsuback_handler( [&chk, &c2, &pid_unsub2] @@ -558,7 +531,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos1 ) { MQTT_CHK("h_unsuback_2"); BOOST_TEST(packet_id == pid_unsub2); c2->disconnect(); - return true; }); c2->set_publish_handler( [&chk, &c2, &pid_unsub2] @@ -574,7 +546,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos1 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub2 = c2->unsubscribe("topic1"); - return true; }); c3->set_connack_handler( @@ -587,7 +558,6 @@ BOOST_AUTO_TEST_CASE( multi_client_qos1 ) { if (c1ready && c2ready && c3ready) { pid_pub3 = c3->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); } - return true; }); c3->set_close_handler( [&chk, &server_close] @@ -606,19 +576,16 @@ BOOST_AUTO_TEST_CASE( multi_client_qos1 ) { MQTT_CHK("h_puback_3"); BOOST_TEST(packet_id == pid_pub3); c3->disconnect(); - return true; }); c3->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c3->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c1->connect(); @@ -699,7 +666,6 @@ BOOST_AUTO_TEST_CASE( multi_client_nl ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c2->connect(); - return true; } ); @@ -710,7 +676,6 @@ BOOST_AUTO_TEST_CASE( multi_client_nl ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c1->subscribe("topic1", MQTT_NS::qos::at_most_once | MQTT_NS::nl::yes); - return true; } ); @@ -721,7 +686,6 @@ BOOST_AUTO_TEST_CASE( multi_client_nl ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c2->subscribe("topic1", MQTT_NS::qos::at_most_once | MQTT_NS::nl::no); - return true; } ); @@ -732,7 +696,6 @@ BOOST_AUTO_TEST_CASE( multi_client_nl ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c1->publish("topic1", "topic1_contents1", MQTT_NS::qos::at_most_once); - return true; } ); @@ -751,7 +714,6 @@ BOOST_AUTO_TEST_CASE( multi_client_nl ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents2"); c1->disconnect(); - return true; } ); @@ -786,7 +748,6 @@ BOOST_AUTO_TEST_CASE( multi_client_nl ) { ); BOOST_TEST(ret); - return true; } ); @@ -813,7 +774,6 @@ BOOST_AUTO_TEST_CASE( multi_client_nl ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c1->connect(); diff --git a/test/system/st_offline.cpp b/test/system/st_offline.cpp index 35d75e54d..1374cd5f0 100644 --- a/test/system/st_offline.cpp +++ b/test/system/st_offline.cpp @@ -92,7 +92,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c->set_puback_handler( [&chk, &c, &pid_pub] @@ -100,7 +99,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -121,7 +119,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub] @@ -129,7 +126,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); - return true; }); break; default: @@ -212,14 +208,12 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_pub] @@ -227,7 +221,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -248,14 +241,12 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code /*reason*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_pub] @@ -263,7 +254,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); - return true; }); break; default: @@ -348,7 +338,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c->set_puback_handler( [&chk, &c, &pid_pub1, &pid_pub2] @@ -365,7 +354,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -386,7 +374,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub1, &pid_pub2] @@ -403,7 +390,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); break; default: @@ -487,7 +473,6 @@ BOOST_AUTO_TEST_CASE( async_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c->set_puback_handler( [&chk, &c, &pid_pub] @@ -495,7 +480,6 @@ BOOST_AUTO_TEST_CASE( async_publish_qos1 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c->async_disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -516,7 +500,6 @@ BOOST_AUTO_TEST_CASE( async_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub] @@ -524,7 +507,6 @@ BOOST_AUTO_TEST_CASE( async_publish_qos1 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c->async_disconnect(); - return true; }); break; default: diff --git a/test/system/st_pubsub_1.cpp b/test/system/st_pubsub_1.cpp index 859f40a26..fe952a34c 100644 --- a/test/system/st_pubsub_1.cpp +++ b/test/system/st_pubsub_1.cpp @@ -48,25 +48,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -76,7 +72,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -84,7 +79,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -100,7 +94,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -111,25 +104,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -139,7 +128,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -149,7 +137,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -166,7 +153,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; default: @@ -237,7 +223,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { std::make_tuple("topic1", MQTT_NS::qos::at_most_once) } ); - return true; }); c->set_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -247,19 +232,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { pub_seq_finished = true; pid_unsub = c->unsubscribe( std::vector {"topic1"}); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_pub, &pid_sub] @@ -269,7 +251,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -277,7 +258,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -292,7 +272,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -307,7 +286,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { std::make_tuple("topic1", MQTT_NS::qos::at_most_once) } ); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -317,19 +295,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { pub_seq_finished = true; pid_unsub = c->unsubscribe( std::vector {"topic1"}); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_pub, &pid_sub] @@ -339,7 +314,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -349,7 +323,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -365,7 +338,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -434,20 +406,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_unsub, &pid_pub] @@ -456,7 +425,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_suback_handler( [&chk, &c, &pid_pub] @@ -466,7 +434,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -474,7 +441,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -489,7 +455,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_CHECK(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -500,20 +465,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_unsub, &pid_pub] @@ -522,7 +484,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_pub] @@ -532,7 +493,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -542,7 +502,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk] @@ -558,7 +517,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_CHECK(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -621,25 +579,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -649,7 +603,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -657,7 +610,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -673,7 +625,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -684,25 +635,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -712,7 +659,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -722,7 +668,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -739,7 +684,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; default: @@ -815,7 +759,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -824,19 +767,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -846,7 +786,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -854,7 +793,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -870,7 +808,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -881,7 +818,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -890,19 +826,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -912,7 +845,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -922,7 +854,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -939,7 +870,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1011,20 +941,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1033,7 +960,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1043,7 +969,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1051,7 +976,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -1067,7 +991,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1078,20 +1001,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1100,7 +1020,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1110,7 +1029,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1120,7 +1038,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -1137,7 +1054,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1202,25 +1118,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -1230,7 +1142,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1238,7 +1149,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -1254,7 +1164,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1265,25 +1174,21 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -1293,7 +1198,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1303,7 +1207,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -1320,7 +1223,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; default: @@ -1392,7 +1294,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1401,19 +1302,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1423,7 +1321,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1431,7 +1328,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -1447,7 +1343,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1458,7 +1353,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1467,19 +1361,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1489,7 +1380,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1499,7 +1389,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -1516,7 +1405,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1589,20 +1477,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1611,7 +1496,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1621,7 +1505,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1629,7 +1512,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -1645,7 +1527,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1656,20 +1537,17 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub] @@ -1678,7 +1556,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(packet_id == pid_pub); pub_seq_finished = true; pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_pub] @@ -1688,7 +1565,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1698,7 +1574,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &recv_packet_id] @@ -1715,7 +1590,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); break; default: @@ -1782,27 +1656,23 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &c] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); c->pubrel(packet_id); - return true; }); c->set_pubcomp_handler( [&chk, g] (packet_id_t) mutable { MQTT_CHK("h_pubcomp"); g.reset(); - return true; }); c->set_suback_handler( [&chk, &c] @@ -1811,14 +1681,12 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c] @@ -1836,7 +1704,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { // send pubrec twice c->pubrec(*packet_id); c->pubrec(*packet_id); - return true; }); c->set_pubrel_handler( [&chk, &c, g] @@ -1853,7 +1720,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { } ); BOOST_TEST(ret); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1864,27 +1730,23 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [&chk, &c] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); c->pubrel(packet_id); - return true; }); c->set_v5_pubcomp_handler( [&chk, g] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) mutable { MQTT_CHK("h_pubcomp"); g.reset(); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -1893,7 +1755,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] @@ -1902,7 +1763,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c] @@ -1921,7 +1781,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { // send pubrec twice c->pubrec(*packet_id); c->pubrec(*packet_id); - return true; }); c->set_v5_pubrel_handler( [&chk, &c, g] @@ -1938,7 +1797,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2_protocol_error_resend_pubrec ) { } ); BOOST_TEST(ret); - return true; }); break; default: @@ -1999,25 +1857,21 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -2027,7 +1881,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -2035,7 +1888,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -2051,7 +1903,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -2062,25 +1913,21 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -2090,7 +1937,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -2100,7 +1946,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -2117,7 +1962,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; default: @@ -2143,1548 +1987,4 @@ BOOST_AUTO_TEST_CASE( publish_function ) { do_combi_test_sync(test); } -BOOST_AUTO_TEST_CASE( publish_function_buffer ) { - auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { - auto& c = cs[0]; - clear_ordered(); - using packet_id_t = typename std::remove_reference_t::packet_id_t; - c->set_client_id("cid1"); - c->set_clean_session(true); - - packet_id_t pid_sub; - packet_id_t pid_unsub; - - - checker chk = { - // connect - cont("h_connack"), - // subscribe topic1 QoS0 - cont("h_suback"), - // publish topic1 QoS0 - cont("h_publish"), - cont("h_unsuback"), - // disconnect - cont("h_close"), - }; - - switch (c->get_protocol_version()) { - case MQTT_NS::protocol_version::v3_1_1: - c->set_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::connect_return_code connack_return_code) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); - pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); - return true; - }); - c->set_puback_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_pubrec_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_pubcomp_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_suback_handler( - [&chk, &c, &pid_sub] - (packet_id_t packet_id, std::vector results) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(results.size() == 1U); - BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); - c->publish("topic1"_mb, "topic1_contents"_mb, MQTT_NS::qos::at_most_once); - return true; - }); - c->set_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - c->disconnect(); - return true; - }); - c->set_publish_handler( - [&chk, &c, &pid_unsub] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_CHECK(!packet_id); - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - pid_unsub = c->unsubscribe("topic1"_mb); - return true; - }); - break; - case MQTT_NS::protocol_version::v5: - c->set_v5_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); - pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); - return true; - }); - c->set_v5_puback_handler( - [] - (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubrec_handler( - [] - (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubcomp_handler( - [] - (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_suback_handler( - [&chk, &c, &pid_sub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); - c->publish("topic1"_mb, "topic1_contents"_mb, MQTT_NS::qos::at_most_once); - return true; - }); - c->set_v5_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); - c->disconnect(); - return true; - }); - c->set_v5_publish_handler( - [&chk, &c, &pid_unsub] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents, - MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_CHECK(!packet_id); - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - pid_unsub = c->unsubscribe("topic1"_mb); - return true; - }); - break; - default: - BOOST_CHECK(false); - break; - } - - c->set_close_handler( - [&chk, &finish] - () { - MQTT_CHK("h_close"); - finish(); - }); - c->set_error_handler( - [] - (MQTT_NS::error_code) { - BOOST_CHECK(false); - }); - c->connect(); - ioc.run(); - BOOST_TEST(chk.all()); - }; - do_combi_test_sync(test); -} - -BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { - auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { - auto& c = cs[0]; - clear_ordered(); - using packet_id_t = typename std::remove_reference_t::packet_id_t; - c->set_client_id("cid1"); - c->set_clean_session(true); - - packet_id_t pid_sub; - packet_id_t pid_unsub; - - - checker chk = { - // connect - cont("h_connack"), - // subscribe topic1 QoS0 - cont("h_suback"), - // publish topic1 QoS0 - cont("h_publish"), - cont("h_unsuback"), - // disconnect - cont("h_close"), - }; - - switch (c->get_protocol_version()) { - case MQTT_NS::protocol_version::v3_1_1: - c->set_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::connect_return_code connack_return_code) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); - pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); - return true; - }); - c->set_puback_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_pubrec_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_pubcomp_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_suback_handler( - [&chk, &c, &pid_sub] - (packet_id_t packet_id, std::vector results) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(results.size() == 1U); - BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); - std::vector bs { - "topic"_mb, - "1"_mb, - "_"_mb, - "contents"_mb, - }; - c->publish("topic1"_mb, MQTT_NS::force_move(bs), MQTT_NS::qos::at_most_once); - return true; - }); - c->set_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - c->disconnect(); - return true; - }); - c->set_publish_handler( - [&chk, &c, &pid_unsub] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_CHECK(!packet_id); - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - pid_unsub = c->unsubscribe("topic1"_mb); - return true; - }); - break; - case MQTT_NS::protocol_version::v5: - c->set_v5_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); - pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); - return true; - }); - c->set_v5_puback_handler( - [] - (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubrec_handler( - [] - (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubcomp_handler( - [] - (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_suback_handler( - [&chk, &c, &pid_sub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); - std::vector bs { - "topic"_mb, - "1"_mb, - "_"_mb, - "contents"_mb, - }; - c->publish("topic1"_mb, MQTT_NS::force_move(bs), MQTT_NS::qos::at_most_once); - return true; - }); - c->set_v5_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); - c->disconnect(); - return true; - }); - c->set_v5_publish_handler( - [&chk, &c, &pid_unsub] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents, - MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_CHECK(!packet_id); - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - pid_unsub = c->unsubscribe("topic1"_mb); - return true; - }); - break; - default: - BOOST_CHECK(false); - break; - } - - c->set_close_handler( - [&chk, &finish] - () { - MQTT_CHK("h_close"); - finish(); - }); - c->set_error_handler( - [] - (MQTT_NS::error_code) { - BOOST_CHECK(false); - }); - c->connect(); - ioc.run(); - BOOST_TEST(chk.all()); - }; - do_combi_test_sync(test); -} - -BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { - auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { - auto& c = cs[0]; - clear_ordered(); - using packet_id_t = typename std::remove_reference_t::packet_id_t; - c->set_client_id("cid1"); - c->set_clean_session(true); - - packet_id_t pid_sub; - packet_id_t pid_unsub; - - - checker chk = { - // connect - cont("h_connack"), - // subscribe topic1 QoS0 - cont("h_suback"), - // publish topic1 QoS0 - cont("h_publish"), - cont("h_unsuback"), - // disconnect - cont("h_close"), - }; - - switch (c->get_protocol_version()) { - case MQTT_NS::protocol_version::v3_1_1: - c->set_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::connect_return_code connack_return_code) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); - pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); - return true; - }); - c->set_puback_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_pubrec_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_pubcomp_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_suback_handler( - [&chk, &c, &pid_sub] - (packet_id_t packet_id, std::vector results) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(results.size() == 1U); - BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); - auto topic_name = std::make_shared("topic1"); - auto s1 = std::make_shared("topic"); - auto s2 = std::make_shared("1"); - auto s3 = std::make_shared("_"); - auto s4 = std::make_shared("contents"); - std::vector cbs { - as::buffer(*s1), - as::buffer(*s2), - as::buffer(*s3), - as::buffer(*s4) - }; - c->publish( - as::buffer(*topic_name), - cbs, - MQTT_NS::qos::at_most_once, - std::make_tuple(topic_name, s1, s2, s3, s4) - ); - return true; - }); - c->set_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - c->disconnect(); - return true; - }); - c->set_publish_handler( - [&chk, &c, &pid_unsub] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_CHECK(!packet_id); - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - pid_unsub = c->unsubscribe("topic1"_mb); - return true; - }); - break; - case MQTT_NS::protocol_version::v5: - c->set_v5_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); - pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); - return true; - }); - c->set_v5_puback_handler( - [] - (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubrec_handler( - [] - (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubcomp_handler( - [] - (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_suback_handler( - [&chk, &c, &pid_sub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); - auto topic_name = std::make_shared("topic1"); - auto s1 = std::make_shared("topic"); - auto s2 = std::make_shared("1"); - auto s3 = std::make_shared("_"); - auto s4 = std::make_shared("contents"); - std::vector cbs { - as::buffer(*s1), - as::buffer(*s2), - as::buffer(*s3), - as::buffer(*s4) - }; - c->publish( - as::buffer(*topic_name), - cbs, - MQTT_NS::qos::at_most_once, - std::make_tuple(topic_name, s1, s2, s3, s4) - ); - return true; - }); - c->set_v5_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); - c->disconnect(); - return true; - }); - c->set_v5_publish_handler( - [&chk, &c, &pid_unsub] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents, - MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_CHECK(!packet_id); - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - pid_unsub = c->unsubscribe("topic1"_mb); - return true; - }); - break; - default: - BOOST_CHECK(false); - break; - } - - c->set_close_handler( - [&chk, &finish] - () { - MQTT_CHK("h_close"); - finish(); - }); - c->set_error_handler( - [] - (MQTT_NS::error_code) { - BOOST_CHECK(false); - }); - c->connect(); - ioc.run(); - BOOST_TEST(chk.all()); - }; - do_combi_test_sync(test); -} - -BOOST_AUTO_TEST_CASE( publish_dup_function ) { - auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { - auto& c = cs[0]; - clear_ordered(); - using packet_id_t = typename std::remove_reference_t::packet_id_t; - c->set_client_id("cid1"); - c->set_clean_session(true); - - packet_id_t pid_sub; - packet_id_t pid_unsub; - - - checker chk = { - // connect - cont("h_connack"), - // subscribe topic1 QoS1 - cont("h_suback"), - // publish topic1 QoS1 - cont("h_publish"), - cont("h_puback"), - cont("h_unsuback"), - // disconnect - cont("h_close"), - }; - - switch (c->get_protocol_version()) { - case MQTT_NS::protocol_version::v3_1_1: - c->set_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::connect_return_code connack_return_code) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); - pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; - }); - c->set_puback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id) { - MQTT_CHK("h_puback"); - BOOST_TEST(packet_id == 1); - pid_unsub = c->unsubscribe("topic1"); - return true; - }); - c->set_pubrec_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_pubcomp_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_suback_handler( - [&chk, &c, &pid_sub] - (packet_id_t packet_id, std::vector results) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(results.size() == 1U); - BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); - BOOST_TEST(c->register_packet_id(1) == true); - c->publish(1, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; - }); - c->set_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - c->disconnect(); - return true; - }); - c->set_publish_handler( - [&chk] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_least_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_CHECK(packet_id.value() == 1); - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - return true; - }); - break; - case MQTT_NS::protocol_version::v5: - c->set_v5_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); - pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; - }); - c->set_v5_puback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_puback"); - BOOST_TEST(packet_id == 1); - pid_unsub = c->unsubscribe("topic1"); - return true; - }); - c->set_v5_pubrec_handler( - [] - (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubcomp_handler( - [] - (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_suback_handler( - [&chk, &c, &pid_sub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); - BOOST_TEST(c->register_packet_id(1) == true); - c->publish(1, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; - }); - c->set_v5_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); - c->disconnect(); - return true; - }); - c->set_v5_publish_handler( - [&chk] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents, - MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_least_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_CHECK(packet_id.value() == 1); - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - return true; - }); - break; - default: - BOOST_CHECK(false); - break; - } - - c->set_close_handler( - [&chk, &finish] - () { - MQTT_CHK("h_close"); - finish(); - }); - c->set_error_handler( - [] - (MQTT_NS::error_code) { - BOOST_CHECK(false); - }); - c->connect(); - ioc.run(); - BOOST_TEST(chk.all()); - }; - do_combi_test_sync(test); -} - -BOOST_AUTO_TEST_CASE( publish_dup_function_buffer ) { - auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { - auto& c = cs[0]; - clear_ordered(); - using packet_id_t = typename std::remove_reference_t::packet_id_t; - c->set_client_id("cid1"); - c->set_clean_session(true); - - packet_id_t pid_sub; - packet_id_t pid_unsub; - - - checker chk = { - // connect - cont("h_connack"), - // subscribe topic1 QoS1 - cont("h_suback"), - // publish topic1 QoS1 - cont("h_publish"), - cont("h_puback"), - cont("h_unsuback"), - // disconnect - cont("h_close"), - }; - - switch (c->get_protocol_version()) { - case MQTT_NS::protocol_version::v3_1_1: - c->set_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::connect_return_code connack_return_code) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); - pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_least_once); - return true; - }); - c->set_puback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id) { - MQTT_CHK("h_puback"); - BOOST_TEST(packet_id == 1); - pid_unsub = c->unsubscribe("topic1"_mb); - return true; - }); - c->set_pubrec_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_pubcomp_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - return true; - }); - c->set_suback_handler( - [&chk, &c, &pid_sub] - (packet_id_t packet_id, std::vector results) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(results.size() == 1U); - BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); - BOOST_TEST(c->register_packet_id(1) == true); - c->publish(1, "topic1"_mb, "topic1_contents"_mb, MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; - }); - c->set_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - c->disconnect(); - return true; - }); - c->set_publish_handler( - [&chk] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_least_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_CHECK(packet_id.value() == 1); - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - return true; - }); - break; - case MQTT_NS::protocol_version::v5: - c->set_v5_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); - pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_least_once); - return true; - }); - c->set_v5_puback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_puback"); - BOOST_TEST(packet_id == 1); - pid_unsub = c->unsubscribe("topic1"_mb); - return true; - }); - c->set_v5_pubrec_handler( - [] - (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubcomp_handler( - [] - (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_suback_handler( - [&chk, &c, &pid_sub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); - BOOST_TEST(c->register_packet_id(1) == true); - c->publish(1, "topic1"_mb, "topic1_contents"_mb, MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); - return true; - }); - c->set_v5_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); - c->disconnect(); - return true; - }); - c->set_v5_publish_handler( - [&chk] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents, - MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_least_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_CHECK(packet_id.value() == 1); - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - return true; - }); - break; - default: - BOOST_CHECK(false); - break; - } - - c->set_close_handler( - [&chk, &finish] - () { - MQTT_CHK("h_close"); - finish(); - }); - c->set_error_handler( - [] - (MQTT_NS::error_code) { - BOOST_CHECK(false); - }); - c->connect(); - ioc.run(); - BOOST_TEST(chk.all()); - }; - do_combi_test_sync(test); -} - -BOOST_AUTO_TEST_CASE( pub_sub_prop ) { - using namespace std::literals::string_literals; - auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { - auto& c = cs[0]; - clear_ordered(); - if (c->get_protocol_version() != MQTT_NS::protocol_version::v5) { - finish(); - return; - } - - using packet_id_t = typename std::remove_reference_t::packet_id_t; - c->set_client_id("cid1"); - c->set_clean_session(true); - - packet_id_t pid_sub; - packet_id_t pid_unsub; - - checker chk = { - // connect - cont("h_connack"), - // subscribe topic1 QoS0 - cont("h_suback"), - // publish topic1 QoS0 - cont("h_publish"), - cont("h_unsuback"), - // disconnect - cont("h_close"), - }; - MQTT_NS::v5::properties ps { - MQTT_NS::v5::property::payload_format_indicator(MQTT_NS::v5::property::payload_format_indicator::string), - MQTT_NS::v5::property::message_expiry_interval(0x12345678UL), - MQTT_NS::v5::property::content_type("content type"_mb), - MQTT_NS::v5::property::topic_alias(0x1234U), - MQTT_NS::v5::property::response_topic("response topic"_mb), - MQTT_NS::v5::property::correlation_data("correlation \0data"_mb), - MQTT_NS::v5::property::user_property("key1"_mb, "val1"_mb), - MQTT_NS::v5::property::user_property("key2"_mb, "val2"_mb), - }; - - auto prop_size = ps.size(); - std::size_t user_prop_count = 0; - - c->set_v5_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); - pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; - }); - c->set_v5_puback_handler( - [] - (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubrec_handler( - [] - (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubcomp_handler( - [] - (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_suback_handler( - [&chk, &c, &pid_sub, ps = MQTT_NS::force_move(ps)] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) mutable { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); - c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once | MQTT_NS::retain::no, MQTT_NS::force_move(ps)); - return true; - }); - c->set_v5_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); - c->disconnect(); - return true; - }); - c->set_v5_publish_handler( - [&chk, &c, &pid_unsub, &user_prop_count, prop_size] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents, - MQTT_NS::v5::properties props) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_CHECK(!packet_id); - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - - // -1 means TopicAlias - // TopicAlias is not forwarded - // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901113 - // A receiver MUST NOT carry forward any Topic Alias mappings from - // one Network Connection to another [MQTT-3.3.2-7]. - BOOST_TEST(props.size() == prop_size - 1); - - for (auto const& p : props) { - MQTT_NS::visit( - MQTT_NS::make_lambda_visitor( - [&](MQTT_NS::v5::property::payload_format_indicator const& t) { - BOOST_TEST(t.val() == MQTT_NS::v5::property::payload_format_indicator::string); - }, - [&](MQTT_NS::v5::property::content_type const& t) { - BOOST_TEST(t.val() == "content type"); - }, - [&](MQTT_NS::v5::property::message_expiry_interval const& t) { - BOOST_TEST(t.val() == 0x12345678UL); - }, - [&](MQTT_NS::v5::property::response_topic const& t) { - BOOST_TEST(t.val() == "response topic"); - }, - [&](MQTT_NS::v5::property::correlation_data const& t) { - BOOST_TEST(t.val() == std::string("correlation \0data"s)); - }, - [&](MQTT_NS::v5::property::user_property const& t) { - switch (user_prop_count++) { - case 0: - BOOST_TEST(t.key() == "key1"); - BOOST_TEST(t.val() == "val1"); - break; - case 1: - BOOST_TEST(t.key() == "key2"); - BOOST_TEST(t.val() == "val2"); - break; - default: - BOOST_TEST(false); - break; - } - }, - [&](auto&& ...) { - BOOST_TEST(false); - } - ), - p - ); - } - - pid_unsub = c->unsubscribe("topic1"); - return true; - }); - c->set_close_handler( - [&chk, &finish] - () { - MQTT_CHK("h_close"); - finish(); - }); - c->set_error_handler( - [] - (MQTT_NS::error_code) { - BOOST_CHECK(false); - }); - c->set_pub_res_sent_handler( - [] - (packet_id_t) { - BOOST_CHECK(false); - }); - c->connect(); - ioc.run(); - BOOST_TEST(chk.all()); - }; - do_combi_test_sync(test); -} - -BOOST_AUTO_TEST_CASE( puback_prop ) { - auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& b) { - auto& c = cs[0]; - clear_ordered(); - if (c->get_protocol_version() != MQTT_NS::protocol_version::v5) { - finish(); - return; - } - - using packet_id_t = typename std::remove_reference_t::packet_id_t; - c->set_client_id("cid1"); - c->set_clean_session(true); - - packet_id_t pid_pub; - packet_id_t pid_sub; - packet_id_t pid_unsub; - - bool pub_seq_finished = false; - - - checker chk = { - // connect - cont("h_connack"), - // subscribe topic1 QoS0 - cont("h_suback"), - // publish topic1 QoS1 - cont("h_publish"), - cont("h_pub_res_sent"), - cont("h_puback"), - cont("h_unsuback"), - // disconnect - cont("h_close"), - }; - - MQTT_NS::v5::properties pubackps { - MQTT_NS::v5::property::reason_string("test success"_mb), - MQTT_NS::v5::property::user_property("key1"_mb, "val1"_mb), - MQTT_NS::v5::property::user_property("key2"_mb, "val2"_mb), - }; - auto puback_prop_size = pubackps.size(); - b.set_puback_props(MQTT_NS::force_move(pubackps)); - std::size_t puback_user_prop_count = 0; - - MQTT_NS::optional recv_packet_id; - c->set_pub_res_sent_handler( - [&chk, &recv_packet_id] - (packet_id_t packet_id) { - MQTT_CHK("h_pub_res_sent"); - BOOST_TEST(*recv_packet_id == packet_id); - }); - - c->set_v5_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); - pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; - }); - c->set_v5_puback_handler( - [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub, puback_prop_size, &puback_user_prop_count] - (packet_id_t packet_id, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties props) { - MQTT_CHK("h_puback"); - BOOST_TEST(packet_id == pid_pub); - pub_seq_finished = true; - - BOOST_TEST(props.size() == puback_prop_size); - for (auto const& p : props) { - MQTT_NS::visit( - MQTT_NS::make_lambda_visitor( - [&](MQTT_NS::v5::property::reason_string const& t) { - BOOST_TEST(t.val() == "test success"); - }, - [&](MQTT_NS::v5::property::user_property const& t) { - switch (puback_user_prop_count++) { - case 0: - BOOST_TEST(t.key() == "key1"); - BOOST_TEST(t.val() == "val1"); - break; - case 1: - BOOST_TEST(t.key() == "key2"); - BOOST_TEST(t.val() == "val2"); - break; - default: - BOOST_TEST(false); - break; - } - }, - [&](auto&& ...) { - BOOST_TEST(false); - } - ), - p - ); - } - - pid_unsub = c->unsubscribe("topic1"); - return true; - }); - c->set_v5_pubrec_handler( - [] - (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubcomp_handler( - [] - (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_suback_handler( - [&chk, &c, &pid_sub, &pid_pub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); - pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; - }); - c->set_v5_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); - c->disconnect(); - return true; - }); - c->set_v5_publish_handler( - [&chk, &recv_packet_id] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents, - MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_least_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_TEST(*packet_id != 0); - recv_packet_id = packet_id; - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - return true; - }); - c->set_close_handler( - [&chk, &finish] - () { - MQTT_CHK("h_close"); - finish(); - }); - c->set_error_handler( - [] - (MQTT_NS::error_code) { - BOOST_CHECK(false); - }); - c->connect(); - ioc.run(); - BOOST_TEST(chk.all()); - }; - do_combi_test_sync(test); -} - -BOOST_AUTO_TEST_CASE( pubrec_rel_comp_prop ) { - auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& b) { - auto& c = cs[0]; - clear_ordered(); - if (c->get_protocol_version() != MQTT_NS::protocol_version::v5) { - finish(); - return; - } - - using packet_id_t = typename std::remove_reference_t::packet_id_t; - c->set_client_id("cid1"); - c->set_clean_session(true); - c->set_auto_pub_response(false); - - packet_id_t pid_pub; - packet_id_t pid_sub; - packet_id_t pid_unsub; - - bool pub_seq_finished = false; - - - checker chk = { - // connect - cont("h_connack"), - // subscribe topic1 QoS0 - cont("h_suback"), - // publish topic1 QoS2 - cont("h_publish"), - cont("h_pubrec"), - cont("h_pub_res_sent"), - cont("h_pubcomp"), - cont("h_unsuback"), - // disconnect - cont("h_close"), - }; - - MQTT_NS::v5::properties pubrecps { - MQTT_NS::v5::property::reason_string("test success"_mb), - MQTT_NS::v5::property::user_property("key1"_mb, "val1"_mb), - MQTT_NS::v5::property::user_property("key2"_mb, "val2"_mb), - }; - auto pubrec_prop_size = pubrecps.size(); - b.set_pubrec_props(MQTT_NS::force_move(pubrecps)); - std::size_t pubrec_user_prop_count = 0; - - MQTT_NS::v5::properties pubrelps { - MQTT_NS::v5::property::reason_string("test success"_mb), - MQTT_NS::v5::property::user_property("key1"_mb, "val1"_mb), - MQTT_NS::v5::property::user_property("key2"_mb, "val2"_mb), - }; - std::size_t pubrel_user_prop_count = 0; - - MQTT_NS::v5::properties pubcompps { - MQTT_NS::v5::property::reason_string("test success"_mb), - MQTT_NS::v5::property::user_property("key1"_mb, "val1"_mb), - MQTT_NS::v5::property::user_property("key2"_mb, "val2"_mb), - }; - auto pubcomp_prop_size = pubcompps.size(); - b.set_pubcomp_props(MQTT_NS::force_move(pubcompps)); - std::size_t pubcomp_user_prop_count = 0; - - b.set_pubrel_props_handler( - [&pubrel_user_prop_count, size = pubrelps.size()] (MQTT_NS::v5::properties const& props) { - BOOST_TEST(props.size() == size); - for (auto const& p : props) { - MQTT_NS::visit( - MQTT_NS::make_lambda_visitor( - [&](MQTT_NS::v5::property::reason_string const& t) { - BOOST_TEST(t.val() == "test success"); - }, - [&](MQTT_NS::v5::property::user_property const& t) { - switch (pubrel_user_prop_count++) { - case 0: - BOOST_TEST(t.key() == "key1"); - BOOST_TEST(t.val() == "val1"); - break; - case 1: - BOOST_TEST(t.key() == "key2"); - BOOST_TEST(t.val() == "val2"); - break; - default: - BOOST_TEST(false); - break; - } - }, - [&](auto&& ...) { - BOOST_TEST(false); - } - ), - p - ); - } - } - ); - - MQTT_NS::optional recv_packet_id; - c->set_pub_res_sent_handler( - [&chk, &recv_packet_id] - (packet_id_t packet_id) { - MQTT_CHK("h_pub_res_sent"); - BOOST_TEST(*recv_packet_id == packet_id); - }); - - c->set_v5_connack_handler( - [&chk, &c, &pid_sub] - (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_connack"); - BOOST_TEST(sp == false); - BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); - pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; - }); - c->set_v5_puback_handler( - [] - (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { - BOOST_CHECK(false); - return true; - }); - c->set_v5_pubrec_handler( - [&chk, &c, &pid_pub, pubrec_prop_size, &pubrec_user_prop_count, pubrelps = MQTT_NS::force_move(pubrelps)] - (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties props) mutable { - MQTT_CHK("h_pubrec"); - BOOST_TEST(packet_id == pid_pub); - - BOOST_TEST(props.size() == pubrec_prop_size); - for (auto const& p : props) { - MQTT_NS::visit( - MQTT_NS::make_lambda_visitor( - [&](MQTT_NS::v5::property::reason_string const& t) { - BOOST_TEST(t.val() == "test success"); - }, - [&](MQTT_NS::v5::property::user_property const& t) { - switch (pubrec_user_prop_count++) { - case 0: - BOOST_TEST(t.key() == "key1"); - BOOST_TEST(t.val() == "val1"); - break; - case 1: - BOOST_TEST(t.key() == "key2"); - BOOST_TEST(t.val() == "val2"); - break; - default: - BOOST_TEST(false); - break; - } - }, - [&](auto&& ...) { - BOOST_TEST(false); - } - ), - p - ); - } - - c->pubrel(packet_id, MQTT_NS::v5::pubrel_reason_code::success, MQTT_NS::force_move(pubrelps)); - - return true; - }); - c->set_v5_pubcomp_handler( - [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub, pubcomp_prop_size, &pubcomp_user_prop_count] - (packet_id_t packet_id, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties props) { - MQTT_CHK("h_pubcomp"); - BOOST_TEST(packet_id == pid_pub); - - BOOST_TEST(props.size() == pubcomp_prop_size); - for (auto const& p : props) { - MQTT_NS::visit( - MQTT_NS::make_lambda_visitor( - [&](MQTT_NS::v5::property::reason_string const& t) { - BOOST_TEST(t.val() == "test success"); - }, - [&](MQTT_NS::v5::property::user_property const& t) { - switch (pubcomp_user_prop_count++) { - case 0: - BOOST_TEST(t.key() == "key1"); - BOOST_TEST(t.val() == "val1"); - break; - case 1: - BOOST_TEST(t.key() == "key2"); - BOOST_TEST(t.val() == "val2"); - break; - default: - BOOST_TEST(false); - break; - } - }, - [&](auto&& ...) { - BOOST_TEST(false); - } - ), - p - ); - } - - pub_seq_finished = true; - pid_unsub = c->unsubscribe("topic1"); - return true; - }); - c->set_v5_suback_handler( - [&chk, &c, &pid_sub, &pid_pub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_suback"); - BOOST_TEST(packet_id == pid_sub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); - pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; - }); - c->set_v5_unsuback_handler( - [&chk, &c, &pid_unsub] - (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_unsuback"); - BOOST_TEST(packet_id == pid_unsub); - BOOST_TEST(reasons.size() == 1U); - BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); - c->disconnect(); - return true; - }); - c->set_v5_publish_handler( - [&chk, &c, &recv_packet_id] - (MQTT_NS::optional packet_id, - MQTT_NS::publish_options pubopts, - MQTT_NS::buffer topic, - MQTT_NS::buffer contents, - MQTT_NS::v5::properties /*props*/) { - MQTT_CHK("h_publish"); - BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); - BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::exactly_once); - BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); - BOOST_TEST(*packet_id != 0); - recv_packet_id = packet_id; - BOOST_TEST(topic == "topic1"); - BOOST_TEST(contents == "topic1_contents"); - c->pubrec(*packet_id, MQTT_NS::v5::pubrec_reason_code::success, {}); - return true; - }); - c->set_v5_pubrel_handler( - [&c] - (packet_id_t packet_id, MQTT_NS::v5::pubrel_reason_code, MQTT_NS::v5::properties /*props*/) { - c->pubcomp(packet_id, MQTT_NS::v5::pubcomp_reason_code::success, {}); - return true; - }); - c->set_close_handler( - [&chk, &finish] - () { - MQTT_CHK("h_close"); - finish(); - }); - c->set_error_handler( - [] - (MQTT_NS::error_code) { - BOOST_CHECK(false); - }); - c->connect(); - ioc.run(); - BOOST_TEST(chk.all()); - }; - do_combi_test_sync(test); -} - BOOST_AUTO_TEST_SUITE_END() diff --git a/test/system/st_pubsub_2.cpp b/test/system/st_pubsub_2.cpp index e81f68518..c0c595dc8 100644 --- a/test/system/st_pubsub_2.cpp +++ b/test/system/st_pubsub_2.cpp @@ -16,6 +16,1458 @@ BOOST_AUTO_TEST_SUITE(st_pubsub_2) using namespace MQTT_NS::literals; +BOOST_AUTO_TEST_CASE( publish_function_buffer ) { + auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { + auto& c = cs[0]; + clear_ordered(); + using packet_id_t = typename std::remove_reference_t::packet_id_t; + c->set_client_id("cid1"); + c->set_clean_session(true); + + packet_id_t pid_sub; + packet_id_t pid_unsub; + + + checker chk = { + // connect + cont("h_connack"), + // subscribe topic1 QoS0 + cont("h_suback"), + // publish topic1 QoS0 + cont("h_publish"), + cont("h_unsuback"), + // disconnect + cont("h_close"), + }; + + switch (c->get_protocol_version()) { + case MQTT_NS::protocol_version::v3_1_1: + c->set_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::connect_return_code connack_return_code) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); + pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); + }); + c->set_puback_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_pubrec_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_pubcomp_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_suback_handler( + [&chk, &c, &pid_sub] + (packet_id_t packet_id, std::vector results) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(results.size() == 1U); + BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); + c->publish("topic1"_mb, "topic1_contents"_mb, MQTT_NS::qos::at_most_once); + }); + c->set_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + c->disconnect(); + }); + c->set_publish_handler( + [&chk, &c, &pid_unsub] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_CHECK(!packet_id); + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + pid_unsub = c->unsubscribe("topic1"_mb); + }); + break; + case MQTT_NS::protocol_version::v5: + c->set_v5_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); + pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); + }); + c->set_v5_puback_handler( + [] + (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubrec_handler( + [] + (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubcomp_handler( + [] + (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_suback_handler( + [&chk, &c, &pid_sub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); + c->publish("topic1"_mb, "topic1_contents"_mb, MQTT_NS::qos::at_most_once); + }); + c->set_v5_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); + c->disconnect(); + }); + c->set_v5_publish_handler( + [&chk, &c, &pid_unsub] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents, + MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_CHECK(!packet_id); + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + pid_unsub = c->unsubscribe("topic1"_mb); + }); + break; + default: + BOOST_CHECK(false); + break; + } + + c->set_close_handler( + [&chk, &finish] + () { + MQTT_CHK("h_close"); + finish(); + }); + c->set_error_handler( + [] + (MQTT_NS::error_code) { + BOOST_CHECK(false); + }); + c->connect(); + ioc.run(); + BOOST_TEST(chk.all()); + }; + do_combi_test_sync(test); +} + +BOOST_AUTO_TEST_CASE( publish_function_buffer_sequence ) { + auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { + auto& c = cs[0]; + clear_ordered(); + using packet_id_t = typename std::remove_reference_t::packet_id_t; + c->set_client_id("cid1"); + c->set_clean_session(true); + + packet_id_t pid_sub; + packet_id_t pid_unsub; + + + checker chk = { + // connect + cont("h_connack"), + // subscribe topic1 QoS0 + cont("h_suback"), + // publish topic1 QoS0 + cont("h_publish"), + cont("h_unsuback"), + // disconnect + cont("h_close"), + }; + + switch (c->get_protocol_version()) { + case MQTT_NS::protocol_version::v3_1_1: + c->set_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::connect_return_code connack_return_code) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); + pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); + }); + c->set_puback_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_pubrec_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_pubcomp_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_suback_handler( + [&chk, &c, &pid_sub] + (packet_id_t packet_id, std::vector results) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(results.size() == 1U); + BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); + std::vector bs { + "topic"_mb, + "1"_mb, + "_"_mb, + "contents"_mb, + }; + c->publish("topic1"_mb, MQTT_NS::force_move(bs), MQTT_NS::qos::at_most_once); + }); + c->set_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + c->disconnect(); + }); + c->set_publish_handler( + [&chk, &c, &pid_unsub] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_CHECK(!packet_id); + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + pid_unsub = c->unsubscribe("topic1"_mb); + }); + break; + case MQTT_NS::protocol_version::v5: + c->set_v5_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); + pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); + }); + c->set_v5_puback_handler( + [] + (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubrec_handler( + [] + (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubcomp_handler( + [] + (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_suback_handler( + [&chk, &c, &pid_sub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); + std::vector bs { + "topic"_mb, + "1"_mb, + "_"_mb, + "contents"_mb, + }; + c->publish("topic1"_mb, MQTT_NS::force_move(bs), MQTT_NS::qos::at_most_once); + }); + c->set_v5_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); + c->disconnect(); + }); + c->set_v5_publish_handler( + [&chk, &c, &pid_unsub] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents, + MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_CHECK(!packet_id); + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + pid_unsub = c->unsubscribe("topic1"_mb); + }); + break; + default: + BOOST_CHECK(false); + break; + } + + c->set_close_handler( + [&chk, &finish] + () { + MQTT_CHK("h_close"); + finish(); + }); + c->set_error_handler( + [] + (MQTT_NS::error_code) { + BOOST_CHECK(false); + }); + c->connect(); + ioc.run(); + BOOST_TEST(chk.all()); + }; + do_combi_test_sync(test); +} + +BOOST_AUTO_TEST_CASE( publish_function_const_buffer_sequence ) { + auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { + auto& c = cs[0]; + clear_ordered(); + using packet_id_t = typename std::remove_reference_t::packet_id_t; + c->set_client_id("cid1"); + c->set_clean_session(true); + + packet_id_t pid_sub; + packet_id_t pid_unsub; + + + checker chk = { + // connect + cont("h_connack"), + // subscribe topic1 QoS0 + cont("h_suback"), + // publish topic1 QoS0 + cont("h_publish"), + cont("h_unsuback"), + // disconnect + cont("h_close"), + }; + + switch (c->get_protocol_version()) { + case MQTT_NS::protocol_version::v3_1_1: + c->set_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::connect_return_code connack_return_code) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); + pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); + }); + c->set_puback_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_pubrec_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_pubcomp_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_suback_handler( + [&chk, &c, &pid_sub] + (packet_id_t packet_id, std::vector results) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(results.size() == 1U); + BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); + auto topic_name = std::make_shared("topic1"); + auto s1 = std::make_shared("topic"); + auto s2 = std::make_shared("1"); + auto s3 = std::make_shared("_"); + auto s4 = std::make_shared("contents"); + std::vector cbs { + as::buffer(*s1), + as::buffer(*s2), + as::buffer(*s3), + as::buffer(*s4) + }; + c->publish( + as::buffer(*topic_name), + cbs, + MQTT_NS::qos::at_most_once, + std::make_tuple(topic_name, s1, s2, s3, s4) + ); + }); + c->set_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + c->disconnect(); + }); + c->set_publish_handler( + [&chk, &c, &pid_unsub] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_CHECK(!packet_id); + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + pid_unsub = c->unsubscribe("topic1"_mb); + }); + break; + case MQTT_NS::protocol_version::v5: + c->set_v5_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); + pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_most_once); + }); + c->set_v5_puback_handler( + [] + (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubrec_handler( + [] + (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubcomp_handler( + [] + (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_suback_handler( + [&chk, &c, &pid_sub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); + auto topic_name = std::make_shared("topic1"); + auto s1 = std::make_shared("topic"); + auto s2 = std::make_shared("1"); + auto s3 = std::make_shared("_"); + auto s4 = std::make_shared("contents"); + std::vector cbs { + as::buffer(*s1), + as::buffer(*s2), + as::buffer(*s3), + as::buffer(*s4) + }; + c->publish( + as::buffer(*topic_name), + cbs, + MQTT_NS::qos::at_most_once, + std::make_tuple(topic_name, s1, s2, s3, s4) + ); + }); + c->set_v5_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); + c->disconnect(); + }); + c->set_v5_publish_handler( + [&chk, &c, &pid_unsub] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents, + MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_CHECK(!packet_id); + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + pid_unsub = c->unsubscribe("topic1"_mb); + }); + break; + default: + BOOST_CHECK(false); + break; + } + + c->set_close_handler( + [&chk, &finish] + () { + MQTT_CHK("h_close"); + finish(); + }); + c->set_error_handler( + [] + (MQTT_NS::error_code) { + BOOST_CHECK(false); + }); + c->connect(); + ioc.run(); + BOOST_TEST(chk.all()); + }; + do_combi_test_sync(test); +} + +BOOST_AUTO_TEST_CASE( publish_dup_function ) { + auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { + auto& c = cs[0]; + clear_ordered(); + using packet_id_t = typename std::remove_reference_t::packet_id_t; + c->set_client_id("cid1"); + c->set_clean_session(true); + + packet_id_t pid_sub; + packet_id_t pid_unsub; + + + checker chk = { + // connect + cont("h_connack"), + // subscribe topic1 QoS1 + cont("h_suback"), + // publish topic1 QoS1 + cont("h_publish"), + cont("h_puback"), + cont("h_unsuback"), + // disconnect + cont("h_close"), + }; + + switch (c->get_protocol_version()) { + case MQTT_NS::protocol_version::v3_1_1: + c->set_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::connect_return_code connack_return_code) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); + pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); + }); + c->set_puback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id) { + MQTT_CHK("h_puback"); + BOOST_TEST(packet_id == 1); + pid_unsub = c->unsubscribe("topic1"); + }); + c->set_pubrec_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_pubcomp_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_suback_handler( + [&chk, &c, &pid_sub] + (packet_id_t packet_id, std::vector results) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(results.size() == 1U); + BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); + BOOST_TEST(c->register_packet_id(1) == true); + c->publish(1, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); + }); + c->set_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + c->disconnect(); + }); + c->set_publish_handler( + [&chk] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_least_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_CHECK(packet_id.value() == 1); + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + }); + break; + case MQTT_NS::protocol_version::v5: + c->set_v5_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); + pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); + }); + c->set_v5_puback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_puback"); + BOOST_TEST(packet_id == 1); + pid_unsub = c->unsubscribe("topic1"); + }); + c->set_v5_pubrec_handler( + [] + (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubcomp_handler( + [] + (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_suback_handler( + [&chk, &c, &pid_sub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); + BOOST_TEST(c->register_packet_id(1) == true); + c->publish(1, "topic1", "topic1_contents", MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); + }); + c->set_v5_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); + c->disconnect(); + }); + c->set_v5_publish_handler( + [&chk] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents, + MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_least_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_CHECK(packet_id.value() == 1); + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + }); + break; + default: + BOOST_CHECK(false); + break; + } + + c->set_close_handler( + [&chk, &finish] + () { + MQTT_CHK("h_close"); + finish(); + }); + c->set_error_handler( + [] + (MQTT_NS::error_code) { + BOOST_CHECK(false); + }); + c->connect(); + ioc.run(); + BOOST_TEST(chk.all()); + }; + do_combi_test_sync(test); +} + +BOOST_AUTO_TEST_CASE( publish_dup_function_buffer ) { + auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { + auto& c = cs[0]; + clear_ordered(); + using packet_id_t = typename std::remove_reference_t::packet_id_t; + c->set_client_id("cid1"); + c->set_clean_session(true); + + packet_id_t pid_sub; + packet_id_t pid_unsub; + + + checker chk = { + // connect + cont("h_connack"), + // subscribe topic1 QoS1 + cont("h_suback"), + // publish topic1 QoS1 + cont("h_publish"), + cont("h_puback"), + cont("h_unsuback"), + // disconnect + cont("h_close"), + }; + + switch (c->get_protocol_version()) { + case MQTT_NS::protocol_version::v3_1_1: + c->set_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::connect_return_code connack_return_code) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); + pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_least_once); + }); + c->set_puback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id) { + MQTT_CHK("h_puback"); + BOOST_TEST(packet_id == 1); + pid_unsub = c->unsubscribe("topic1"_mb); + }); + c->set_pubrec_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_pubcomp_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->set_suback_handler( + [&chk, &c, &pid_sub] + (packet_id_t packet_id, std::vector results) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(results.size() == 1U); + BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); + BOOST_TEST(c->register_packet_id(1) == true); + c->publish(1, "topic1"_mb, "topic1_contents"_mb, MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); + }); + c->set_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + c->disconnect(); + }); + c->set_publish_handler( + [&chk] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_least_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_CHECK(packet_id.value() == 1); + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + }); + break; + case MQTT_NS::protocol_version::v5: + c->set_v5_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); + pid_sub = c->subscribe("topic1"_mb, MQTT_NS::qos::at_least_once); + }); + c->set_v5_puback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_puback"); + BOOST_TEST(packet_id == 1); + pid_unsub = c->unsubscribe("topic1"_mb); + }); + c->set_v5_pubrec_handler( + [] + (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubcomp_handler( + [] + (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_suback_handler( + [&chk, &c, &pid_sub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); + BOOST_TEST(c->register_packet_id(1) == true); + c->publish(1, "topic1"_mb, "topic1_contents"_mb, MQTT_NS::qos::at_least_once | MQTT_NS::dup::yes); + }); + c->set_v5_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); + c->disconnect(); + }); + c->set_v5_publish_handler( + [&chk] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents, + MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_least_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_CHECK(packet_id.value() == 1); + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + }); + break; + default: + BOOST_CHECK(false); + break; + } + + c->set_close_handler( + [&chk, &finish] + () { + MQTT_CHK("h_close"); + finish(); + }); + c->set_error_handler( + [] + (MQTT_NS::error_code) { + BOOST_CHECK(false); + }); + c->connect(); + ioc.run(); + BOOST_TEST(chk.all()); + }; + do_combi_test_sync(test); +} + +BOOST_AUTO_TEST_CASE( pub_sub_prop ) { + using namespace std::literals::string_literals; + auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { + auto& c = cs[0]; + clear_ordered(); + if (c->get_protocol_version() != MQTT_NS::protocol_version::v5) { + finish(); + return; + } + + using packet_id_t = typename std::remove_reference_t::packet_id_t; + c->set_client_id("cid1"); + c->set_clean_session(true); + + packet_id_t pid_sub; + packet_id_t pid_unsub; + + checker chk = { + // connect + cont("h_connack"), + // subscribe topic1 QoS0 + cont("h_suback"), + // publish topic1 QoS0 + cont("h_publish"), + cont("h_unsuback"), + // disconnect + cont("h_close"), + }; + MQTT_NS::v5::properties ps { + MQTT_NS::v5::property::payload_format_indicator(MQTT_NS::v5::property::payload_format_indicator::string), + MQTT_NS::v5::property::message_expiry_interval(0x12345678UL), + MQTT_NS::v5::property::content_type("content type"_mb), + MQTT_NS::v5::property::topic_alias(0x1234U), + MQTT_NS::v5::property::response_topic("response topic"_mb), + MQTT_NS::v5::property::correlation_data("correlation \0data"_mb), + MQTT_NS::v5::property::user_property("key1"_mb, "val1"_mb), + MQTT_NS::v5::property::user_property("key2"_mb, "val2"_mb), + }; + + auto prop_size = ps.size(); + std::size_t user_prop_count = 0; + + c->set_v5_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); + pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); + }); + c->set_v5_puback_handler( + [] + (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubrec_handler( + [] + (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubcomp_handler( + [] + (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_suback_handler( + [&chk, &c, &pid_sub, ps = MQTT_NS::force_move(ps)] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) mutable { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); + c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once | MQTT_NS::retain::no, MQTT_NS::force_move(ps)); + }); + c->set_v5_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); + c->disconnect(); + }); + c->set_v5_publish_handler( + [&chk, &c, &pid_unsub, &user_prop_count, prop_size] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents, + MQTT_NS::v5::properties props) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_most_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_CHECK(!packet_id); + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + + // -1 means TopicAlias + // TopicAlias is not forwarded + // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901113 + // A receiver MUST NOT carry forward any Topic Alias mappings from + // one Network Connection to another [MQTT-3.3.2-7]. + BOOST_TEST(props.size() == prop_size - 1); + + for (auto const& p : props) { + MQTT_NS::visit( + MQTT_NS::make_lambda_visitor( + [&](MQTT_NS::v5::property::payload_format_indicator const& t) { + BOOST_TEST(t.val() == MQTT_NS::v5::property::payload_format_indicator::string); + }, + [&](MQTT_NS::v5::property::content_type const& t) { + BOOST_TEST(t.val() == "content type"); + }, + [&](MQTT_NS::v5::property::message_expiry_interval const& t) { + BOOST_TEST(t.val() == 0x12345678UL); + }, + [&](MQTT_NS::v5::property::response_topic const& t) { + BOOST_TEST(t.val() == "response topic"); + }, + [&](MQTT_NS::v5::property::correlation_data const& t) { + BOOST_TEST(t.val() == std::string("correlation \0data"s)); + }, + [&](MQTT_NS::v5::property::user_property const& t) { + switch (user_prop_count++) { + case 0: + BOOST_TEST(t.key() == "key1"); + BOOST_TEST(t.val() == "val1"); + break; + case 1: + BOOST_TEST(t.key() == "key2"); + BOOST_TEST(t.val() == "val2"); + break; + default: + BOOST_TEST(false); + break; + } + }, + [&](auto&& ...) { + BOOST_TEST(false); + } + ), + p + ); + } + + pid_unsub = c->unsubscribe("topic1"); + }); + c->set_close_handler( + [&chk, &finish] + () { + MQTT_CHK("h_close"); + finish(); + }); + c->set_error_handler( + [] + (MQTT_NS::error_code) { + BOOST_CHECK(false); + }); + c->set_pub_res_sent_handler( + [] + (packet_id_t) { + BOOST_CHECK(false); + }); + c->connect(); + ioc.run(); + BOOST_TEST(chk.all()); + }; + do_combi_test_sync(test); +} + +BOOST_AUTO_TEST_CASE( puback_prop ) { + auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& b) { + auto& c = cs[0]; + clear_ordered(); + if (c->get_protocol_version() != MQTT_NS::protocol_version::v5) { + finish(); + return; + } + + using packet_id_t = typename std::remove_reference_t::packet_id_t; + c->set_client_id("cid1"); + c->set_clean_session(true); + + packet_id_t pid_pub; + packet_id_t pid_sub; + packet_id_t pid_unsub; + + bool pub_seq_finished = false; + + + checker chk = { + // connect + cont("h_connack"), + // subscribe topic1 QoS0 + cont("h_suback"), + // publish topic1 QoS1 + cont("h_publish"), + cont("h_pub_res_sent"), + cont("h_puback"), + cont("h_unsuback"), + // disconnect + cont("h_close"), + }; + + MQTT_NS::v5::properties pubackps { + MQTT_NS::v5::property::reason_string("test success"_mb), + MQTT_NS::v5::property::user_property("key1"_mb, "val1"_mb), + MQTT_NS::v5::property::user_property("key2"_mb, "val2"_mb), + }; + auto puback_prop_size = pubackps.size(); + b.set_puback_props(MQTT_NS::force_move(pubackps)); + std::size_t puback_user_prop_count = 0; + + MQTT_NS::optional recv_packet_id; + c->set_pub_res_sent_handler( + [&chk, &recv_packet_id] + (packet_id_t packet_id) { + MQTT_CHK("h_pub_res_sent"); + BOOST_TEST(*recv_packet_id == packet_id); + }); + + c->set_v5_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); + pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); + }); + c->set_v5_puback_handler( + [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub, puback_prop_size, &puback_user_prop_count] + (packet_id_t packet_id, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties props) { + MQTT_CHK("h_puback"); + BOOST_TEST(packet_id == pid_pub); + pub_seq_finished = true; + + BOOST_TEST(props.size() == puback_prop_size); + for (auto const& p : props) { + MQTT_NS::visit( + MQTT_NS::make_lambda_visitor( + [&](MQTT_NS::v5::property::reason_string const& t) { + BOOST_TEST(t.val() == "test success"); + }, + [&](MQTT_NS::v5::property::user_property const& t) { + switch (puback_user_prop_count++) { + case 0: + BOOST_TEST(t.key() == "key1"); + BOOST_TEST(t.val() == "val1"); + break; + case 1: + BOOST_TEST(t.key() == "key2"); + BOOST_TEST(t.val() == "val2"); + break; + default: + BOOST_TEST(false); + break; + } + }, + [&](auto&& ...) { + BOOST_TEST(false); + } + ), + p + ); + } + + pid_unsub = c->unsubscribe("topic1"); + }); + c->set_v5_pubrec_handler( + [] + (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubcomp_handler( + [] + (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_suback_handler( + [&chk, &c, &pid_sub, &pid_pub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_1); + pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); + }); + c->set_v5_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); + c->disconnect(); + }); + c->set_v5_publish_handler( + [&chk, &recv_packet_id] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents, + MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::at_least_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_TEST(*packet_id != 0); + recv_packet_id = packet_id; + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + }); + c->set_close_handler( + [&chk, &finish] + () { + MQTT_CHK("h_close"); + finish(); + }); + c->set_error_handler( + [] + (MQTT_NS::error_code) { + BOOST_CHECK(false); + }); + c->connect(); + ioc.run(); + BOOST_TEST(chk.all()); + }; + do_combi_test_sync(test); +} + +BOOST_AUTO_TEST_CASE( pubrec_rel_comp_prop ) { + auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& b) { + auto& c = cs[0]; + clear_ordered(); + if (c->get_protocol_version() != MQTT_NS::protocol_version::v5) { + finish(); + return; + } + + using packet_id_t = typename std::remove_reference_t::packet_id_t; + c->set_client_id("cid1"); + c->set_clean_session(true); + c->set_auto_pub_response(false); + + packet_id_t pid_pub; + packet_id_t pid_sub; + packet_id_t pid_unsub; + + bool pub_seq_finished = false; + + + checker chk = { + // connect + cont("h_connack"), + // subscribe topic1 QoS0 + cont("h_suback"), + // publish topic1 QoS2 + cont("h_publish"), + cont("h_pubrec"), + cont("h_pub_res_sent"), + cont("h_pubcomp"), + cont("h_unsuback"), + // disconnect + cont("h_close"), + }; + + MQTT_NS::v5::properties pubrecps { + MQTT_NS::v5::property::reason_string("test success"_mb), + MQTT_NS::v5::property::user_property("key1"_mb, "val1"_mb), + MQTT_NS::v5::property::user_property("key2"_mb, "val2"_mb), + }; + auto pubrec_prop_size = pubrecps.size(); + b.set_pubrec_props(MQTT_NS::force_move(pubrecps)); + std::size_t pubrec_user_prop_count = 0; + + MQTT_NS::v5::properties pubrelps { + MQTT_NS::v5::property::reason_string("test success"_mb), + MQTT_NS::v5::property::user_property("key1"_mb, "val1"_mb), + MQTT_NS::v5::property::user_property("key2"_mb, "val2"_mb), + }; + std::size_t pubrel_user_prop_count = 0; + + MQTT_NS::v5::properties pubcompps { + MQTT_NS::v5::property::reason_string("test success"_mb), + MQTT_NS::v5::property::user_property("key1"_mb, "val1"_mb), + MQTT_NS::v5::property::user_property("key2"_mb, "val2"_mb), + }; + auto pubcomp_prop_size = pubcompps.size(); + b.set_pubcomp_props(MQTT_NS::force_move(pubcompps)); + std::size_t pubcomp_user_prop_count = 0; + + b.set_pubrel_props_handler( + [&pubrel_user_prop_count, size = pubrelps.size()] (MQTT_NS::v5::properties const& props) { + BOOST_TEST(props.size() == size); + for (auto const& p : props) { + MQTT_NS::visit( + MQTT_NS::make_lambda_visitor( + [&](MQTT_NS::v5::property::reason_string const& t) { + BOOST_TEST(t.val() == "test success"); + }, + [&](MQTT_NS::v5::property::user_property const& t) { + switch (pubrel_user_prop_count++) { + case 0: + BOOST_TEST(t.key() == "key1"); + BOOST_TEST(t.val() == "val1"); + break; + case 1: + BOOST_TEST(t.key() == "key2"); + BOOST_TEST(t.val() == "val2"); + break; + default: + BOOST_TEST(false); + break; + } + }, + [&](auto&& ...) { + BOOST_TEST(false); + } + ), + p + ); + } + } + ); + + MQTT_NS::optional recv_packet_id; + c->set_pub_res_sent_handler( + [&chk, &recv_packet_id] + (packet_id_t packet_id) { + MQTT_CHK("h_pub_res_sent"); + BOOST_TEST(*recv_packet_id == packet_id); + }); + + c->set_v5_connack_handler( + [&chk, &c, &pid_sub] + (bool sp, MQTT_NS::v5::connect_reason_code connack_return_code, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_connack"); + BOOST_TEST(sp == false); + BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); + pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); + }); + c->set_v5_puback_handler( + [] + (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { + BOOST_CHECK(false); + }); + c->set_v5_pubrec_handler( + [&chk, &c, &pid_pub, pubrec_prop_size, &pubrec_user_prop_count, pubrelps = MQTT_NS::force_move(pubrelps)] + (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties props) mutable { + MQTT_CHK("h_pubrec"); + BOOST_TEST(packet_id == pid_pub); + + BOOST_TEST(props.size() == pubrec_prop_size); + for (auto const& p : props) { + MQTT_NS::visit( + MQTT_NS::make_lambda_visitor( + [&](MQTT_NS::v5::property::reason_string const& t) { + BOOST_TEST(t.val() == "test success"); + }, + [&](MQTT_NS::v5::property::user_property const& t) { + switch (pubrec_user_prop_count++) { + case 0: + BOOST_TEST(t.key() == "key1"); + BOOST_TEST(t.val() == "val1"); + break; + case 1: + BOOST_TEST(t.key() == "key2"); + BOOST_TEST(t.val() == "val2"); + break; + default: + BOOST_TEST(false); + break; + } + }, + [&](auto&& ...) { + BOOST_TEST(false); + } + ), + p + ); + } + + c->pubrel(packet_id, MQTT_NS::v5::pubrel_reason_code::success, MQTT_NS::force_move(pubrelps)); + + }); + c->set_v5_pubcomp_handler( + [&chk, &c, &pub_seq_finished, &pid_pub, &pid_unsub, pubcomp_prop_size, &pubcomp_user_prop_count] + (packet_id_t packet_id, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties props) { + MQTT_CHK("h_pubcomp"); + BOOST_TEST(packet_id == pid_pub); + + BOOST_TEST(props.size() == pubcomp_prop_size); + for (auto const& p : props) { + MQTT_NS::visit( + MQTT_NS::make_lambda_visitor( + [&](MQTT_NS::v5::property::reason_string const& t) { + BOOST_TEST(t.val() == "test success"); + }, + [&](MQTT_NS::v5::property::user_property const& t) { + switch (pubcomp_user_prop_count++) { + case 0: + BOOST_TEST(t.key() == "key1"); + BOOST_TEST(t.val() == "val1"); + break; + case 1: + BOOST_TEST(t.key() == "key2"); + BOOST_TEST(t.val() == "val2"); + break; + default: + BOOST_TEST(false); + break; + } + }, + [&](auto&& ...) { + BOOST_TEST(false); + } + ), + p + ); + } + + pub_seq_finished = true; + pid_unsub = c->unsubscribe("topic1"); + }); + c->set_v5_suback_handler( + [&chk, &c, &pid_sub, &pid_pub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_suback"); + BOOST_TEST(packet_id == pid_sub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); + pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); + }); + c->set_v5_unsuback_handler( + [&chk, &c, &pid_unsub] + (packet_id_t packet_id, std::vector reasons, MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_unsuback"); + BOOST_TEST(packet_id == pid_unsub); + BOOST_TEST(reasons.size() == 1U); + BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); + c->disconnect(); + }); + c->set_v5_publish_handler( + [&chk, &c, &recv_packet_id] + (MQTT_NS::optional packet_id, + MQTT_NS::publish_options pubopts, + MQTT_NS::buffer topic, + MQTT_NS::buffer contents, + MQTT_NS::v5::properties /*props*/) { + MQTT_CHK("h_publish"); + BOOST_TEST(pubopts.get_dup() == MQTT_NS::dup::no); + BOOST_TEST(pubopts.get_qos() == MQTT_NS::qos::exactly_once); + BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::no); + BOOST_TEST(*packet_id != 0); + recv_packet_id = packet_id; + BOOST_TEST(topic == "topic1"); + BOOST_TEST(contents == "topic1_contents"); + c->pubrec(*packet_id, MQTT_NS::v5::pubrec_reason_code::success, {}); + }); + c->set_v5_pubrel_handler( + [&c] + (packet_id_t packet_id, MQTT_NS::v5::pubrel_reason_code, MQTT_NS::v5::properties /*props*/) { + c->pubcomp(packet_id, MQTT_NS::v5::pubcomp_reason_code::success, {}); + }); + c->set_close_handler( + [&chk, &finish] + () { + MQTT_CHK("h_close"); + finish(); + }); + c->set_error_handler( + [] + (MQTT_NS::error_code) { + BOOST_CHECK(false); + }); + c->connect(); + ioc.run(); + BOOST_TEST(chk.all()); + }; + do_combi_test_sync(test); +} + BOOST_AUTO_TEST_CASE( pub_sub_wc_plus ) { auto test = [](boost::asio::io_context& ioc, auto& cs, auto finish, auto& /*b*/) { auto& c = cs[0]; @@ -48,25 +1500,21 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_plus ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("a/+/b", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -76,7 +1524,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_plus ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("a/topic1/b", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -84,7 +1531,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_plus ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -100,7 +1546,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_plus ) { BOOST_TEST(topic == "a/topic1/b"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("a/+/b"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -111,25 +1556,21 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_plus ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("a/+/b", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -139,7 +1580,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_plus ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c->publish("a/topic1/b", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -149,7 +1589,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_plus ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -166,7 +1605,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_plus ) { BOOST_TEST(topic == "a/topic1/b"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("a/+/b"); - return true; }); break; default: @@ -229,25 +1667,21 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_sharp ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("a/#", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (packet_id_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -257,7 +1691,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_sharp ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("a/topic1/b", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -265,7 +1698,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_sharp ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -281,7 +1713,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_sharp ) { BOOST_TEST(topic == "a/topic1/b"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("a/#"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -292,25 +1723,21 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_sharp ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("a/#", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -320,7 +1747,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_sharp ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c->publish("a/topic1/b", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -330,7 +1756,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_sharp ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -347,7 +1772,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_wc_sharp ) { BOOST_TEST(topic == "a/topic1/b"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("a/#"); - return true; }); break; default: @@ -412,7 +1836,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_sid ) { "topic1", MQTT_NS::qos::at_most_once, MQTT_NS::v5::properties{ MQTT_NS::v5::property::subscription_identifier(123) } ); - return true; }); c->set_v5_suback_handler( [&] @@ -421,7 +1844,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_sid ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_publish_handler( [&] @@ -447,7 +1869,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_sid ) { ); } c->disconnect(); - return true; }); c->set_close_handler( [&] @@ -507,7 +1928,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_sid_ow ) { "topic1", MQTT_NS::qos::at_most_once, MQTT_NS::v5::properties{ MQTT_NS::v5::property::subscription_identifier(456) } ); - return true; }); c->set_v5_suback_handler( [&] @@ -526,7 +1946,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_sid_ow ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_publish_handler( [&] @@ -552,7 +1971,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_sid_ow ) { ); } c->disconnect(); - return true; }); c->set_close_handler( [&] @@ -613,7 +2031,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_sid_multi_match ) { "a/#", MQTT_NS::qos::at_most_once, MQTT_NS::v5::properties{ MQTT_NS::v5::property::subscription_identifier(456) } ); - return true; }); c->set_v5_suback_handler( [&] @@ -632,7 +2049,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_sid_multi_match ) { } ); BOOST_TEST(ret); - return true; }); std::set sids { 123, 456 }; @@ -684,7 +2100,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_sid_multi_match ) { } ); BOOST_TEST(ret); - return true; }); c->set_close_handler( [&] diff --git a/test/system/st_pubsub_no_strand.cpp b/test/system/st_pubsub_no_strand.cpp index 500f68f42..73211f42b 100644 --- a/test/system/st_pubsub_no_strand.cpp +++ b/test/system/st_pubsub_no_strand.cpp @@ -71,7 +71,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -88,19 +87,16 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -110,7 +106,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -118,7 +113,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -134,7 +128,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos0 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->connect(); ioc.run(); @@ -197,7 +190,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -216,19 +208,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_pub, &pid_sub] @@ -238,7 +227,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -246,7 +234,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -261,7 +248,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos0 ) { BOOST_TEST(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); c->connect(); ioc.run(); @@ -324,7 +310,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -341,14 +326,12 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_unsub, &pid_pub] @@ -356,7 +339,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_suback_handler( [&chk, &c, &pid_pub] @@ -366,7 +348,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -374,7 +355,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk] @@ -389,7 +369,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos0 ) { BOOST_CHECK(!packet_id); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); c->connect(); ioc.run(); @@ -449,7 +428,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -466,19 +444,16 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -488,7 +463,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -496,7 +470,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -512,7 +485,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos1 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->connect(); ioc.run(); @@ -575,7 +547,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -594,19 +565,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); MQTT_NS::optional recv_packet_id; c->set_pub_res_sent_handler( @@ -623,7 +591,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -631,7 +598,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -647,7 +613,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); c->connect(); ioc.run(); @@ -711,7 +676,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -728,14 +692,12 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -743,7 +705,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); pid_unsub = c->unsubscribe("topic1"); - return true; }); MQTT_NS::optional recv_packet_id; c->set_pub_res_sent_handler( @@ -760,7 +721,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -768,7 +728,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -784,7 +743,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos1 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); c->connect(); ioc.run(); @@ -845,7 +803,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -862,19 +819,16 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -884,7 +838,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -892,7 +845,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -908,7 +860,6 @@ BOOST_AUTO_TEST_CASE( pub_qos0_sub_qos2 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->connect(); ioc.run(); @@ -972,7 +923,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -991,19 +941,16 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); MQTT_NS::optional recv_packet_id; c->set_pub_res_sent_handler( @@ -1020,7 +967,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1028,7 +974,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -1044,7 +989,6 @@ BOOST_AUTO_TEST_CASE( pub_qos1_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); c->connect(); ioc.run(); @@ -1109,7 +1053,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -1126,14 +1069,12 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_pub, &pid_unsub] @@ -1141,7 +1082,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); pid_unsub = c->unsubscribe("topic1"); - return true; }); MQTT_NS::optional recv_packet_id; c->set_pub_res_sent_handler( @@ -1158,7 +1098,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); pid_pub = c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1166,7 +1105,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &recv_packet_id] @@ -1182,7 +1120,6 @@ BOOST_AUTO_TEST_CASE( pub_qos2_sub_qos2 ) { recv_packet_id = packet_id; BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); - return true; }); c->connect(); ioc.run(); @@ -1243,7 +1180,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -1260,19 +1196,16 @@ BOOST_AUTO_TEST_CASE( publish_function ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -1282,7 +1215,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1290,7 +1222,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -1306,7 +1237,6 @@ BOOST_AUTO_TEST_CASE( publish_function ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->connect(); ioc.run(); diff --git a/test/system/st_receive_maximum.cpp b/test/system/st_receive_maximum.cpp index ae853c6e0..6b90ed369 100644 --- a/test/system/st_receive_maximum.cpp +++ b/test/system/st_receive_maximum.cpp @@ -60,7 +60,6 @@ BOOST_AUTO_TEST_CASE( sync ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -86,7 +85,6 @@ BOOST_AUTO_TEST_CASE( sync ) { "message3", MQTT_NS::qos::at_least_once ); - return true; }); c->set_v5_publish_handler( [&chk, &c] @@ -126,12 +124,10 @@ BOOST_AUTO_TEST_CASE( sync ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { - return true; }); c->set_close_handler( @@ -189,7 +185,6 @@ BOOST_AUTO_TEST_CASE( sync_manual_pubrel ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->pubrel(1); - return true; }); c->set_v5_pubcomp_handler( [&] @@ -197,7 +192,6 @@ BOOST_AUTO_TEST_CASE( sync_manual_pubrel ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c->disconnect(); - return true; } ); c->set_close_handler( @@ -255,7 +249,6 @@ BOOST_AUTO_TEST_CASE( async_manual_pubrel ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->async_pubrel(1); - return true; }); c->set_v5_pubcomp_handler( [&] @@ -263,7 +256,6 @@ BOOST_AUTO_TEST_CASE( async_manual_pubrel ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c->async_disconnect(); - return true; } ); c->set_close_handler( diff --git a/test/system/st_remaining_length.cpp b/test/system/st_remaining_length.cpp index f5fb7f949..27a7899c1 100644 --- a/test/system/st_remaining_length.cpp +++ b/test/system/st_remaining_length.cpp @@ -55,7 +55,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_127 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -72,19 +71,16 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_127 ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &test_contents] @@ -94,7 +90,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_127 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("topic1", test_contents, MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -102,7 +97,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_127 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub, &test_contents] @@ -118,7 +112,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_127 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == test_contents); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->connect(); ioc.run(); @@ -168,7 +161,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_16384 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -185,19 +177,16 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_16384 ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &test_contents] @@ -207,7 +196,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_16384 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("topic1", test_contents, MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -215,7 +203,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_16384 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub, &test_contents] @@ -231,7 +218,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_16384 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == test_contents); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->connect(); ioc.run(); @@ -283,7 +269,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_2097152 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_close_handler( [&chk, &finish] @@ -300,19 +285,16 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_2097152 ) { [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub, &test_contents] @@ -322,7 +304,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_2097152 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->publish("topic1", test_contents, MQTT_NS::qos::at_most_once); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -330,7 +311,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_2097152 ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub, &test_contents] @@ -346,7 +326,6 @@ BOOST_AUTO_TEST_CASE( pub_sub_over_2097152 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == test_contents); pid_unsub = c->unsubscribe("topic1"); - return true; }); c->connect(); ioc.run(); diff --git a/test/system/st_reqres.cpp b/test/system/st_reqres.cpp index 213b31c70..cbc2806fd 100644 --- a/test/system/st_reqres.cpp +++ b/test/system/st_reqres.cpp @@ -59,7 +59,6 @@ BOOST_AUTO_TEST_CASE( pubsub ) { BOOST_TEST(times == 1); c->subscribe(response_topic, MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_suback_handler( [&] @@ -71,7 +70,6 @@ BOOST_AUTO_TEST_CASE( pubsub ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c->publish(response_topic, "response_contents", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_publish_handler( [&] @@ -84,7 +82,6 @@ BOOST_AUTO_TEST_CASE( pubsub ) { BOOST_TEST(topic == response_topic); BOOST_TEST(contents == "response_contents"); c->disconnect(); - return true; }); c->set_close_handler( [&] @@ -197,7 +194,6 @@ BOOST_AUTO_TEST_CASE( session ) { ); BOOST_TEST(ret); c->disconnect(); - return true; }); c->set_close_handler( [&] @@ -353,7 +349,6 @@ BOOST_AUTO_TEST_CASE( retain ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_suback_handler( [&] @@ -375,7 +370,6 @@ BOOST_AUTO_TEST_CASE( retain ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_publish_handler( [&] @@ -389,7 +383,6 @@ BOOST_AUTO_TEST_CASE( retain ) { BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::yes); BOOST_TEST(contents == "response_contents"); c->disconnect(); - return true; }); c->set_close_handler( [&] diff --git a/test/system/st_resend.cpp b/test/system/st_resend.cpp index 6e8ead061..057c958a3 100644 --- a/test/system/st_resend.cpp +++ b/test/system/st_resend.cpp @@ -135,7 +135,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c->set_puback_handler( [&chk, &c, &pid_pub] @@ -143,7 +142,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -171,7 +169,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub] @@ -179,7 +176,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); - return true; }); break; default: @@ -284,14 +280,12 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_pub] @@ -299,7 +293,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -327,14 +320,12 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_pub] @@ -342,7 +333,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); - return true; }); break; default: @@ -495,7 +485,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c->set_pubrec_handler( [&chk, &c, &pid_pub] @@ -503,7 +492,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); c->force_disconnect(); - return true; }); c->set_pubcomp_handler( [&chk, &c] @@ -511,7 +499,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -539,7 +526,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_pubrec_handler( [&chk, &c, &pid_pub, ps = std::move(ps)] @@ -548,7 +534,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { BOOST_TEST(packet_id == pid_pub); c->pubrel(packet_id, MQTT_NS::v5::pubrel_reason_code::success, std::move(ps)); c->force_disconnect(); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c] @@ -556,7 +541,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c->disconnect(); - return true; }); break; default: @@ -669,7 +653,6 @@ BOOST_AUTO_TEST_CASE( publish_pubrel_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c->set_pubrec_handler( [&chk, &c, &pid_pub] @@ -677,7 +660,6 @@ BOOST_AUTO_TEST_CASE( publish_pubrel_qos2 ) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); c->force_disconnect(); - return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_pub] @@ -685,7 +667,6 @@ BOOST_AUTO_TEST_CASE( publish_pubrel_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -717,7 +698,6 @@ BOOST_AUTO_TEST_CASE( publish_pubrel_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_pubrec_handler( [&chk, &c, &pid_pub] @@ -725,7 +705,6 @@ BOOST_AUTO_TEST_CASE( publish_pubrel_qos2 ) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); c->force_disconnect(); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_pub] @@ -733,7 +712,6 @@ BOOST_AUTO_TEST_CASE( publish_pubrel_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); - return true; }); break; default: @@ -863,7 +841,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_from_broker ) { } ); BOOST_TEST(ret); - return true; }); c->set_suback_handler( [&chk, &c] @@ -872,7 +849,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_from_broker ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; } ); c->set_publish_handler( @@ -909,7 +885,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_from_broker ) { } ); BOOST_TEST(ret); - return true; } ); c->set_puback_handler( @@ -919,7 +894,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_from_broker ) { if (chk.passed("h_publish1")) { c->force_disconnect(); } - return true; } ); break; @@ -947,7 +921,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_from_broker ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -957,7 +930,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_from_broker ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::at_least_once); - return true; } ); c->set_v5_publish_handler( @@ -995,7 +967,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_from_broker ) { } ); BOOST_TEST(ret); - return true; } ); c->set_v5_puback_handler( @@ -1005,7 +976,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_from_broker ) { if (chk.passed("h_publish1")) { c->force_disconnect(); } - return true; } ); break; @@ -1114,7 +1084,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_from_broker ) { } ); BOOST_TEST(ret); - return true; } ); c->set_suback_handler( @@ -1124,7 +1093,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_from_broker ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; } ); c->set_publish_handler( @@ -1144,7 +1112,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_from_broker ) { if (chk.passed("h_pubcomp")) { c->force_disconnect(); } - return true; } ); c->set_pubrec_handler( @@ -1152,7 +1119,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_from_broker ) { (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); c->pubrel(packet_id); - return true; } ); c->set_pubcomp_handler( @@ -1162,7 +1128,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_from_broker ) { if (chk.passed("h_publish1")) { c->force_disconnect(); } - return true; } ); break; @@ -1191,7 +1156,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_from_broker ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -1201,7 +1165,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_from_broker ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; } ); c->set_v5_publish_handler( @@ -1222,7 +1185,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_from_broker ) { if (chk.passed("h_pubcomp")) { c->force_disconnect(); } - return true; } ); c->set_v5_pubrec_handler( @@ -1230,7 +1192,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_from_broker ) { (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); c->pubrel(packet_id); - return true; }); c->set_v5_pubcomp_handler( [&chk, &c] @@ -1239,7 +1200,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_from_broker ) { if (chk.passed("h_publish1")) { c->force_disconnect(); } - return true; }); break; default: @@ -1348,7 +1308,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { } ); BOOST_TEST(ret); - return true; }); c->set_suback_handler( [&chk, &c] @@ -1357,7 +1316,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; } ); c->set_publish_handler( @@ -1375,7 +1333,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); c->pubrec(packet_id.value()); - return true; } ); c->set_pubrec_handler( @@ -1383,7 +1340,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); c->pubrel(packet_id); - return true; } ); c->set_pubrel_handler( @@ -1405,7 +1361,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { } ); BOOST_TEST(ret); - return true; } ); c->set_pubcomp_handler( @@ -1415,7 +1370,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { if (chk.passed("h_publish")) { c->force_disconnect(); } - return true; } ); break; @@ -1444,7 +1398,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { } ); BOOST_TEST(ret); - return true; } ); c->set_v5_suback_handler( @@ -1454,7 +1407,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_2); c->publish("topic1", "topic1_contents", MQTT_NS::qos::exactly_once); - return true; } ); c->set_v5_publish_handler( @@ -1473,7 +1425,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "topic1_contents"); c->pubrec(packet_id.value()); - return true; } ); c->set_v5_pubrec_handler( @@ -1481,7 +1432,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); c->pubrel(packet_id); - return true; } ); c->set_v5_pubrel_handler( @@ -1503,7 +1453,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { } ); BOOST_TEST(ret); - return true; } ); c->set_v5_pubcomp_handler( @@ -1513,7 +1462,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_from_broker ) { if (chk.passed("h_publish")) { c->force_disconnect(); } - return true; } ); break; @@ -1626,7 +1574,6 @@ BOOST_AUTO_TEST_CASE( publish_message_expired_from_broker ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -1641,7 +1588,6 @@ BOOST_AUTO_TEST_CASE( publish_message_expired_from_broker ) { MQTT_NS::qos::at_least_once, MQTT_NS::v5::properties { MQTT_NS::v5::property::message_expiry_interval(1) } ); - return true; } ); c->set_v5_publish_handler( @@ -1662,7 +1608,6 @@ BOOST_AUTO_TEST_CASE( publish_message_expired_from_broker ) { if (chk.passed("h_puback")) { c->force_disconnect(); } - return true; } ); c->set_v5_puback_handler( @@ -1672,7 +1617,6 @@ BOOST_AUTO_TEST_CASE( publish_message_expired_from_broker ) { if (chk.passed("h_publish")) { c->force_disconnect(); } - return true; } ); @@ -1773,7 +1717,6 @@ BOOST_AUTO_TEST_CASE( publish_message_expiry_update_from_broker ) { } ); BOOST_TEST(ret); - return true; } ); c->set_v5_suback_handler( @@ -1789,7 +1732,6 @@ BOOST_AUTO_TEST_CASE( publish_message_expiry_update_from_broker ) { MQTT_NS::qos::at_least_once, MQTT_NS::v5::properties { MQTT_NS::v5::property::message_expiry_interval(5) } ); - return true; } ); c->set_v5_publish_handler( @@ -1841,7 +1783,6 @@ BOOST_AUTO_TEST_CASE( publish_message_expiry_update_from_broker ) { } ); BOOST_TEST(ret); - return true; } ); c->set_v5_puback_handler( @@ -1851,7 +1792,6 @@ BOOST_AUTO_TEST_CASE( publish_message_expiry_update_from_broker ) { if (chk.passed("h_publish1")) { c->force_disconnect(); } - return true; } ); @@ -1948,7 +1888,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c->set_puback_handler( [&chk, &c, &pid_pub1, &pid_pub2] @@ -1965,7 +1904,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -1994,7 +1932,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub1, &pid_pub2] @@ -2011,7 +1948,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); break; default: @@ -2122,7 +2058,6 @@ BOOST_AUTO_TEST_CASE( publish_session_before_expire ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub] @@ -2130,7 +2065,6 @@ BOOST_AUTO_TEST_CASE( publish_session_before_expire ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); - return true; }); break; default: @@ -2253,13 +2187,11 @@ BOOST_AUTO_TEST_CASE( publish_session_after_expire ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_TEST(false); - return true; }); break; default: diff --git a/test/system/st_resend_new_client.cpp b/test/system/st_resend_new_client.cpp index 9bcea6b9f..bd4c076be 100644 --- a/test/system/st_resend_new_client.cpp +++ b/test/system/st_resend_new_client.cpp @@ -90,7 +90,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -131,7 +130,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -145,7 +143,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); @@ -229,7 +226,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -270,7 +266,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -283,7 +278,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { (MQTT_NS::broker::packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c2->set_pubcomp_handler( [&chk, &c2, &pid_pub] @@ -291,7 +285,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -373,7 +366,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -413,7 +405,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); c1->force_disconnect(); - return true; }); c2->set_connack_handler( @@ -422,7 +413,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -436,7 +426,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -522,7 +511,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -562,7 +550,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -585,7 +572,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -736,7 +722,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -777,7 +762,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -791,7 +775,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_v5 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); @@ -877,7 +860,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -918,7 +900,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -931,7 +912,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { (MQTT_NS::broker::packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c2->set_v5_pubcomp_handler( [&chk, &c2, &pid_pub] @@ -939,7 +919,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -1073,7 +1052,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -1114,7 +1092,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { BOOST_TEST(packet_id == pid_pub); c1->pubrel(packet_id, MQTT_NS::v5::pubrel_reason_code::success, std::move(ps)); c1->force_disconnect(); - return true; }); c2->set_v5_connack_handler( @@ -1123,7 +1100,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -1137,7 +1113,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -1225,7 +1200,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -1265,7 +1239,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -1288,7 +1261,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1_v5 ) { } ); BOOST_TEST(ret); - return true; }); MQTT_CHK("start"); c1->connect(); diff --git a/test/system/st_resend_serialize.cpp b/test/system/st_resend_serialize.cpp index f7b70a990..fe937ec25 100644 --- a/test/system/st_resend_serialize.cpp +++ b/test/system/st_resend_serialize.cpp @@ -182,7 +182,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -227,7 +226,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -241,7 +239,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); @@ -339,7 +336,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -384,7 +380,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -397,7 +392,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c2->set_pubcomp_handler( [&chk, &c2, &pid_pub] @@ -405,7 +399,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -501,7 +494,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -545,7 +537,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); c1->force_disconnect(); - return true; }); c2->set_connack_handler( @@ -554,7 +545,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -568,7 +558,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -668,7 +657,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -712,7 +700,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -735,7 +722,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -980,7 +966,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -1025,7 +1010,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -1039,7 +1023,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_v5 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); @@ -1139,7 +1122,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -1184,7 +1166,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -1197,7 +1178,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c2->set_v5_pubcomp_handler( [&chk, &c2, &pid_pub] @@ -1205,7 +1185,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -1353,7 +1332,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -1398,7 +1376,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { BOOST_TEST(packet_id == pid_pub); c1->pubrel(packet_id, MQTT_NS::v5::pubrel_reason_code::success, std::move(ps)); c1->force_disconnect(); - return true; }); c2->set_v5_connack_handler( @@ -1407,7 +1384,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -1421,7 +1397,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -1523,7 +1498,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -1567,7 +1541,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -1590,7 +1563,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1_v5 ) { } ); BOOST_TEST(ret); - return true; }); MQTT_CHK("start"); c1->connect(); diff --git a/test/system/st_resend_serialize_ptr_size.cpp b/test/system/st_resend_serialize_ptr_size.cpp index 8113abe8b..0c831962b 100644 --- a/test/system/st_resend_serialize_ptr_size.cpp +++ b/test/system/st_resend_serialize_ptr_size.cpp @@ -120,7 +120,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -157,7 +156,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -171,7 +169,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); @@ -263,7 +260,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -300,7 +296,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -313,7 +308,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c2->set_pubcomp_handler( [&chk, &c2, &pid_pub] @@ -321,7 +315,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -411,7 +404,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -447,7 +439,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); c1->force_disconnect(); - return true; }); c2->set_connack_handler( @@ -456,7 +447,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -470,7 +460,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -564,7 +553,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -600,7 +588,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -623,7 +610,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { } ); BOOST_TEST(ret); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -806,7 +792,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -843,7 +828,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -857,7 +841,6 @@ BOOST_AUTO_TEST_CASE( publish_qos1_v5 ) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); @@ -951,7 +934,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -988,7 +970,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -1001,7 +982,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { (packet_id_t packet_id, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); - return true; }); c2->set_v5_pubcomp_handler( [&chk, &c2, &pid_pub] @@ -1009,7 +989,6 @@ BOOST_AUTO_TEST_CASE( publish_qos2_v5 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -1151,7 +1130,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -1188,7 +1166,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { BOOST_TEST(packet_id == pid_pub); c1->pubrel(packet_id, MQTT_NS::v5::pubrel_reason_code::success, std::move(ps)); c1->force_disconnect(); - return true; }); c2->set_v5_connack_handler( @@ -1197,7 +1174,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -1211,7 +1187,6 @@ BOOST_AUTO_TEST_CASE( pubrel_qos2_v5 ) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c2->disconnect(); - return true; }); MQTT_CHK("start"); c1->connect(); @@ -1307,7 +1282,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1_v5 ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c1] @@ -1343,7 +1317,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1_v5 ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -1366,7 +1339,6 @@ BOOST_AUTO_TEST_CASE( multi_publish_qos1_v5 ) { } ); BOOST_TEST(ret); - return true; }); MQTT_CHK("start"); c1->connect(); diff --git a/test/system/st_retain_1.cpp b/test/system/st_retain_1.cpp index a11832640..e0053c309 100644 --- a/test/system/st_retain_1.cpp +++ b/test/system/st_retain_1.cpp @@ -52,25 +52,21 @@ BOOST_AUTO_TEST_CASE( simple ) { c->publish("topic1", "retained_contents", MQTT_NS::qos::at_most_once | MQTT_NS::retain::yes); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &pid_sub] @@ -79,7 +75,6 @@ BOOST_AUTO_TEST_CASE( simple ) { BOOST_TEST(packet_id == pid_sub); BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -87,7 +82,6 @@ BOOST_AUTO_TEST_CASE( simple ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -103,7 +97,6 @@ BOOST_AUTO_TEST_CASE( simple ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "retained_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -117,25 +110,21 @@ BOOST_AUTO_TEST_CASE( simple ) { c->publish("topic1", "retained_contents", MQTT_NS::qos::at_most_once | MQTT_NS::retain::yes); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &pid_sub] @@ -144,7 +133,6 @@ BOOST_AUTO_TEST_CASE( simple ) { BOOST_TEST(packet_id == pid_sub); BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -154,7 +142,6 @@ BOOST_AUTO_TEST_CASE( simple ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -171,7 +158,6 @@ BOOST_AUTO_TEST_CASE( simple ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "retained_contents"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; default: @@ -237,25 +223,21 @@ BOOST_AUTO_TEST_CASE( overwrite ) { c->publish("topic1", "retained_contents3", MQTT_NS::qos::at_most_once | MQTT_NS::retain::no); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &pid_sub] @@ -264,7 +246,6 @@ BOOST_AUTO_TEST_CASE( overwrite ) { BOOST_TEST(packet_id == pid_sub); BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_unsub] @@ -272,7 +253,6 @@ BOOST_AUTO_TEST_CASE( overwrite ) { MQTT_CHK("h_unsuback"); BOOST_TEST(packet_id == pid_unsub); c->disconnect(); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -288,7 +268,6 @@ BOOST_AUTO_TEST_CASE( overwrite ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "retained_contents2"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -304,25 +283,21 @@ BOOST_AUTO_TEST_CASE( overwrite ) { c->publish("topic1", "retained_contents3", MQTT_NS::qos::at_most_once | MQTT_NS::retain::no); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &pid_sub] @@ -331,7 +306,6 @@ BOOST_AUTO_TEST_CASE( overwrite ) { BOOST_TEST(packet_id == pid_sub); BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -341,7 +315,6 @@ BOOST_AUTO_TEST_CASE( overwrite ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -358,7 +331,6 @@ BOOST_AUTO_TEST_CASE( overwrite ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "retained_contents2"); pid_unsub = c->unsubscribe("topic1"); - return true; }); break; default: diff --git a/test/system/st_retain_2.cpp b/test/system/st_retain_2.cpp index 06a069349..9d0499bbc 100644 --- a/test/system/st_retain_2.cpp +++ b/test/system/st_retain_2.cpp @@ -55,25 +55,21 @@ BOOST_AUTO_TEST_CASE( retain_and_publish ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_puback_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubrec_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_pubcomp_handler( [] (std::uint16_t) { BOOST_CHECK(false); - return true; }); c->set_suback_handler( [&chk, &c, &pid_sub] @@ -91,7 +87,6 @@ BOOST_AUTO_TEST_CASE( retain_and_publish ) { } ); BOOST_TEST(ret); - return true; }); c->set_unsuback_handler( [&chk, &c, &pid_sub, &pid_unsub] @@ -108,7 +103,6 @@ BOOST_AUTO_TEST_CASE( retain_and_publish ) { } ); BOOST_TEST(ret); - return true; }); c->set_publish_handler( [&chk, &c, &pid_unsub] @@ -133,7 +127,6 @@ BOOST_AUTO_TEST_CASE( retain_and_publish ) { } ); BOOST_TEST(ret); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -144,25 +137,21 @@ BOOST_AUTO_TEST_CASE( retain_and_publish ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -180,7 +169,6 @@ BOOST_AUTO_TEST_CASE( retain_and_publish ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_sub, &pid_unsub] @@ -199,7 +187,6 @@ BOOST_AUTO_TEST_CASE( retain_and_publish ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -225,7 +212,6 @@ BOOST_AUTO_TEST_CASE( retain_and_publish ) { } ); BOOST_TEST(ret); - return true; }); break; default: @@ -299,25 +285,21 @@ BOOST_AUTO_TEST_CASE( retain_and_publish_timeout ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub, &pid_unsub, &timeout, message_timeout] @@ -349,7 +331,6 @@ BOOST_AUTO_TEST_CASE( retain_and_publish_timeout ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_sub, &pid_unsub, &timeout, message_timeout] @@ -376,7 +357,6 @@ BOOST_AUTO_TEST_CASE( retain_and_publish_timeout ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -402,7 +382,6 @@ BOOST_AUTO_TEST_CASE( retain_and_publish_timeout ) { } ); BOOST_TEST(ret); - return true; }); break; default: @@ -470,25 +449,21 @@ BOOST_AUTO_TEST_CASE( retain_rap ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once | MQTT_NS::rap::retain); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &pid_sub] @@ -506,7 +481,6 @@ BOOST_AUTO_TEST_CASE( retain_rap ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_sub, &pid_unsub] @@ -525,7 +499,6 @@ BOOST_AUTO_TEST_CASE( retain_rap ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub] @@ -551,7 +524,6 @@ BOOST_AUTO_TEST_CASE( retain_rap ) { } ); BOOST_TEST(ret); - return true; }); c->set_close_handler( @@ -612,25 +584,21 @@ BOOST_AUTO_TEST_CASE( retain_rh_send ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::at_most_once | MQTT_NS::rap::retain); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -650,7 +618,6 @@ BOOST_AUTO_TEST_CASE( retain_rh_send ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] @@ -675,7 +642,6 @@ BOOST_AUTO_TEST_CASE( retain_rh_send ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_publish_handler( [&chk, &c] @@ -706,7 +672,6 @@ BOOST_AUTO_TEST_CASE( retain_rh_send ) { } ); BOOST_TEST(ret); - return true; }); c->set_close_handler( @@ -766,25 +731,21 @@ BOOST_AUTO_TEST_CASE( retain_rh_only_newsub ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::at_most_once | MQTT_NS::rap::retain); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -804,7 +765,6 @@ BOOST_AUTO_TEST_CASE( retain_rh_only_newsub ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] @@ -829,7 +789,6 @@ BOOST_AUTO_TEST_CASE( retain_rh_only_newsub ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_publish_handler( [&chk, &c] @@ -855,7 +814,6 @@ BOOST_AUTO_TEST_CASE( retain_rh_only_newsub ) { } ); BOOST_TEST(ret); - return true; }); c->set_close_handler( @@ -914,25 +872,21 @@ BOOST_AUTO_TEST_CASE( retain_rh_not_send ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::at_most_once | MQTT_NS::rap::retain); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -953,7 +907,6 @@ BOOST_AUTO_TEST_CASE( retain_rh_not_send ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] @@ -978,7 +931,6 @@ BOOST_AUTO_TEST_CASE( retain_rh_not_send ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_publish_handler( [&chk, &c] @@ -995,7 +947,6 @@ BOOST_AUTO_TEST_CASE( retain_rh_not_send ) { c->unsubscribe("topic1"); MQTT_CHK("h_publish1"); BOOST_TEST(pubopts.get_retain() == MQTT_NS::retain::yes); - return true; }); c->set_close_handler( @@ -1068,25 +1019,21 @@ BOOST_AUTO_TEST_CASE( prop ) { c->publish("topic1", "retained_contents", MQTT_NS::qos::at_most_once | MQTT_NS::retain::yes, MQTT_NS::force_move(ps)); pid_sub = c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &pid_sub] @@ -1095,7 +1042,6 @@ BOOST_AUTO_TEST_CASE( prop ) { BOOST_TEST(packet_id == pid_sub); BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1105,7 +1051,6 @@ BOOST_AUTO_TEST_CASE( prop ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c, &pid_unsub, prop_size, &user_prop_count] @@ -1171,7 +1116,6 @@ BOOST_AUTO_TEST_CASE( prop ) { } pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_close_handler( [&chk, &finish] @@ -1233,25 +1177,21 @@ BOOST_AUTO_TEST_CASE( sid ) { "topic1", MQTT_NS::qos::at_most_once, MQTT_NS::v5::properties{ MQTT_NS::v5::property::subscription_identifier(123) } ); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &pid_sub] @@ -1260,7 +1200,6 @@ BOOST_AUTO_TEST_CASE( sid ) { BOOST_TEST(packet_id == pid_sub); BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &pid_unsub] @@ -1270,7 +1209,6 @@ BOOST_AUTO_TEST_CASE( sid ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&] @@ -1302,7 +1240,6 @@ BOOST_AUTO_TEST_CASE( sid ) { } pid_unsub = c->unsubscribe("topic1"); - return true; }); c->set_close_handler( [&chk, &finish] diff --git a/test/system/st_shared_sub.cpp b/test/system/st_shared_sub.cpp index 9a4219f2e..8b084dd70 100644 --- a/test/system/st_shared_sub.cpp +++ b/test/system/st_shared_sub.cpp @@ -97,7 +97,6 @@ BOOST_AUTO_TEST_CASE( qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); s1->connect(); - return true; } ); @@ -108,7 +107,6 @@ BOOST_AUTO_TEST_CASE( qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); s2->connect(); - return true; } ); @@ -119,7 +117,6 @@ BOOST_AUTO_TEST_CASE( qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); s3->connect(); - return true; } ); @@ -136,7 +133,6 @@ BOOST_AUTO_TEST_CASE( qos0 ) { {"$share/sn1/t2", MQTT_NS::qos::at_most_once} } ); - return true; } ); @@ -150,7 +146,6 @@ BOOST_AUTO_TEST_CASE( qos0 ) { s2->subscribe("$share/sn1/t2", MQTT_NS::qos::at_most_once); - return true; } ); @@ -167,7 +162,6 @@ BOOST_AUTO_TEST_CASE( qos0 ) { {"$share/sn1/t2", MQTT_NS::qos::at_most_once} } ); - return true; } ); @@ -188,7 +182,6 @@ BOOST_AUTO_TEST_CASE( qos0 ) { p1->publish("t1", "contents7", MQTT_NS::qos::at_most_once); p1->publish("t2", "contents8", MQTT_NS::qos::at_most_once); p1->disconnect(); - return true; } ); @@ -230,7 +223,6 @@ BOOST_AUTO_TEST_CASE( qos0 ) { } ); BOOST_TEST(ret); - return true; } ); @@ -263,7 +255,6 @@ BOOST_AUTO_TEST_CASE( qos0 ) { } ); BOOST_TEST(ret); - return true; } ); @@ -305,7 +296,6 @@ BOOST_AUTO_TEST_CASE( qos0 ) { } ); BOOST_TEST(ret); - return true; } ); @@ -434,7 +424,6 @@ BOOST_AUTO_TEST_CASE( unsub_target ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); s1->connect(); - return true; } ); @@ -445,7 +434,6 @@ BOOST_AUTO_TEST_CASE( unsub_target ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); s2->connect(); - return true; } ); @@ -456,7 +444,6 @@ BOOST_AUTO_TEST_CASE( unsub_target ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); s3->connect(); - return true; } ); @@ -469,7 +456,6 @@ BOOST_AUTO_TEST_CASE( unsub_target ) { s1->subscribe("$share/sn1/t1", MQTT_NS::qos::at_most_once); - return true; } ); @@ -482,7 +468,6 @@ BOOST_AUTO_TEST_CASE( unsub_target ) { s2->subscribe("$share/sn1/t2", MQTT_NS::qos::at_most_once); - return true; } ); @@ -495,7 +480,6 @@ BOOST_AUTO_TEST_CASE( unsub_target ) { s3->subscribe("$share/sn1/t1", MQTT_NS::qos::at_most_once); - return true; } ); @@ -508,7 +492,6 @@ BOOST_AUTO_TEST_CASE( unsub_target ) { p1->publish("t1", "contents1", MQTT_NS::qos::at_most_once); - return true; } ); @@ -527,7 +510,6 @@ BOOST_AUTO_TEST_CASE( unsub_target ) { BOOST_TEST(topic == "t1"); BOOST_TEST(contents == "contents1"); s2->unsubscribe("$share/sn1/t2"); - return true; } ); @@ -539,7 +521,6 @@ BOOST_AUTO_TEST_CASE( unsub_target ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); p1->publish("t1", "contents2", MQTT_NS::qos::at_most_once); - return true; } ); @@ -561,7 +542,6 @@ BOOST_AUTO_TEST_CASE( unsub_target ) { s1->disconnect(); s2->disconnect(); s3->disconnect(); - return true; } ); diff --git a/test/system/st_sub.cpp b/test/system/st_sub.cpp index a9d5b9b19..3200eb7b7 100644 --- a/test/system/st_sub.cpp +++ b/test/system/st_sub.cpp @@ -47,7 +47,6 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_single ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_suback_handler( [&chk, &c] @@ -56,14 +55,12 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_single ) { BOOST_TEST(results.size() == 1); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c->unsubscribe("topic1"); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -74,7 +71,6 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_single ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -83,7 +79,6 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_single ) { BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); MQTT_CHK("h_suback"); c->unsubscribe("topic1"); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] @@ -92,7 +87,6 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_single ) { BOOST_TEST(reasons.size() == 1); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); break; default: @@ -151,7 +145,6 @@ BOOST_AUTO_TEST_CASE( sub_update ) { c->subscribe("topic1", MQTT_NS::qos::at_most_once); c->subscribe("topic1", MQTT_NS::qos::at_least_once); c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_suback_handler( [&chk, &c] @@ -173,14 +166,12 @@ BOOST_AUTO_TEST_CASE( sub_update ) { } ); BOOST_TEST(ret); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -193,7 +184,6 @@ BOOST_AUTO_TEST_CASE( sub_update ) { c->subscribe("topic1", MQTT_NS::qos::at_most_once); c->subscribe("topic1", MQTT_NS::qos::at_least_once); c->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -215,7 +205,6 @@ BOOST_AUTO_TEST_CASE( sub_update ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] @@ -224,7 +213,6 @@ BOOST_AUTO_TEST_CASE( sub_update ) { BOOST_TEST(reasons.size() == 1); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); break; default: @@ -279,21 +267,18 @@ BOOST_AUTO_TEST_CASE( sub_v5_options ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_suback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*results*/) { MQTT_CHK("h_suback"); c->unsubscribe("topic1"); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -307,21 +292,18 @@ BOOST_AUTO_TEST_CASE( sub_v5_options ) { | MQTT_NS::rap::retain | MQTT_NS::qos::at_most_once | MQTT_NS::retain_handling::not_send); - return true; }); c->set_v5_suback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_suback"); c->unsubscribe("topic1"); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; default: @@ -382,21 +364,18 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_arg ) { {"topic2", MQTT_NS::qos::exactly_once} } ); - return true; }); c->set_suback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*results*/) { MQTT_CHK("h_suback"); c->unsubscribe( std::vector{ MQTT_NS::string_view{"topic1"}, MQTT_NS::string_view{"topic2"} } ); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -413,21 +392,18 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_arg ) { {"topic2", MQTT_NS::qos::exactly_once} } ); - return true; }); c->set_v5_suback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_suback"); c->unsubscribe( std::vector{ MQTT_NS::string_view{"topic1"}, MQTT_NS::string_view{"topic2"} }); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; default: @@ -485,7 +461,6 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_vec ) { v.emplace_back("topic1", MQTT_NS::qos::at_most_once); v.emplace_back("topic2", MQTT_NS::qos::exactly_once); c->subscribe(v); - return true; }); c->set_suback_handler( [&chk, &c] @@ -497,14 +472,12 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_vec ) { "topic2", }; c->unsubscribe(v); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -518,7 +491,6 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_vec ) { v.emplace_back("topic1", MQTT_NS::qos::at_most_once); v.emplace_back("topic2", MQTT_NS::qos::exactly_once); c->subscribe(v); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -530,14 +502,12 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_vec ) { "topic2", }; c->unsubscribe(v); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); break; default: @@ -592,21 +562,18 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_single_async ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c->async_subscribe("topic1", MQTT_NS::qos::at_most_once, [](MQTT_NS::error_code) {}); - return true; }); c->set_suback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*results*/) { MQTT_CHK("h_suback"); c->async_unsubscribe("topic1", [](MQTT_NS::error_code) {}); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -617,21 +584,18 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_single_async ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->async_subscribe("topic1", MQTT_NS::qos::at_most_once, [](MQTT_NS::error_code) {}); - return true; }); c->set_v5_suback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_suback"); c->async_unsubscribe("topic1", [](MQTT_NS::error_code) {}); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; default: @@ -693,7 +657,6 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_arg_async ) { }, [](MQTT_NS::error_code) {} ); - return true; }); c->set_suback_handler( [&chk, &c] @@ -706,14 +669,12 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_arg_async ) { }, [](MQTT_NS::error_code) {} ); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -731,7 +692,6 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_arg_async ) { }, [](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -744,14 +704,12 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_arg_async ) { }, [](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; default: @@ -812,7 +770,6 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_vec_async ) { v, [](MQTT_NS::error_code) {} ); - return true; }); c->set_suback_handler( [&chk, &c] @@ -827,14 +784,12 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_vec_async ) { v, [](MQTT_NS::error_code) {} ); - return true; }); c->set_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; case MQTT_NS::protocol_version::v5: @@ -851,7 +806,6 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_vec_async ) { v, [](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -866,14 +820,12 @@ BOOST_AUTO_TEST_CASE( qos0_sub_string_multi_vec_async ) { v, [](MQTT_NS::error_code) {} ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->async_disconnect(); - return true; }); break; default: @@ -1010,21 +962,18 @@ BOOST_AUTO_TEST_CASE( sub_unsub_prop ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::at_most_once, subps); - return true; }); c->set_v5_suback_handler( [&chk, &c, &unsubps] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_suback"); c->unsubscribe("topic1", unsubps); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback"); c->disconnect(); - return true; }); c->set_close_handler( [&chk, &finish] @@ -1095,7 +1044,6 @@ BOOST_AUTO_TEST_CASE( suback_unsuback_prop ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_suback_handler( [&chk, &c, &sub_user_prop_count, suback_prop_size] @@ -1132,7 +1080,6 @@ BOOST_AUTO_TEST_CASE( suback_unsuback_prop ) { } c->unsubscribe("topic1"); - return true; }); c->set_v5_unsuback_handler( [&chk, &c, &unsub_user_prop_count, unsuback_prop_size] @@ -1168,7 +1115,6 @@ BOOST_AUTO_TEST_CASE( suback_unsuback_prop ) { ); } c->disconnect(); - return true; }); c->set_close_handler( [&chk, &finish] diff --git a/test/system/st_topic_alias.cpp b/test/system/st_topic_alias.cpp index d1d73b00b..241496640 100644 --- a/test/system/st_topic_alias.cpp +++ b/test/system/st_topic_alias.cpp @@ -54,25 +54,21 @@ BOOST_AUTO_TEST_CASE( pubsub ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -98,7 +94,6 @@ BOOST_AUTO_TEST_CASE( pubsub ) { MQTT_NS::v5::property::topic_alias(0x1U) } ); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] @@ -107,7 +102,6 @@ BOOST_AUTO_TEST_CASE( pubsub ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c] @@ -138,7 +132,6 @@ BOOST_AUTO_TEST_CASE( pubsub ) { } ); BOOST_TEST(ret); - return true; }); break; default: @@ -256,7 +249,6 @@ BOOST_AUTO_TEST_CASE( auto_replace ) { "topic1_contents_2", MQTT_NS::qos::at_most_once ); - return true; }); break; default: @@ -413,7 +405,6 @@ BOOST_AUTO_TEST_CASE( auto_map ) { "topic5_contents_6", MQTT_NS::qos::at_most_once ); - return true; }); break; default: @@ -486,25 +477,21 @@ BOOST_AUTO_TEST_CASE( overwrite ) { BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::at_most_once); c->subscribe("topic2", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -547,7 +534,6 @@ BOOST_AUTO_TEST_CASE( overwrite ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] @@ -566,7 +552,6 @@ BOOST_AUTO_TEST_CASE( overwrite ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_publish_handler( [&chk, &c] @@ -607,7 +592,6 @@ BOOST_AUTO_TEST_CASE( overwrite ) { } ); BOOST_TEST(ret); - return true; }); break; default: @@ -671,25 +655,21 @@ BOOST_AUTO_TEST_CASE( no_entry ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c->set_v5_puback_handler( [] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c] @@ -713,13 +693,11 @@ BOOST_AUTO_TEST_CASE( no_entry ) { BOOST_TEST(e.what() == "protocol error"); c->disconnect(); } - return true; }); c->set_v5_unsuback_handler( [] (packet_id_t /*packet_id*/, std::vector /*reasons*/, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_publish_handler( [] @@ -729,7 +707,6 @@ BOOST_AUTO_TEST_CASE( no_entry ) { MQTT_NS::buffer /*contents*/, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_disconnect_handler( [&chk] @@ -830,25 +807,21 @@ BOOST_AUTO_TEST_CASE( resend_publish ) { } ); BOOST_TEST(ret); - return true; }); c->set_v5_puback_handler( [&chk] (packet_id_t, MQTT_NS::v5::puback_reason_code, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_puback"); - return true; }); c->set_v5_pubrec_handler( [] (packet_id_t, MQTT_NS::v5::pubrec_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_pubcomp_handler( [] (packet_id_t, MQTT_NS::v5::pubcomp_reason_code, MQTT_NS::v5::properties /*props*/) { BOOST_CHECK(false); - return true; }); c->set_v5_suback_handler( [&chk, &c, &tim] @@ -890,7 +863,6 @@ BOOST_AUTO_TEST_CASE( resend_publish ) { // See https://lists.oasis-open.org/archives/mqtt-comment/202009/msg00000.html c->force_disconnect(); - return true; }); c->set_v5_unsuback_handler( [&chk, &c] @@ -899,7 +871,6 @@ BOOST_AUTO_TEST_CASE( resend_publish ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c->disconnect(); - return true; }); c->set_v5_publish_handler( [&chk, &c] @@ -930,7 +901,6 @@ BOOST_AUTO_TEST_CASE( resend_publish ) { } ); BOOST_TEST(ret); - return true; }); break; default: diff --git a/test/system/st_utf8string_validate.cpp b/test/system/st_utf8string_validate.cpp index 38ea9d871..528a0269b 100644 --- a/test/system/st_utf8string_validate.cpp +++ b/test/system/st_utf8string_validate.cpp @@ -209,19 +209,16 @@ BOOST_AUTO_TEST_CASE( publish_overlength_topic ) { (bool, MQTT_NS::connect_return_code) { try { c->publish(tp, "topic1_contents", MQTT_NS::qos::at_most_once); - return true; } catch (MQTT_NS::utf8string_length_error const&) { BOOST_CHECK(true); finish(); c->force_disconnect(); - return false; } catch (boost::bad_numeric_cast const&) { BOOST_CHECK(true); finish(); c->force_disconnect(); - return false; } } ); @@ -247,13 +244,11 @@ BOOST_AUTO_TEST_CASE( publish_invalid_topic ) { (bool, MQTT_NS::connect_return_code) { try { c->publish(tp, "topic1_contents", MQTT_NS::qos::at_most_once); - return true; } catch (MQTT_NS::utf8string_contents_error const&) { BOOST_CHECK(true); finish(); c->force_disconnect(); - return false; } } ); @@ -279,13 +274,11 @@ BOOST_AUTO_TEST_CASE( subscribe_overlength_topic ) { (bool, MQTT_NS::connect_return_code) { try { c->subscribe(tp, MQTT_NS::qos::at_most_once); - return true; } catch (MQTT_NS::utf8string_length_error const&) { BOOST_CHECK(true); finish(); c->force_disconnect(); - return false; } } ); @@ -311,13 +304,11 @@ BOOST_AUTO_TEST_CASE( subscribe_invalid_topic ) { (bool, MQTT_NS::connect_return_code) { try { c->subscribe(tp, MQTT_NS::qos::at_most_once); - return true; } catch (MQTT_NS::utf8string_contents_error const&) { BOOST_CHECK(true); finish(); c->force_disconnect(); - return false; } } ); @@ -343,13 +334,11 @@ BOOST_AUTO_TEST_CASE( unsubscribe_overlength_topic ) { (bool, MQTT_NS::connect_return_code) { try { c->unsubscribe(tp); - return true; } catch (MQTT_NS::utf8string_length_error const&) { BOOST_CHECK(true); finish(); c->force_disconnect(); - return false; } } ); @@ -375,13 +364,11 @@ BOOST_AUTO_TEST_CASE( unsubscribe_invalid_topic ) { (bool, MQTT_NS::connect_return_code) { try { c->unsubscribe(tp); - return true; } catch (MQTT_NS::utf8string_contents_error const&) { BOOST_CHECK(true); finish(); c->force_disconnect(); - return false; } } ); diff --git a/test/system/st_will.cpp b/test/system/st_will.cpp index a0b782ae5..9a79b041e 100644 --- a/test/system/st_will.cpp +++ b/test/system/st_will.cpp @@ -87,7 +87,6 @@ BOOST_AUTO_TEST_CASE( will_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c1_force_disconnect(); - return true; }); c1->set_close_handler( [] @@ -115,7 +114,6 @@ BOOST_AUTO_TEST_CASE( will_qos0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub2 = c2->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -136,7 +134,6 @@ BOOST_AUTO_TEST_CASE( will_qos0 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_0); c1_force_disconnect(); - return true; }); c2->set_unsuback_handler( [&chk, &c2, &pid_unsub2] @@ -144,7 +141,6 @@ BOOST_AUTO_TEST_CASE( will_qos0 ) { MQTT_CHK("h_unsuback_2"); BOOST_TEST(packet_id == pid_unsub2); c2->disconnect(); - return true; }); c2->set_publish_handler( [&chk, &c2, &pid_unsub2] @@ -160,7 +156,6 @@ BOOST_AUTO_TEST_CASE( will_qos0 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "will_contents"); pid_unsub2 = c2->unsubscribe("topic1"); - return true; }); c1->connect(); @@ -247,7 +242,6 @@ BOOST_AUTO_TEST_CASE( will_qo0_timeout ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c1_force_disconnect(); - return true; }); c1->set_close_handler( [] @@ -270,7 +264,6 @@ BOOST_AUTO_TEST_CASE( will_qo0_timeout ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub2 = c2->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -309,7 +302,6 @@ BOOST_AUTO_TEST_CASE( will_qo0_timeout ) { } ); - return true; }); c2->set_v5_unsuback_handler( [&chk, &c2, &pid_unsub2] @@ -317,7 +309,6 @@ BOOST_AUTO_TEST_CASE( will_qo0_timeout ) { MQTT_CHK("h_unsuback_2"); BOOST_TEST(packet_id == pid_unsub2); c2->disconnect(); - return true; }); c2->set_v5_publish_handler( [] @@ -329,7 +320,6 @@ BOOST_AUTO_TEST_CASE( will_qo0_timeout ) { // Will should not be received BOOST_TEST(false); - return true; }); c1->connect(); @@ -416,7 +406,6 @@ BOOST_AUTO_TEST_CASE( will_qos0_wd0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c1_force_disconnect(); - return true; }); c1->set_close_handler( [] @@ -436,7 +425,6 @@ BOOST_AUTO_TEST_CASE( will_qos0_wd0 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c2->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -456,14 +444,12 @@ BOOST_AUTO_TEST_CASE( will_qos0_wd0 ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c1_force_disconnect(); - return true; }); c2->set_v5_unsuback_handler( [&chk, &c2] (packet_id_t, std::vector, MQTT_NS::v5::properties /*props*/) { MQTT_CHK("h_unsuback_2"); c2->disconnect(); - return true; }); c2->set_v5_publish_handler( [&chk, &c2] @@ -480,7 +466,6 @@ BOOST_AUTO_TEST_CASE( will_qos0_wd0 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "will_contents"); c2->unsubscribe("topic1"); - return true; }); c1->connect(); @@ -578,7 +563,6 @@ BOOST_AUTO_TEST_CASE( will_qos0_cancel ) { } ); BOOST_TEST(ret); - return true; }); c1->set_close_handler( [&chk, &c2] @@ -600,7 +584,6 @@ BOOST_AUTO_TEST_CASE( will_qos0_cancel ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c2->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -620,7 +603,6 @@ BOOST_AUTO_TEST_CASE( will_qos0_cancel ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c1_force_disconnect(); - return true; }); c2->set_v5_publish_handler( [] @@ -631,7 +613,6 @@ BOOST_AUTO_TEST_CASE( will_qos0_cancel ) { MQTT_NS::v5::properties /*props*/) { // Will should not be received BOOST_TEST(false); - return true; }); c1->connect( @@ -713,7 +694,6 @@ BOOST_AUTO_TEST_CASE( will_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c1_force_disconnect(); - return true; }); c1->set_close_handler( [] @@ -737,7 +717,6 @@ BOOST_AUTO_TEST_CASE( will_qos1 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub2 = c2->subscribe("topic1", MQTT_NS::qos::at_least_once); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -758,7 +737,6 @@ BOOST_AUTO_TEST_CASE( will_qos1 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_1); c1_force_disconnect(); - return true; }); c2->set_unsuback_handler( [&chk, &c2, &pid_unsub2] @@ -766,7 +744,6 @@ BOOST_AUTO_TEST_CASE( will_qos1 ) { MQTT_CHK("h_unsuback_2"); BOOST_TEST(packet_id == pid_unsub2); c2->disconnect(); - return true; }); c2->set_publish_handler( [&chk, &c2, &pid_unsub2] @@ -782,7 +759,6 @@ BOOST_AUTO_TEST_CASE( will_qos1 ) { BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "will_contents"); pid_unsub2 = c2->unsubscribe("topic1"); - return true; }); c1->connect(); @@ -861,7 +837,6 @@ BOOST_AUTO_TEST_CASE( will_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c1_force_disconnect(); - return true; }); c1->set_close_handler( [] @@ -885,7 +860,6 @@ BOOST_AUTO_TEST_CASE( will_qos2 ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub2 = c2->subscribe("topic1", MQTT_NS::qos::exactly_once); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -906,7 +880,6 @@ BOOST_AUTO_TEST_CASE( will_qos2 ) { BOOST_TEST(results.size() == 1U); BOOST_TEST(results[0] == MQTT_NS::suback_return_code::success_maximum_qos_2); c1_force_disconnect(); - return true; }); c2->set_unsuback_handler( [&chk, &c2, &pid_unsub2] @@ -914,7 +887,6 @@ BOOST_AUTO_TEST_CASE( will_qos2 ) { MQTT_CHK("h_unsuback_2"); BOOST_TEST(packet_id == pid_unsub2); c2->disconnect(); - return true; }); c2->set_publish_handler( [&chk] @@ -929,7 +901,6 @@ BOOST_AUTO_TEST_CASE( will_qos2 ) { BOOST_CHECK(*packet_id != 0); BOOST_TEST(topic == "topic1"); BOOST_TEST(contents == "will_contents"); - return true; }); c2->set_pub_res_sent_handler( [&chk, &c2, &pid_unsub2] @@ -1018,7 +989,6 @@ BOOST_AUTO_TEST_CASE( will_retain ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); c1_force_disconnect(); - return true; }); c1->set_close_handler( [] @@ -1042,7 +1012,6 @@ BOOST_AUTO_TEST_CASE( will_retain ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::connect_return_code::accepted); pid_sub2 = c2->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -1071,7 +1040,6 @@ BOOST_AUTO_TEST_CASE( will_retain ) { } ); BOOST_TEST(ret); - return true; }); c2->set_unsuback_handler( [&chk, &c2, &pid_unsub2, &pid_sub2] @@ -1088,7 +1056,6 @@ BOOST_AUTO_TEST_CASE( will_retain ) { } ); BOOST_TEST(ret); - return true; }); c2->set_publish_handler( [&chk, &c2, &pid_unsub2] @@ -1113,7 +1080,6 @@ BOOST_AUTO_TEST_CASE( will_retain ) { } ); BOOST_TEST(ret); - return true; }); c1->connect(); @@ -1261,7 +1227,6 @@ BOOST_AUTO_TEST_CASE( will_prop ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); c1_force_disconnect(); - return true; }); c1->set_close_handler( [] @@ -1289,7 +1254,6 @@ BOOST_AUTO_TEST_CASE( will_prop ) { BOOST_TEST(sp == false); BOOST_TEST(connack_return_code == MQTT_NS::v5::connect_reason_code::success); pid_sub2 = c2->subscribe("topic1", MQTT_NS::qos::at_most_once); - return true; }); c2->set_close_handler( [&chk, &finish] @@ -1310,7 +1274,6 @@ BOOST_AUTO_TEST_CASE( will_prop ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::suback_reason_code::granted_qos_0); c1_force_disconnect(); - return true; }); c2->set_v5_unsuback_handler( [&chk, &c2, &pid_unsub2] @@ -1320,7 +1283,6 @@ BOOST_AUTO_TEST_CASE( will_prop ) { BOOST_TEST(reasons.size() == 1U); BOOST_TEST(reasons[0] == MQTT_NS::v5::unsuback_reason_code::success); c2->disconnect(); - return true; }); c2->set_v5_publish_handler( [&chk, &c2, &pid_unsub2, prop_size, &user_prop_count] @@ -1387,7 +1349,6 @@ BOOST_AUTO_TEST_CASE( will_prop ) { } pid_unsub2 = c2->unsubscribe("topic1"); - return true; }); c1->connect();