mirror of
https://github.com/nlohmann/json.git
synced 2026-02-26 13:26:28 +00:00
🚑 fix for #894
- Implemented "copy" in terms of "add". - Added check for JSON Pointer array indices to make sure the complete reference token was processed. - Added test suite from https://github.com/json-patch/json-patch-tests
This commit is contained in:
@@ -1322,4 +1322,32 @@ TEST_CASE("regression tests")
|
||||
j = ar;
|
||||
ar = j;
|
||||
}
|
||||
|
||||
SECTION("issue #894 - invalid RFC6902 copy operation succeeds")
|
||||
{
|
||||
auto model = R"({
|
||||
"one": {
|
||||
"two": {
|
||||
"three": "hello",
|
||||
"four": 42
|
||||
}
|
||||
}
|
||||
})"_json;
|
||||
|
||||
CHECK_THROWS_AS(model.patch(R"([{"op": "move",
|
||||
"from": "/one/two/three",
|
||||
"path": "/a/b/c"}])"_json), json::out_of_range);
|
||||
CHECK_THROWS_WITH(model.patch(R"([{"op": "move",
|
||||
"from": "/one/two/three",
|
||||
"path": "/a/b/c"}])"_json),
|
||||
"[json.exception.out_of_range.403] key 'a' not found");
|
||||
|
||||
CHECK_THROWS_AS(model.patch(R"([{"op": "copy",
|
||||
"from": "/one/two/three",
|
||||
"path": "/a/b/c"}])"_json), json::out_of_range);
|
||||
CHECK_THROWS_WITH(model.patch(R"([{"op": "copy",
|
||||
"from": "/one/two/three",
|
||||
"path": "/a/b/c"}])"_json),
|
||||
"[json.exception.out_of_range.403] key 'a' not found");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user