From 282b0b592793e8f6cad564ba34def2c5706cccf6 Mon Sep 17 00:00:00 2001 From: Huu Nguyen Date: Sun, 18 Oct 2015 12:04:37 -0400 Subject: [PATCH] Write test case for parse error when unpacking unused 0xc1 --- test/pack_unpack.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/pack_unpack.cpp b/test/pack_unpack.cpp index 568ad524..f3d9569d 100644 --- a/test/pack_unpack.cpp +++ b/test/pack_unpack.cpp @@ -372,3 +372,22 @@ TEST(unpack, insufficient_bytes_zone) EXPECT_EQ(off, 0u); } } + +TEST(unpack, parse_error) +{ + msgpack::sbuffer sbuf; + + char c = '\xc1'; + sbuf.write(&c, 1); + + bool thrown = false; + msgpack::unpacked msg; + try { + msgpack::unpack(msg, sbuf.data(), sbuf.size()); + EXPECT_TRUE(false); + } + catch (msgpack::parse_error const&) { + thrown = true; + } + EXPECT_TRUE(thrown); +}