From 30dd9bdb1aa68d9aee65338ef29aea0c6401adad Mon Sep 17 00:00:00 2001 From: chenguoping Date: Mon, 13 Jul 2020 20:44:47 +0800 Subject: [PATCH] boost code coverage --- test/src/unit-element_access2.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/src/unit-element_access2.cpp b/test/src/unit-element_access2.cpp index 0a73964a2..59a97c38d 100644 --- a/test/src/unit-element_access2.cpp +++ b/test/src/unit-element_access2.cpp @@ -282,6 +282,18 @@ TEST_CASE("element access 2") CHECK_THROWS_WITH(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number"); } + SECTION("default value is lvalue") + { + json j_nonobject(json::value_t::number_float); + const json j_nonobject_const(j_nonobject); + std::string defval = "default value"; + CHECK_THROWS_AS(j_nonobject.value("foo", defval), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("foo", defval), json::type_error&); + CHECK_THROWS_WITH(j_nonobject.value("foo", defval), + "[json.exception.type_error.306] cannot use value() with number"); + CHECK_THROWS_WITH(j_nonobject_const.value("foo", defval), + "[json.exception.type_error.306] cannot use value() with number"); + } } }