Skip to content

Commit 09885f7

Browse files
author
Ivan Baidakou
committed
Better tests coverage
1 parent 455aa14 commit 09885f7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

t/05-protocol.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ TEST_CASE("malformed bulk string(3)", "[protocol]") {
203203
REQUIRE(r->code.message() == "Terminator for bulk string not found");
204204
};
205205

206+
TEST_CASE("malformed bulk string(4)", "[protocol]") {
207+
using Policy = r::parsing_policy::drop_result;
208+
std::string ok =
209+
"$4555555555555555555555555555555555555555555555555555\r\nsomemm";
210+
Buffer buff(ok.c_str(), ok.size());
211+
auto from = Iterator::begin(buff), to = Iterator::end(buff);
212+
auto parsed_result = r::Protocol::parse<Iterator, Policy>(from, to);
213+
r::protocol_error_t *r = boost::get<r::protocol_error_t>(&parsed_result);
214+
REQUIRE(r->code.message() == "Cannot convert count to number");
215+
};
216+
206217
TEST_CASE("empty array", "[protocol]") {
207218
std::string ok = "*0\r\n";
208219
Buffer buff(ok.c_str(), ok.size());
@@ -241,6 +252,15 @@ TEST_CASE("malformed array", "[protocol]") {
241252
REQUIRE(r->code.message() == "Unacceptable count value");
242253
};
243254

255+
TEST_CASE("malformed array (2)", "[protocol]") {
256+
std::string ok = "*555555555555555555555555555555555555555\r\nsome\r\n";
257+
Buffer buff(ok.c_str(), ok.size());
258+
auto from = Iterator::begin(buff), to = Iterator::end(buff);
259+
auto parsed_result = r::Protocol::parse(from, to);
260+
r::protocol_error_t *r = boost::get<r::protocol_error_t>(&parsed_result);
261+
REQUIRE(r->code.message() == "Cannot convert count to number");
262+
};
263+
244264
TEST_CASE("patrial array(1)", "[protocol]") {
245265
std::string ok = "*1\r\n";
246266
Buffer buff(ok.c_str(), ok.size());

0 commit comments

Comments
 (0)