From 494f0cc5ddbb52b090f1c9aeec5a2341902936a3 Mon Sep 17 00:00:00 2001 From: chenguoping Date: Thu, 11 Jun 2020 19:37:40 +0800 Subject: [PATCH] add testcase --- test/src/unit-element_access2.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/src/unit-element_access2.cpp b/test/src/unit-element_access2.cpp index e881a9479..e59632dcb 100644 --- a/test/src/unit-element_access2.cpp +++ b/test/src/unit-element_access2.cpp @@ -464,6 +464,14 @@ TEST_CASE("element access 2") CHECK(j_const[json::object_t::key_type("array")] == j["array"]); } + SECTION("access not-existing value") + { + // not existing access + CHECK_THROWS_AS(j_const["not-existing"], json::out_of_range&); + CHECK_THROWS_WITH(j_const["not-existing"], + "[json.exception.out_of_range.403] key 'not-existing' not found"); + } + SECTION("access on non-object type") { SECTION("null")