added missing test case

This commit is contained in:
Niels 2015-02-15 15:51:11 +01:00
parent af568b9b27
commit 3e885c8328

View file

@ -2204,43 +2204,61 @@ TEST_CASE("element access")
SECTION("null") SECTION("null")
{ {
json j_nonobject(json::value_t::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["foo"], std::runtime_error);
CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("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") SECTION("boolean")
{ {
json j_nonobject(json::value_t::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["foo"], std::runtime_error);
CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("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") SECTION("string")
{ {
json j_nonobject(json::value_t::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["foo"], std::runtime_error);
CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("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") SECTION("array")
{ {
json j_nonobject(json::value_t::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["foo"], std::runtime_error);
CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("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)") SECTION("number (integer)")
{ {
json j_nonobject(json::value_t::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["foo"], std::runtime_error);
CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("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)") SECTION("number (floating-point)")
{ {
json j_nonobject(json::value_t::number_float); 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["foo"], std::runtime_error);
CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("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);
} }
} }
} }