Skip to content

Commit d23a649

Browse files
committed
Merge pull request #375 from whoshuu/test-parse-error
Write test case for parse error when unpacking unused 0xc1
2 parents 0a261fc + 282b0b5 commit d23a649

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/pack_unpack.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,3 +372,22 @@ TEST(unpack, insufficient_bytes_zone)
372372
EXPECT_EQ(off, 0u);
373373
}
374374
}
375+
376+
TEST(unpack, parse_error)
377+
{
378+
msgpack::sbuffer sbuf;
379+
380+
char c = '\xc1';
381+
sbuf.write(&c, 1);
382+
383+
bool thrown = false;
384+
msgpack::unpacked msg;
385+
try {
386+
msgpack::unpack(msg, sbuf.data(), sbuf.size());
387+
EXPECT_TRUE(false);
388+
}
389+
catch (msgpack::parse_error const&) {
390+
thrown = true;
391+
}
392+
EXPECT_TRUE(thrown);
393+
}

0 commit comments

Comments
 (0)