From bc3d745c183d525d9f8d33413112697e5342bb46 Mon Sep 17 00:00:00 2001 From: melode11 Date: Mon, 20 Apr 2015 23:12:28 +0800 Subject: [PATCH] add test cases,format code --- src/internal/sio_client_impl.cpp | 66 +++++------ src/internal/sio_client_impl.h | 4 +- src/internal/sio_packet.cpp | 193 ++++++++++++++++--------------- src/sio_client.cpp | 2 +- src/sio_message.h | 17 +-- src/sio_socket.cpp | 134 ++++++++++----------- test/sio_test.cpp | 111 +++++++++++++++++- 7 files changed, 316 insertions(+), 211 deletions(-) diff --git a/src/internal/sio_client_impl.cpp b/src/internal/sio_client_impl.cpp index dab76b27..cc025890 100644 --- a/src/internal/sio_client_impl.cpp +++ b/src/internal/sio_client_impl.cpp @@ -22,7 +22,7 @@ using boost::posix_time::milliseconds; namespace sio { -/*************************public:*************************/ + /*************************public:*************************/ client_impl::client_impl() : m_con_state(con_closed), m_ping_interval(0), @@ -34,10 +34,10 @@ namespace sio m_reconn_delay_max(25000) { using websocketpp::log::alevel; - #ifndef DEBUG +#ifndef DEBUG m_client.clear_access_channels(alevel::all); m_client.set_access_channels(alevel::connect|alevel::disconnect|alevel::app); - #endif +#endif // Initialize the Asio transport policy m_client.init_asio(); @@ -141,7 +141,7 @@ namespace sio } } -/*************************protected:*************************/ + /*************************protected:*************************/ void client_impl::send(packet& p) { m_packet_mgr.encode(p); @@ -172,7 +172,7 @@ namespace sio if(m_socket_open_listener)m_socket_open_listener(nsp); } -/*************************private:*************************/ + /*************************private:*************************/ void client_impl::run_loop() { @@ -261,10 +261,10 @@ namespace sio packet p(packet::frame_ping); m_packet_mgr.encode(p, [&](bool isBin,shared_ptr payload) - { - lib::error_code ec; - this->m_client.send(this->m_con, *payload, frame::opcode::text, ec); - }); + { + lib::error_code ec; + this->m_client.send(this->m_con, *payload, frame::opcode::text, ec); + }); if(m_ping_timer) { boost::system::error_code e_code; @@ -347,7 +347,7 @@ namespace sio LOG("Connection failed." << std::endl); if(m_reconn_madenext_delay(); if(m_reconnect_listener) m_reconnect_listener(m_reconn_made,delay); m_reconn_timer.reset(new boost::asio::deadline_timer(m_client.get_io_service())); @@ -366,7 +366,7 @@ namespace sio LOG("Connected." << std::endl); m_con_state = con_opened; m_con = con; - m_reconn_made = 0; + m_reconn_made = 0; this->sockets_invoke_void(&sio::socket::on_open); if(m_open_listener)m_open_listener(); } @@ -399,7 +399,7 @@ namespace sio this->sockets_invoke_void(&sio::socket::on_disconnect); if(m_reconn_madenext_delay(); if(m_reconnect_listener) m_reconnect_listener(m_reconn_made,delay); m_reconn_timer.reset(new boost::asio::deadline_timer(m_client.get_io_service())); @@ -468,12 +468,12 @@ namespace sio LOG("On handshake,sid:"<on_message_packet(p); - break; - } - case packet::frame_open: - this->on_handshake(p.get_message()); - break; - case packet::frame_close: - //FIXME how to deal? - this->close_impl(close::status::abnormal_close, "End by server"); - break; - case packet::frame_pong: - this->on_pong(); - break; - - default: - break; + case packet::frame_message: + { + socket::ptr so_ptr = get_socket_locked(p.get_nsp()); + if(so_ptr)so_ptr->on_message_packet(p); + break; + } + case packet::frame_open: + this->on_handshake(p.get_message()); + break; + case packet::frame_close: + //FIXME how to deal? + this->close_impl(close::status::abnormal_close, "End by server"); + break; + case packet::frame_pong: + this->on_pong(); + break; + + default: + break; } } diff --git a/src/internal/sio_client_impl.h b/src/internal/sio_client_impl.h index 9aab11aa..6333228c 100644 --- a/src/internal/sio_client_impl.h +++ b/src/internal/sio_client_impl.h @@ -51,8 +51,8 @@ namespace sio //set listeners and event bindings. #define SYNTHESIS_SETTER(__TYPE__,__FIELD__) \ -void set_##__FIELD__(__TYPE__ const& l) \ -{ m_##__FIELD__ = l;} + void set_##__FIELD__(__TYPE__ const& l) \ + { m_##__FIELD__ = l;} SYNTHESIS_SETTER(client::con_listener,open_listener) diff --git a/src/internal/sio_packet.cpp b/src/internal/sio_packet.cpp index 10e0fdf5..0f7f16d5 100755 --- a/src/internal/sio_packet.cpp +++ b/src/internal/sio_packet.cpp @@ -17,12 +17,12 @@ namespace sio using namespace rapidjson; using namespace std; void accept_message(message const& msg,Value& val, Document& doc,vector >& buffers); - + void accept_int_message(int_message const& msg, Value& val) { val.SetInt64(msg.get_int()); } - + void accept_double_message(double_message const& msg, Value& val) { val.SetDouble(msg.get_double()); @@ -33,7 +33,7 @@ namespace sio val.SetString(msg.get_string().data(),(SizeType) msg.get_string().length()); } - + void accept_binary_message(binary_message const& msg,Value& val,Document& doc,vector >& buffers) { val.SetObject(); @@ -51,7 +51,7 @@ namespace sio write_buffer->append(*(msg.get_binary())); buffers.push_back(write_buffer); } - + void accept_array_message(array_message const& msg,Value& val,Document& doc,vector >& buffers) { val.SetArray(); @@ -61,7 +61,7 @@ namespace sio val.PushBack(child, doc.GetAllocator()); } } - + void accept_object_message(object_message const& msg,Value& val,Document& doc,vector >& buffers) { val.SetObject(); @@ -73,47 +73,47 @@ namespace sio val.AddMember(nameVal, valueVal, doc.GetAllocator()); } } - + void accept_message(message const& msg,Value& val, Document& doc,vector >& buffers) { const message* msg_ptr = &msg; switch(msg.get_flag()) { - case message::flag_integer: - { - accept_int_message(*(static_cast(msg_ptr)), val); - break; - } - case message::flag_double: - { - accept_double_message(*(static_cast(msg_ptr)), val); - break; - } - case message::flag_string: - { - accept_string_message(*(static_cast(msg_ptr)), val); - break; - } - case message::flag_binary: - { - accept_binary_message(*(static_cast(msg_ptr)), val,doc,buffers); - break; - } - case message::flag_array: - { - accept_array_message(*(static_cast(msg_ptr)), val,doc,buffers); - break; - } - case message::flag_object: - { - accept_object_message(*(static_cast(msg_ptr)), val,doc,buffers); - break; - } - default: - break; + case message::flag_integer: + { + accept_int_message(*(static_cast(msg_ptr)), val); + break; + } + case message::flag_double: + { + accept_double_message(*(static_cast(msg_ptr)), val); + break; + } + case message::flag_string: + { + accept_string_message(*(static_cast(msg_ptr)), val); + break; + } + case message::flag_binary: + { + accept_binary_message(*(static_cast(msg_ptr)), val,doc,buffers); + break; + } + case message::flag_array: + { + accept_array_message(*(static_cast(msg_ptr)), val,doc,buffers); + break; + } + case message::flag_object: + { + accept_object_message(*(static_cast(msg_ptr)), val,doc,buffers); + break; + } + default: + break; } } - + message::ptr from_json(Value const& value, vector > const& buffers) { if(value.IsInt64()) @@ -139,10 +139,10 @@ namespace sio } else if(value.IsObject()) { - //binary placeholder + //binary placeholder auto mem_it = value.FindMember(kBIN_PLACE_HOLDER); if (mem_it!=value.MemberEnd() && mem_it->value.GetBool()) { - + int num = value["num"].GetInt(); if(num >= 0 && num < static_cast(buffers.size())) { @@ -164,63 +164,63 @@ namespace sio } return message::ptr(); } - + packet::packet(string const& nsp,message::ptr const& msg,int pack_id, bool isAck): - _frame(frame_message), - _type((isAck?type_ack : type_event) | type_undetermined), - _nsp(nsp), - _message(msg), - _pack_id(pack_id), - _pending_buffers(0) + _frame(frame_message), + _type((isAck?type_ack : type_event) | type_undetermined), + _nsp(nsp), + _message(msg), + _pack_id(pack_id), + _pending_buffers(0) { assert((!isAck || (isAck&&pack_id>=0))); } packet::packet(type type,string const& nsp, message::ptr const& msg): - _frame(frame_message), - _type(type), - _nsp(nsp), - _message(msg), - _pack_id(-1), - _pending_buffers(0) + _frame(frame_message), + _type(type), + _nsp(nsp), + _message(msg), + _pack_id(-1), + _pending_buffers(0) { - + } - + packet::packet(packet::frame_type frame): - _frame(frame), - _type(type_undetermined), - _pack_id(-1), - _pending_buffers(0) + _frame(frame), + _type(type_undetermined), + _pack_id(-1), + _pending_buffers(0) { - + } - + packet::packet(): - _type(type_undetermined), - _pack_id(-1), - _pending_buffers(0) + _type(type_undetermined), + _pack_id(-1), + _pending_buffers(0) { - + } - - + + bool packet::is_binary_message(string const& payload_ptr) { return payload_ptr.size()>0 && payload_ptr[0] == frame_message; } - + bool packet::is_text_message(string const& payload_ptr) { return payload_ptr.size()>0 && payload_ptr[0] == (frame_message + '0'); } - + bool packet::is_message(string const& payload_ptr) { return is_binary_message(payload_ptr) || is_text_message(payload_ptr); } - + bool packet::parse_buffer(const string &buf_payload) { if (_pending_buffers > 0) { @@ -228,7 +228,7 @@ namespace sio _buffers.push_back(std::make_shared(buf_payload.data()+1,buf_payload.size()-1)); _pending_buffers--; if (_pending_buffers == 0) { - + Document doc; doc.Parse<0>(_buffers.front()->data()); _buffers.erase(_buffers.begin()); @@ -240,12 +240,15 @@ namespace sio } return false; } - + bool packet::parse(const string& payload_ptr) { assert(!is_binary_message(payload_ptr)); //this is ensured by outside _frame = (packet::frame_type) (payload_ptr[0] - '0'); - + _message.reset(); + _pack_id = -1; + _buffers.clear(); + _pending_buffers = 0; size_t pos = 1; if (_frame == frame_message) { _type = (packet::type)(payload_ptr[pos] - '0'); @@ -260,7 +263,7 @@ namespace sio pos = score_pos+1; } } - + size_t nsp_json_pos = payload_ptr.find_first_of("{[\"/",pos,4); if(nsp_json_pos==string::npos)//no namespace and no message,the end. { @@ -310,9 +313,9 @@ namespace sio _message = from_json(doc, vector >()); return false; } - + } - + bool packet::accept(string& payload_ptr, vector >&buffers) { char frame_char = _frame+'0'; @@ -349,55 +352,55 @@ namespace sio ss<<","; } } - + if(_pack_id>=0) { ss<<_pack_id; } - + payload_ptr.append(ss.str()); - if (hasMessage) { - StringBuffer buffer; - Writer writer(buffer); + if (hasMessage) + { + StringBuffer buffer; + Writer writer(buffer); doc.Accept(writer); - payload_ptr.append(buffer.GetString(),buffer.GetSize()); + payload_ptr.append(buffer.GetString(),buffer.GetSize()); } - return hasBinary; } - + packet::frame_type packet::get_frame() const { return _frame; } - + packet::type packet::get_type() const { assert((_type & type_undetermined) == 0); return (type)_type; } - + string const& packet::get_nsp() const { return _nsp; } - + message::ptr const& packet::get_message() const { return _message; } - + unsigned packet::get_pack_id() const { return _pack_id; } - - + + void packet_manager::set_decode_callback(function const& decode_callback) { m_decode_callback = decode_callback; } - + void packet_manager::set_encode_callback(function const&)> const& encode_callback) { m_encode_callback = encode_callback; @@ -407,7 +410,7 @@ namespace sio { m_partial_packet.reset(); } - + void packet_manager::encode(packet& pack,encode_callback_function const& override_encode_callback) const { shared_ptr ptr = make_shared(); @@ -439,7 +442,7 @@ namespace sio } } } - + void packet_manager::put_payload(string const& payload) { unique_ptr p; @@ -476,7 +479,7 @@ namespace sio } return; }while(0); - + if(m_decode_callback) { m_decode_callback(*p); diff --git a/src/sio_client.cpp b/src/sio_client.cpp index 3f04dced..d1c63692 100755 --- a/src/sio_client.cpp +++ b/src/sio_client.cpp @@ -14,7 +14,7 @@ using std::stringstream; namespace sio { client::client(): - m_impl(new client_impl()) + m_impl(new client_impl()) { } diff --git a/src/sio_message.h b/src/sio_message.h index 919a121f..8137de54 100755 --- a/src/sio_message.h +++ b/src/sio_message.h @@ -243,9 +243,7 @@ namespace sio list(message::ptr const& message) { if(message) - { - m_vector.push_back(message); - } + m_vector.push_back(message); } list(string& text) @@ -256,25 +254,20 @@ namespace sio list(const char* text) { if(text) - { - m_vector.push_back(string_message::create(text)); - } + m_vector.push_back(string_message::create(text)); } list(shared_ptr const& binary) { if(binary) - { - m_vector.push_back(binary_message::create(binary)); - } + m_vector.push_back(binary_message::create(binary)); } void push(message::ptr const& message) { if(message) - { - m_vector.push_back(message); - } + m_vector.push_back(message); + } void insert(size_t pos,message::ptr const& message) diff --git a/src/sio_socket.cpp b/src/sio_socket.cpp index 89aa13c7..8264e142 100644 --- a/src/sio_socket.cpp +++ b/src/sio_socket.cpp @@ -13,7 +13,7 @@ #endif #define NULL_GUARD(_x_) \ -if(_x_ == NULL) return + if(_x_ == NULL) return namespace sio { @@ -69,10 +69,10 @@ namespace sio inline event::event(std::string const& nsp,std::string const& name,message::ptr const& message,bool need_ack): - m_nsp(nsp), - m_name(name), - m_message(message), - m_need_ack(need_ack) + m_nsp(nsp), + m_name(name), + m_message(message), + m_need_ack(need_ack) { } @@ -102,8 +102,8 @@ namespace sio void off_all(); #define SYNTHESIS_SETTER(__TYPE__,__FIELD__) \ -void set_##__FIELD__(__TYPE__ const& l) \ -{ m_##__FIELD__ = l;} + void set_##__FIELD__(__TYPE__ const& l) \ + { m_##__FIELD__ = l;} SYNTHESIS_SETTER(error_listener, error_listener) //socket io errors @@ -209,9 +209,9 @@ void set_##__FIELD__(__TYPE__ const& l) \ } socket::impl::impl(client_impl *client,std::string const& nsp): - m_client(client), - m_nsp(nsp), - m_connected(false) + m_client(client), + m_nsp(nsp), + m_connected(false) { NULL_GUARD(client); if(m_client->opened()) @@ -334,74 +334,74 @@ void set_##__FIELD__(__TYPE__ const& l) \ { switch (p.get_type()) { - // Connect open - case packet::type_connect: - { - LOG("Received Message type (Connect)"<on_connected(); - break; - } - case packet::type_disconnect: - { - LOG("Received Message type (Disconnect)"<on_close(); - break; - } - case packet::type_event: - case packet::type_binary_event: + // Connect open + case packet::type_connect: + { + LOG("Received Message type (Connect)"<on_connected(); + break; + } + case packet::type_disconnect: + { + LOG("Received Message type (Disconnect)"<on_close(); + break; + } + case packet::type_event: + case packet::type_binary_event: + { + LOG("Received Message type (Event)"<get_flag() == message::flag_array) { - LOG("Received Message type (Event)"<get_flag() == message::flag_array) + const array_message* array_ptr = static_cast(ptr.get()); + if(array_ptr->get_vector().size() >= 1&&array_ptr->get_vector()[0]->get_flag() == message::flag_string) { - const array_message* array_ptr = static_cast(ptr.get()); - if(array_ptr->get_vector().size() >= 1&&array_ptr->get_vector()[0]->get_flag() == message::flag_string) + const string_message* name_ptr = static_cast(array_ptr->get_vector()[0].get()); + message::ptr value_ptr; + if(array_ptr->get_vector().size()>1) { - const string_message* name_ptr = static_cast(array_ptr->get_vector()[0].get()); - message::ptr value_ptr; - if(array_ptr->get_vector().size()>1) - { - value_ptr = array_ptr->get_vector()[1]; - } - this->on_socketio_event(p.get_nsp(), p.get_pack_id(),name_ptr->get_string(), value_ptr); + value_ptr = array_ptr->get_vector()[1]; } + this->on_socketio_event(p.get_nsp(), p.get_pack_id(),name_ptr->get_string(), value_ptr); } - - break; } - // Ack - case packet::type_ack: - case packet::type_binary_ack: + + break; + } + // Ack + case packet::type_ack: + case packet::type_binary_ack: + { + LOG("Received Message type (ACK)"<get_flag() == message::flag_array) { - LOG("Received Message type (ACK)"<get_flag() == message::flag_array) + const array_message* array_ptr = static_cast(ptr.get()); + if(array_ptr->get_vector().size() >= 1&&array_ptr->get_vector()[0]->get_flag() == message::flag_string) { - const array_message* array_ptr = static_cast(ptr.get()); - if(array_ptr->get_vector().size() >= 1&&array_ptr->get_vector()[0]->get_flag() == message::flag_string) + message::ptr value_ptr; + if(array_ptr->get_vector().size()>1) { - message::ptr value_ptr; - if(array_ptr->get_vector().size()>1) - { - value_ptr = array_ptr->get_vector()[1]; - } - this->on_socketio_ack(p.get_pack_id(), value_ptr); - break; + value_ptr = array_ptr->get_vector()[1]; } + this->on_socketio_ack(p.get_pack_id(), value_ptr); + break; } - this->on_socketio_ack(p.get_pack_id(),ptr); - break; } - // Error - case packet::type_error: - { - LOG("Received Message type (ERROR)"<on_socketio_error(p.get_message()); - break; - } - default: - break; + this->on_socketio_ack(p.get_pack_id(),ptr); + break; + } + // Error + case packet::type_error: + { + LOG("Received Message type (ERROR)"<on_socketio_error(p.get_message()); + break; + } + default: + break; } } } @@ -486,7 +486,7 @@ void set_##__FIELD__(__TYPE__ const& l) \ } socket::socket(client_impl* client,std::string const& nsp): - m_impl(new impl(client,nsp)) + m_impl(new impl(client,nsp)) { } diff --git a/test/sio_test.cpp b/test/sio_test.cpp index 4395943d..16bc3bac 100644 --- a/test/sio_test.cpp +++ b/test/sio_test.cpp @@ -11,8 +11,11 @@ #include #define BOOST_TEST_MODULE sio_test + #include -#include "json.hpp" +#ifndef _WIN32 +#include "json.hpp" //nlohmann::json cannot build in MSVC +#endif using namespace sio; BOOST_AUTO_TEST_SUITE(test_packet) @@ -79,6 +82,7 @@ BOOST_AUTO_TEST_CASE( test_packet_accept_3 ) BOOST_CHECK_MESSAGE(payload == "43/nsp,1001[\"event\",\"text\"]",std::string("outputing payload:")+payload); } +#ifndef _WIN32 BOOST_AUTO_TEST_CASE( test_packet_accept_4 ) { message::ptr binObj = object_message::create(); @@ -115,6 +119,111 @@ BOOST_AUTO_TEST_CASE( test_packet_accept_4 ) BOOST_CHECK_MESSAGE(buffers[bin2Num]->length()==51 , std::string("outputing payload bin2 num:") + numchar); BOOST_CHECK(buffers[bin2Num]->at(25)==1 && buffers[bin2Num]->at(0) == packet::frame_message); } +#endif + +BOOST_AUTO_TEST_CASE( test_packet_parse_1 ) +{ + packet p; + bool hasbin = p.parse("42/nsp,1001[\"event\",\"text\"]"); + BOOST_CHECK(!hasbin); + BOOST_CHECK(p.get_frame() == packet::frame_message); + BOOST_CHECK(p.get_type() == packet::type_event); + BOOST_CHECK(p.get_nsp() == "/nsp"); + BOOST_CHECK(p.get_pack_id() == 1001); + BOOST_CHECK(p.get_message()->get_flag() == message::flag_array); + BOOST_REQUIRE(p.get_message()->get_vector()[0]->get_flag() == message::flag_string); + BOOST_CHECK(p.get_message()->get_vector()[0]->get_string() == "event"); + BOOST_REQUIRE(p.get_message()->get_vector()[1]->get_flag() == message::flag_string); + BOOST_CHECK(p.get_message()->get_vector()[1]->get_string() == "text"); + + hasbin = p.parse("431111[\"ack\",{\"count\":5}]"); + BOOST_CHECK(!hasbin); + BOOST_CHECK(p.get_frame() == packet::frame_message); + BOOST_CHECK(p.get_type() == packet::type_ack); + BOOST_CHECK(p.get_pack_id() == 1111); + BOOST_CHECK(p.get_nsp() == "/"); + BOOST_CHECK(p.get_message()->get_flag() == message::flag_array); + BOOST_REQUIRE(p.get_message()->get_vector()[0]->get_flag() == message::flag_string); + BOOST_CHECK(p.get_message()->get_vector()[0]->get_string() == "ack"); + BOOST_REQUIRE(p.get_message()->get_vector()[1]->get_flag() == message::flag_object); + BOOST_CHECK(p.get_message()->get_vector()[1]->get_map()["count"]->get_int() == 5); +} + +BOOST_AUTO_TEST_CASE( test_packet_parse_2 ) +{ + packet p; + bool hasbin = p.parse("3"); + BOOST_CHECK(!hasbin); + BOOST_CHECK(p.get_frame() == packet::frame_pong); + BOOST_CHECK(!p.get_message()); + BOOST_CHECK(p.get_nsp() == "/"); + BOOST_CHECK(p.get_pack_id() == -1); + hasbin = p.parse("2"); + + BOOST_CHECK(!hasbin); + BOOST_CHECK(p.get_frame() == packet::frame_ping); + BOOST_CHECK(!p.get_message()); + BOOST_CHECK(p.get_nsp() == "/"); + BOOST_CHECK(p.get_pack_id() == -1); +} + +BOOST_AUTO_TEST_CASE( test_packet_parse_3 ) +{ + packet p; + bool hasbin = p.parse("40/nsp"); + BOOST_CHECK(!hasbin); + BOOST_CHECK(p.get_type() == packet::type_connect); + BOOST_CHECK(p.get_frame() == packet::frame_message); + BOOST_CHECK(p.get_nsp() == "/nsp"); + BOOST_CHECK(p.get_pack_id() == -1); + BOOST_CHECK(!p.get_message()); + p.parse("40"); + BOOST_CHECK(p.get_type() == packet::type_connect); + BOOST_CHECK(p.get_nsp() == "/"); + BOOST_CHECK(p.get_pack_id() == -1); + BOOST_CHECK(!p.get_message()); + p.parse("44\"error\""); + BOOST_CHECK(p.get_type() == packet::type_error); + BOOST_CHECK(p.get_nsp() == "/"); + BOOST_CHECK(p.get_pack_id() == -1); + BOOST_CHECK(p.get_message()->get_flag() == message::flag_string); + p.parse("44/nsp,\"error\""); + BOOST_CHECK(p.get_type() == packet::type_error); + BOOST_CHECK(p.get_nsp() == "/nsp"); + BOOST_CHECK(p.get_pack_id() == -1); + BOOST_CHECK(p.get_message()->get_flag() == message::flag_string); +} + +BOOST_AUTO_TEST_CASE( test_packet_parse_4 ) +{ + packet p; + bool hasbin = p.parse("452-/nsp,101[\"bin_event\",[{\"_placeholder\":true,\"num\":1},{\"_placeholder\":true,\"num\":0},\"text\"]]"); + BOOST_CHECK(hasbin); + char buf[101]; + buf[0] = packet::frame_message; + memset(buf+1,0,100); + + std::string bufstr(buf,101); + std::string bufstr2(buf,51); + BOOST_CHECK(p.parse_buffer(bufstr)); + BOOST_CHECK(!p.parse_buffer(bufstr2)); + + BOOST_CHECK(p.get_frame() == packet::frame_message); + BOOST_CHECK(p.get_nsp() == "/nsp"); + BOOST_CHECK(p.get_pack_id() == 101); + message::ptr msg = p.get_message(); + BOOST_REQUIRE(msg&&msg->get_flag() == message::flag_array); + BOOST_CHECK(msg->get_vector()[0]->get_string() == "bin_event"); + message::ptr array = msg->get_vector()[1]; + BOOST_REQUIRE(array->get_flag() == message::flag_array); + BOOST_REQUIRE(array->get_vector()[0]->get_flag() == message::flag_binary); + BOOST_REQUIRE(array->get_vector()[1]->get_flag() == message::flag_binary); + BOOST_REQUIRE(array->get_vector()[2]->get_flag() == message::flag_string); + BOOST_CHECK(array->get_vector()[0]->get_binary()->size() == 50); + BOOST_CHECK(array->get_vector()[1]->get_binary()->size() == 100); + BOOST_CHECK(array->get_vector()[2]->get_string() == "text"); + +} BOOST_AUTO_TEST_SUITE_END()