|
263 | 263 | "patch": [ { "op": "add", "path": "/2/1/-", "value": { "foo": [ "bar", "baz" ] } } ],
|
264 | 264 | "expected": [ 1, 2, [ 3, [ 4, 5, { "foo": [ "bar", "baz" ] } ] ] ]},
|
265 | 265 |
|
| 266 | + { "comment": "test remove with bad number should fail", |
| 267 | + "doc": {"foo": 1, "baz": [{"qux": "hello"}]}, |
| 268 | + "patch": [{"op": "remove", "path": "/baz/1e0/qux"}], |
| 269 | + "error": "remove op shouldn't remove from array with bad number" }, |
| 270 | + |
| 271 | + { "comment": "test remove on array", |
| 272 | + "doc": [1, 2, 3, 4], |
| 273 | + "patch": [{"op": "remove", "path": "/0"}], |
| 274 | + "expected": [2, 3, 4] }, |
| 275 | + |
| 276 | + { "comment": "test remove with bad index should fail", |
| 277 | + "doc": [1, 2, 3, 4], |
| 278 | + "patch": [{"op": "remove", "path": "/1e0"}], |
| 279 | + "error": "remove op shouldn't remove from array with bad number" }, |
| 280 | + |
| 281 | + { "comment": "test replace with bad number should fail", |
| 282 | + "doc": [""], |
| 283 | + "patch": [{"op": "replace", "path": "/1e0", "value": false}], |
| 284 | + "error": "replace op shouldn't replace in array with bad number" }, |
| 285 | + |
| 286 | + { "comment": "test copy with bad number should fail", |
| 287 | + "doc": {"baz": [1,2,3], "bar": 1}, |
| 288 | + "patch": [{"op": "copy", "from": "/baz/1e0", "path": "/boo"}], |
| 289 | + "error": "copy op shouldn't work with bad number" }, |
| 290 | + |
| 291 | + { "comment": "test move with bad number should fail", |
| 292 | + "doc": {"foo": 1, "baz": [1,2,3,4]}, |
| 293 | + "patch": [{"op": "move", "from": "/baz/1e0", "path": "/foo"}], |
| 294 | + "error": "move op shouldn't work with bad number" }, |
| 295 | + |
| 296 | + { "comment": "test add with bad number should fail", |
| 297 | + "doc": ["foo", "sil"], |
| 298 | + "patch": [{"op": "add", "path": "/1e0", "value": "bar"}], |
| 299 | + "error": "add op shouldn't add to array with bad number" }, |
| 300 | + |
266 | 301 | { "comment": "tests complete" }
|
267 | 302 | ]
|
0 commit comments