1
0
mirror of https://github.com/nlohmann/json synced 2024-11-23 04:20:06 +00:00

add test

This commit is contained in:
Niels Lohmann 2021-01-24 17:45:48 +01:00
parent c190a72f3d
commit e8dba10f53
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
2 changed files with 8 additions and 1 deletions

View File

@ -12739,7 +12739,7 @@ class json_pointer
{
if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
{
JSON_THROW(detail::type_error::create(315, "values in object must be primitive", diagnostics_t(element)));
JSON_THROW(detail::type_error::create(315, "values in object must be primitive", diagnostics_t(element.second)));
}
// assign value to reference pointed to by JSON pointer; Note that if

View File

@ -101,4 +101,11 @@ TEST_CASE("Better diagnostics")
CHECK_THROWS_WITH_AS(json({"0", "0"})[1].get<int>(), "[json.exception.type_error.302] (/1) type must be number, but is string", json::type_error);
CHECK_THROWS_WITH_AS(json({"0", "1"})[1].get<int>(), "[json.exception.type_error.302] (/1) type must be number, but is string", json::type_error);
}
SECTION("Regression test for https://github.com/nlohmann/json/pull/2562/files/380a613f2b5d32425021129cd1f371ddcfd54ddf#r563259793")
{
json j;
j["/foo"] = {1, 2, 3};
CHECK_THROWS_WITH_AS(j.unflatten(), "[json.exception.type_error.315] (/~1foo) values in object must be primitive", json::type_error);
}
}