From 7410763731cd991efd710f5d5cfb59316c537e27 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 10 Sep 2017 11:42:43 +0200 Subject: [PATCH] :white_check_mark: improved test coverage --- test/src/unit-cbor.cpp | 7 +++++++ test/src/unit-msgpack.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index 4060a5ab3..4ec03f23d 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -1224,6 +1224,13 @@ TEST_CASE("CBOR") SECTION("errors") { + SECTION("empty byte vector") + { + CHECK_THROWS_AS(json::from_cbor(std::vector()), json::parse_error&); + CHECK_THROWS_WITH(json::from_cbor(std::vector()), + "[json.exception.parse_error.110] parse error at 1: unexpected end of input"); + } + SECTION("too short byte vector") { CHECK_THROWS_AS(json::from_cbor(std::vector({0x18})), json::parse_error&); diff --git a/test/src/unit-msgpack.cpp b/test/src/unit-msgpack.cpp index 374349931..ff90f353c 100644 --- a/test/src/unit-msgpack.cpp +++ b/test/src/unit-msgpack.cpp @@ -1014,6 +1014,13 @@ TEST_CASE("MessagePack") SECTION("errors") { + SECTION("empty byte vector") + { + CHECK_THROWS_AS(json::from_msgpack(std::vector()), json::parse_error&); + CHECK_THROWS_WITH(json::from_msgpack(std::vector()), + "[json.exception.parse_error.110] parse error at 1: unexpected end of input"); + } + SECTION("too short byte vector") { CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcc})), json::parse_error&);