From 3e885c8328f4faeeb634c35f1cc713591f09a227 Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 15 Feb 2015 15:51:11 +0100 Subject: [PATCH] added missing test case --- test/unit.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/unit.cpp b/test/unit.cpp index a41154a8..e819e5fd 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -2204,43 +2204,61 @@ TEST_CASE("element access") SECTION("null") { json j_nonobject(json::value_t::null); + const json j_const_nonobject(j_nonobject); CHECK_THROWS_AS(j_nonobject["foo"], std::runtime_error); CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject["foo"], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], std::runtime_error); } SECTION("boolean") { json j_nonobject(json::value_t::boolean); + const json j_const_nonobject(j_nonobject); CHECK_THROWS_AS(j_nonobject["foo"], std::runtime_error); CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject["foo"], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], std::runtime_error); } SECTION("string") { json j_nonobject(json::value_t::string); + const json j_const_nonobject(j_nonobject); CHECK_THROWS_AS(j_nonobject["foo"], std::runtime_error); CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject["foo"], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], std::runtime_error); } SECTION("array") { json j_nonobject(json::value_t::array); + const json j_const_nonobject(j_nonobject); CHECK_THROWS_AS(j_nonobject["foo"], std::runtime_error); CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject["foo"], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], std::runtime_error); } SECTION("number (integer)") { json j_nonobject(json::value_t::number_integer); + const json j_const_nonobject(j_nonobject); CHECK_THROWS_AS(j_nonobject["foo"], std::runtime_error); CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject["foo"], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], std::runtime_error); } SECTION("number (floating-point)") { json j_nonobject(json::value_t::number_float); + const json j_const_nonobject(j_nonobject); CHECK_THROWS_AS(j_nonobject["foo"], std::runtime_error); CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject["foo"], std::runtime_error); + CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], std::runtime_error); } } }