diff options
author | Julian Berman <Julian@GrayVines.com> | 2019-03-31 09:38:07 -0400 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2019-03-31 09:38:07 -0400 |
commit | eb60af03a05771bdfa07256b54b71aef8c055a3b (patch) | |
tree | ba6a15303ce8be0a7bb4092ead1da89a9df413ff /tests/draft4 | |
parent | a1ade0ac5e44e4314cf5dd35f6d9af3d44f34acd (diff) | |
download | jsonschema-eb60af03a05771bdfa07256b54b71aef8c055a3b.tar.gz |
Squashed 'json/' changes from 3c3881a..15ba997
15ba997 Merge pull request #259 from epoberezkin/epoberezkin/special-chars
6f74063 ref with quote
5bb7a0d dependencies with escaped characters
96085b7 enum with escaped characters
4019147 required with escaped characters
6e97672 properties with escaped characters
92eeeb4 Merge pull request #258 from gzzi/master
60d5ff4 Add test with negative integer for minimum in draft 3/4/6
25710d0 Add test with negative integer for minimum
git-subtree-dir: json
git-subtree-split: 15ba997f9b937150a0ab88244d1d0fbf58526c48
Diffstat (limited to 'tests/draft4')
-rw-r--r-- | tests/draft4/dependencies.json | 71 | ||||
-rw-r--r-- | tests/draft4/enum.json | 23 | ||||
-rw-r--r-- | tests/draft4/minimum.json | 31 | ||||
-rw-r--r-- | tests/draft4/properties.json | 39 | ||||
-rw-r--r-- | tests/draft4/ref.json | 27 | ||||
-rw-r--r-- | tests/draft4/required.json | 35 |
6 files changed, 226 insertions, 0 deletions
diff --git a/tests/draft4/dependencies.json b/tests/draft4/dependencies.json index 38effa1..51eeddf 100644 --- a/tests/draft4/dependencies.json +++ b/tests/draft4/dependencies.json @@ -119,5 +119,76 @@ "valid": false } ] + }, + { + "description": "dependencies with escaped characters", + "schema": { + "dependencies": { + "foo\nbar": ["foo\rbar"], + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": {"required": ["foo\"bar"]}, + "foo\"bar": ["foo'bar"] + } + }, + "tests": [ + { + "description": "valid object 1", + "data": { + "foo\nbar": 1, + "foo\rbar": 2 + }, + "valid": true + }, + { + "description": "valid object 2", + "data": { + "foo\tbar": 1, + "a": 2, + "b": 3, + "c": 4 + }, + "valid": true + }, + { + "description": "valid object 3", + "data": { + "foo'bar": 1, + "foo\"bar": 2 + }, + "valid": true + }, + { + "description": "invalid object 1", + "data": { + "foo\nbar": 1, + "foo": 2 + }, + "valid": false + }, + { + "description": "invalid object 2", + "data": { + "foo\tbar": 1, + "a": 2 + }, + "valid": false + }, + { + "description": "invalid object 3", + "data": { + "foo'bar": 1 + }, + "valid": false + }, + { + "description": "invalid object 4", + "data": { + "foo\"bar": 2 + }, + "valid": false + } + ] } ] diff --git a/tests/draft4/enum.json b/tests/draft4/enum.json index 8fb9d7a..04a92a4 100644 --- a/tests/draft4/enum.json +++ b/tests/draft4/enum.json @@ -68,5 +68,28 @@ "valid": false } ] + }, + { + "description": "enum with escaped characters", + "schema": { + "enum": ["foo\nbar", "foo\rbar"] + }, + "tests": [ + { + "description": "member 1 is valid", + "data": "foo\nbar", + "valid": true + }, + { + "description": "member 2 is valid", + "data": "foo\rbar", + "valid": true + }, + { + "description": "another string is invalid", + "data": "abc", + "valid": false + } + ] } ] diff --git a/tests/draft4/minimum.json b/tests/draft4/minimum.json index 98f08d5..6becf2a 100644 --- a/tests/draft4/minimum.json +++ b/tests/draft4/minimum.json @@ -69,5 +69,36 @@ "valid": false } ] + }, + { + "description": "minimum validation with signed integer", + "schema": {"minimum": -2}, + "tests": [ + { + "description": "negative above the minimum is valid", + "data": -1, + "valid": true + }, + { + "description": "positive above the minimum is valid", + "data": 0, + "valid": true + }, + { + "description": "boundary point is valid", + "data": -2, + "valid": true + }, + { + "description": "below the minimum is invalid", + "data": -3, + "valid": false + }, + { + "description": "ignores non-numbers", + "data": "x", + "valid": true + } + ] } ] diff --git a/tests/draft4/properties.json b/tests/draft4/properties.json index a830c67..688527b 100644 --- a/tests/draft4/properties.json +++ b/tests/draft4/properties.json @@ -93,5 +93,44 @@ "valid": false } ] + }, + { + "description": "properties with escaped characters", + "schema": { + "properties": { + "foo\nbar": {"type": "number"}, + "foo\"bar": {"type": "number"}, + "foo\\bar": {"type": "number"}, + "foo\rbar": {"type": "number"}, + "foo\tbar": {"type": "number"}, + "foo\fbar": {"type": "number"} + } + }, + "tests": [ + { + "description": "object with all numbers is valid", + "data": { + "foo\nbar": 1, + "foo\"bar": 1, + "foo\\bar": 1, + "foo\rbar": 1, + "foo\tbar": 1, + "foo\fbar": 1 + }, + "valid": true + }, + { + "description": "object with strings is invalid", + "data": { + "foo\nbar": "1", + "foo\"bar": "1", + "foo\\bar": "1", + "foo\rbar": "1", + "foo\tbar": "1", + "foo\fbar": "1" + }, + "valid": false + } + ] } ] diff --git a/tests/draft4/ref.json b/tests/draft4/ref.json index 52cf50a..1541caf 100644 --- a/tests/draft4/ref.json +++ b/tests/draft4/ref.json @@ -296,5 +296,32 @@ "valid": false } ] + }, + { + "description": "refs with quote", + "schema": { + "properties": { + "foo\"bar": {"$ref": "#/definitions/foo\"bar"} + }, + "definitions": { + "foo\"bar": {"type": "number"} + } + }, + "tests": [ + { + "description": "object with numbers is valid", + "data": { + "foo\"bar": 1 + }, + "valid": true + }, + { + "description": "object with strings is invalid", + "data": { + "foo\"bar": "1" + }, + "valid": false + } + ] } ] diff --git a/tests/draft4/required.json b/tests/draft4/required.json index 1e2a4f0..9b05318 100644 --- a/tests/draft4/required.json +++ b/tests/draft4/required.json @@ -50,5 +50,40 @@ "valid": true } ] + }, + { + "description": "required with escaped characters", + "schema": { + "required": [ + "foo\nbar", + "foo\"bar", + "foo\\bar", + "foo\rbar", + "foo\tbar", + "foo\fbar" + ] + }, + "tests": [ + { + "description": "object with all properties present is valid", + "data": { + "foo\nbar": 1, + "foo\"bar": 1, + "foo\\bar": 1, + "foo\rbar": 1, + "foo\tbar": 1, + "foo\fbar": 1 + }, + "valid": true + }, + { + "description": "object with some properties missing is invalid", + "data": { + "foo\nbar": "1", + "foo\"bar": "1" + }, + "valid": false + } + ] } ] |