From e2162adeedc1c4fca3e2a315dca174ca80e7b644 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Thu, 11 Oct 2018 00:30:43 +0200 Subject: [PATCH] Squashed 'tests/json-patch-tests/' changes from 99264bb..9ecd703 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 9ecd703 Merge pull request #39 from mr-mixas/test-absent-from-location-for-copy-and-move-ops 66817e7 test absent 'from' location for copy and move 09dee56 Fix anonymous test 8bae8ed Fix « test should pass - no error » test 855f2a4 Fix « test should pass despite (nested) rearrangement » test 53283fc Fix « test should pass despite rearrangement » test ecf01e7 Fix « null value should be valid obj property » test 1586cdf Fix « Empty-string element » test git-subtree-dir: tests/json-patch-tests git-subtree-split: 9ecd703c08cda4864cd2d2fb580a513ec5740934 --- tests.json | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tests.json b/tests.json index 86305c1..2554078 100644 --- a/tests.json +++ b/tests.json @@ -214,6 +214,7 @@ { "doc": {"foo": null}, "patch": [{"op": "test", "path": "/foo", "value": null}], + "expected": {"foo": null}, "comment": "null value should be valid obj property" }, { "doc": {"foo": null}, @@ -243,14 +244,17 @@ { "doc": {"foo": {"foo": 1, "bar": 2}}, "patch": [{"op": "test", "path": "/foo", "value": {"bar": 2, "foo": 1}}], + "expected": {"foo": {"foo": 1, "bar": 2}}, "comment": "test should pass despite rearrangement" }, { "doc": {"foo": [{"foo": 1, "bar": 2}]}, "patch": [{"op": "test", "path": "/foo", "value": [{"bar": 2, "foo": 1}]}], + "expected": {"foo": [{"foo": 1, "bar": 2}]}, "comment": "test should pass despite (nested) rearrangement" }, { "doc": {"foo": {"bar": [1, 2, 5, 4]}}, "patch": [{"op": "test", "path": "/foo", "value": {"bar": [1, 2, 5, 4]}}], + "expected": {"foo": {"bar": [1, 2, 5, 4]}}, "comment": "test should pass - no error" }, { "doc": {"foo": {"bar": [1, 2, 5, 4]}}, @@ -264,7 +268,8 @@ { "comment": "Empty-string element", "doc": { "": 1 }, - "patch": [{"op": "test", "path": "/", "value": 1}] }, + "patch": [{"op": "test", "path": "/", "value": 1}], + "expected": { "": 1 } }, { "doc": { "foo": ["bar", "baz"], @@ -288,8 +293,23 @@ {"op": "test", "path": "/i\\j", "value": 5}, {"op": "test", "path": "/k\"l", "value": 6}, {"op": "test", "path": "/ ", "value": 7}, - {"op": "test", "path": "/m~0n", "value": 8}] }, - + {"op": "test", "path": "/m~0n", "value": 8}], + "expected": { + "": 0, + " ": 7, + "a/b": 1, + "c%d": 2, + "e^f": 3, + "foo": [ + "bar", + "baz" + ], + "g|h": 4, + "i\\j": 5, + "k\"l": 6, + "m~n": 8 + } + }, { "comment": "Move to same location has no effect", "doc": {"foo": 1}, "patch": [{"op": "move", "from": "/foo", "path": "/foo"}], @@ -388,11 +408,21 @@ "patch": [ { "op": "copy", "path": "/-" } ], "error": "missing 'from' parameter" }, + { "comment": "missing from location to copy", + "doc": { "foo": 1 }, + "patch": [ { "op": "copy", "from": "/bar", "path": "/foo" } ], + "error": "missing 'from' location" }, + { "comment": "missing from parameter to move", "doc": { "foo": 1 }, "patch": [ { "op": "move", "path": "" } ], "error": "missing 'from' parameter" }, + { "comment": "missing from location to move", + "doc": { "foo": 1 }, + "patch": [ { "op": "move", "from": "/bar", "path": "/foo" } ], + "error": "missing 'from' location" }, + { "comment": "duplicate ops", "doc": { "foo": "bar" }, "patch": [ { "op": "add", "path": "/baz", "value": "qux",