mirror of
https://github.com/nlohmann/json.git
synced 2025-08-05 00:46:13 +08:00
✅ add test
This commit is contained in:
parent
c190a72f3d
commit
e8dba10f53
@ -12739,7 +12739,7 @@ class json_pointer
|
|||||||
{
|
{
|
||||||
if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
|
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
|
// assign value to reference pointed to by JSON pointer; Note that if
|
||||||
|
@ -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", "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);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user