From 395830c1b68d47ff54b93724ac22e2255765015d Mon Sep 17 00:00:00 2001 From: Ivan Baidakou Date: Sat, 7 Dec 2019 09:21:01 +0300 Subject: [PATCH] Add test for #37 --- t/05-protocol.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/t/05-protocol.cpp b/t/05-protocol.cpp index d795aea7..49da20db 100644 --- a/t/05-protocol.cpp +++ b/t/05-protocol.cpp @@ -464,3 +464,13 @@ TEST_CASE("serialize + dynamic_string_buffer", "[protocol]") { std::string copy(std::begin(buff_backend), std::begin(buff_backend) + buff.size()); REQUIRE(copy == expected); } + +TEST_CASE("issue#37, empty command", "[protocol]") { + boost::asio::streambuf buff; + r::single_command_t cmd("HSET", "key", "value1", "", "value2", ""); + r::Protocol::serialize(buff, cmd); + std::string expected("*6\r\n$4\r\nHSET\r\n$3\r\nkey\r\n$6\r\nvalue1\r\n$0\r\n\r\n$6\r\nvalue2\r\n$0\r\n\r\n"); + char data[128] = {0}; + asio::buffer_copy(asio::buffer(data), asio::buffer(buff.data(), buff.size())); + REQUIRE(data == expected); +}