From b7b79fc6bed0db1119d23d6e77e692c4565e8c4c Mon Sep 17 00:00:00 2001 From: Michael Szwarc <msc@incowia.com> Date: Fri, 9 Jun 2017 18:03:15 +0200 Subject: [PATCH 1/2] extended tests for json-pointer format --- tests/draft6/optional/format.json | 120 +++++++++++++++++++++++++++--- 1 file changed, 110 insertions(+), 10 deletions(-) diff --git a/tests/draft6/optional/format.json b/tests/draft6/optional/format.json index 677891cd..e17d46a8 100644 --- a/tests/draft6/optional/format.json +++ b/tests/draft6/optional/format.json @@ -220,7 +220,7 @@ ] }, { - "description": "validation of JSON-pointers", + "description": "validation of JSON-pointers (JSON String Representation)", "schema": {"format": "json-pointer"}, "tests": [ { @@ -229,29 +229,129 @@ "valid": true }, { - "description": "empty string is valid", + "description": "not a valid JSON-pointer (~ not escaped)", + "data": "/foo/bar~", + "valid": false + }, + { + "description": "valid JSON-pointer with empty segment", + "data": "/foo//bar", + "valid": true + }, + { + "description": "valid JSON-pointer with the last empty segment", + "data": "/foo/bar/", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #1", "data": "", "valid": true }, { - "description": "/ is valid", + "description": "valid JSON-pointer as stated in RFC 6901 #2", + "data": "/foo", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #3", + "data": "/foo/0", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #4", "data": "/", "valid": true }, { - "description": "not a valid JSON-pointer (~ not escaped)", - "data": "/foo/bar~", - "valid": false + "description": "valid JSON-pointer as stated in RFC 6901 #5", + "data": "/a~1b", + "valid": true }, { - "description": "valid JSON-pointer with empty segment", - "data": "/foo//bar", + "description": "valid JSON-pointer as stated in RFC 6901 #6", + "data": "/c%d", "valid": true }, { - "description": "valid JSON-pointer with the last empty segment", - "data": "/foo/bar/", + "description": "valid JSON-pointer as stated in RFC 6901 #7", + "data": "/e^f", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #8", + "data": "/g|h", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #9", + "data": "/i\\j", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #10", + "data": "/k\"l", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #11", + "data": "/ ", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #12", + "data": "/m~0n", + "valid": true + }, + { + "description": "valid JSON-pointer used to add something to the last position of an array", + "data": "/foo/-", "valid": true + }, + { + "description": "valid JSON-pointer (- used as object member name)", + "data": "/foo/-/bar", + "valid": true + }, + { + "description": "valid JSON-pointer (multiple escaped characters)", + "data": "/~1~0~0~1~1", + "valid": true + }, + { + "description": "not a valid JSON-pointer (URI Fragment Identifier Representation) #1", + "data": "#", + "valid": false + }, + { + "description": "not a valid JSON-pointer (URI Fragment Identifier Representation) #2", + "data": "#/", + "valid": false + }, + { + "description": "not a valid JSON-pointer (URI Fragment Identifier)", + "data": "#a", + "valid": false + }, + { + "description": "not a valid JSON-pointer (some escaped, but not all)", + "data": "/~0~", + "valid": false + }, + { + "description": "not a valid JSON-pointer (multiple characters not escaped)", + "data": "/~~", + "valid": false + }, + { + "description": "not a valid JSON-pointer (isn't empty nor starts with /) #1", + "data": "a", + "valid": false + }, + { + "description": "not a valid JSON-pointer (isn't empty nor starts with /) #2", + "data": "0", + "valid": false } ] } From 85a552f53048bb9a5025560e2e96b70be68396d6 Mon Sep 17 00:00:00 2001 From: Michael Szwarc <CroniD@users.noreply.github.com> Date: Fri, 9 Jun 2017 18:38:26 +0200 Subject: [PATCH 2/2] added some more tests for json-pointer format --- tests/draft6/optional/format.json | 32 ++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/draft6/optional/format.json b/tests/draft6/optional/format.json index e17d46a8..daad68b1 100644 --- a/tests/draft6/optional/format.json +++ b/tests/draft6/optional/format.json @@ -318,6 +318,16 @@ "data": "/~1~0~0~1~1", "valid": true }, + { + "description": "valid JSON-pointer (escaped characters with fraction part) #1", + "data": "/~1.1", + "valid": true + }, + { + "description": "valid JSON-pointer (escaped characters with fraction part) #2", + "data": "/~0.1", + "valid": true + }, { "description": "not a valid JSON-pointer (URI Fragment Identifier Representation) #1", "data": "#", @@ -334,10 +344,25 @@ "valid": false }, { - "description": "not a valid JSON-pointer (some escaped, but not all)", + "description": "not a valid JSON-pointer (some escaped, but not all) #1", "data": "/~0~", "valid": false }, + { + "description": "not a valid JSON-pointer (some escaped, but not all) #2", + "data": "/~0/~", + "valid": false + }, + { + "description": "not a valid JSON-pointer (wrong escape character) #1", + "data": "/~2", + "valid": false + }, + { + "description": "not a valid JSON-pointer (wrong escape character) #2", + "data": "/~-1", + "valid": false + }, { "description": "not a valid JSON-pointer (multiple characters not escaped)", "data": "/~~", @@ -352,6 +377,11 @@ "description": "not a valid JSON-pointer (isn't empty nor starts with /) #2", "data": "0", "valid": false + }, + { + "description": "not a valid JSON-pointer (isn't empty nor starts with /) #2", + "data": "a/a", + "valid": false } ] }