diff --git a/test/JSON-Schema-Test-Suite/remotes/folder/folderInteger.json b/test/JSON-Schema-Test-Suite/remotes/folder/folderInteger.json index dbe5c75..8b50ea3 100644 --- a/test/JSON-Schema-Test-Suite/remotes/folder/folderInteger.json +++ b/test/JSON-Schema-Test-Suite/remotes/folder/folderInteger.json @@ -1,3 +1,3 @@ { "type": "integer" -} \ No newline at end of file +} diff --git a/test/JSON-Schema-Test-Suite/remotes/integer.json b/test/JSON-Schema-Test-Suite/remotes/integer.json index dbe5c75..8b50ea3 100644 --- a/test/JSON-Schema-Test-Suite/remotes/integer.json +++ b/test/JSON-Schema-Test-Suite/remotes/integer.json @@ -1,3 +1,3 @@ { "type": "integer" -} \ No newline at end of file +} diff --git a/test/JSON-Schema-Test-Suite/remotes/name-defs.json b/test/JSON-Schema-Test-Suite/remotes/name-defs.json new file mode 100644 index 0000000..1dab4a4 --- /dev/null +++ b/test/JSON-Schema-Test-Suite/remotes/name-defs.json @@ -0,0 +1,15 @@ +{ + "$defs": { + "orNull": { + "anyOf": [ + { + "type": "null" + }, + { + "$ref": "#" + } + ] + } + }, + "type": "string" +} diff --git a/test/JSON-Schema-Test-Suite/remotes/name.json b/test/JSON-Schema-Test-Suite/remotes/name.json index 19ba093..fceacb8 100644 --- a/test/JSON-Schema-Test-Suite/remotes/name.json +++ b/test/JSON-Schema-Test-Suite/remotes/name.json @@ -2,8 +2,12 @@ "definitions": { "orNull": { "anyOf": [ - {"type": "null"}, - {"$ref": "#"} + { + "type": "null" + }, + { + "$ref": "#" + } ] } }, diff --git a/test/JSON-Schema-Test-Suite/remotes/subSchemas-defs.json b/test/JSON-Schema-Test-Suite/remotes/subSchemas-defs.json new file mode 100644 index 0000000..50b7b6d --- /dev/null +++ b/test/JSON-Schema-Test-Suite/remotes/subSchemas-defs.json @@ -0,0 +1,10 @@ +{ + "$defs": { + "integer": { + "type": "integer" + }, + "refToInteger": { + "$ref": "#/$defs/integer" + } + } +} diff --git a/test/JSON-Schema-Test-Suite/remotes/subSchemas.json b/test/JSON-Schema-Test-Suite/remotes/subSchemas.json index 8b6d8f8..9f8030b 100644 --- a/test/JSON-Schema-Test-Suite/remotes/subSchemas.json +++ b/test/JSON-Schema-Test-Suite/remotes/subSchemas.json @@ -1,8 +1,8 @@ { "integer": { "type": "integer" - }, + }, "refToInteger": { "$ref": "#/integer" } -} \ No newline at end of file +} diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/allOf.json b/test/JSON-Schema-Test-Suite/tests/draft7/allOf.json index eb61209..cff8251 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/allOf.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/allOf.json @@ -214,5 +214,31 @@ "valid": false } ] + }, + { + "description": "nested allOf, to check validation semantics", + "schema": { + "allOf": [ + { + "allOf": [ + { + "type": "null" + } + ] + } + ] + }, + "tests": [ + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "anything non-null is invalid", + "data": 123, + "valid": false + } + ] } ] diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/anyOf.json b/test/JSON-Schema-Test-Suite/tests/draft7/anyOf.json index ab5eb38..b720afa 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/anyOf.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/anyOf.json @@ -160,6 +160,32 @@ } ] }, + { + "description": "nested anyOf, to check validation semantics", + "schema": { + "anyOf": [ + { + "anyOf": [ + { + "type": "null" + } + ] + } + ] + }, + "tests": [ + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "anything non-null is invalid", + "data": 123, + "valid": false + } + ] + }, { "description": "nested anyOf, to check validation semantics", "schema": { diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/const.json b/test/JSON-Schema-Test-Suite/tests/draft7/const.json index c089625..1a55235 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/const.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/const.json @@ -126,7 +126,7 @@ ] }, { - "description": "const with 0 does not match false", + "description": "const with 0 does not match other zero-like types", "schema": {"const": 0}, "tests": [ { @@ -143,6 +143,21 @@ "description": "float zero is valid", "data": 0.0, "valid": true + }, + { + "description": "empty object is invalid", + "data": {}, + "valid": false + }, + { + "description": "empty array is invalid", + "data": [], + "valid": false + }, + { + "description": "empty string is invalid", + "data": "", + "valid": false } ] }, @@ -166,5 +181,62 @@ "valid": true } ] + }, + { + "description": "const with -2.0 matches integer and float types", + "schema": {"const": -2.0}, + "tests": [ + { + "description": "integer -2 is valid", + "data": -2, + "valid": true + }, + { + "description": "integer 2 is invalid", + "data": 2, + "valid": false + }, + { + "description": "float -2.0 is valid", + "data": -2.0, + "valid": true + }, + { + "description": "float 2.0 is invalid", + "data": 2.0, + "valid": false + }, + { + "description": "float -2.00001 is invalid", + "data": -2.00001, + "valid": false + } + ] + }, + { + "description": "float and integers are equal up to 64-bit representation limits", + "schema": {"const": 9007199254740992}, + "tests": [ + { + "description": "integer is valid", + "data": 9007199254740992, + "valid": true + }, + { + "description": "integer minus one is invalid", + "data": 9007199254740991, + "valid": false + }, + { + "description": "float is valid", + "data": 9007199254740992.0, + "valid": true + }, + { + "description": "float minus one is invalid", + "data": 9007199254740991.0, + "valid": false + } + ] } ] diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/dependencies.json b/test/JSON-Schema-Test-Suite/tests/draft7/dependencies.json index 8dd78aa..a5e5428 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/dependencies.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/dependencies.json @@ -57,6 +57,11 @@ "description": "object with one property", "data": {"bar": 2}, "valid": true + }, + { + "description": "non-object is valid", + "data": 1, + "valid": true } ] }, @@ -169,31 +174,6 @@ } ] }, - { - "description": "empty array of dependencies", - "schema": { - "dependencies": { - "foo": [] - } - }, - "tests": [ - { - "description": "object with property is valid", - "data": { "foo": 1 }, - "valid": true - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - }, - { - "description": "non-object is valid", - "data": 1, - "valid": true - } - ] - }, { "description": "dependencies with escaped characters", "schema": { diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/enum.json b/test/JSON-Schema-Test-Suite/tests/draft7/enum.json index 32d7902..0191b55 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/enum.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/enum.json @@ -36,6 +36,27 @@ } ] }, + { + "description": "heterogeneous enum-with-null validation", + "schema": { "enum": [6, null] }, + "tests": [ + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "number is valid", + "data": 6, + "valid": true + }, + { + "description": "something else is invalid", + "data": "test", + "valid": false + } + ] + }, { "description": "enums in properties", "schema": { @@ -52,6 +73,16 @@ "data": {"foo":"foo", "bar":"bar"}, "valid": true }, + { + "description": "wrong foo value", + "data": {"foo":"foot", "bar":"bar"}, + "valid": false + }, + { + "description": "wrong bar value", + "data": {"foo":"foo", "bar":"bart"}, + "valid": false + }, { "description": "missing optional property is valid", "data": {"bar":"bar"}, diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/format.json b/test/JSON-Schema-Test-Suite/tests/draft7/format.json new file mode 100644 index 0000000..93305f5 --- /dev/null +++ b/test/JSON-Schema-Test-Suite/tests/draft7/format.json @@ -0,0 +1,614 @@ +[ + { + "description": "validation of e-mail addresses", + "schema": {"format": "email"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of IDN e-mail addresses", + "schema": {"format": "idn-email"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of regexes", + "schema": {"format": "regex"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of IP addresses", + "schema": {"format": "ipv4"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of IPv6 addresses", + "schema": {"format": "ipv6"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of IDN hostnames", + "schema": {"format": "idn-hostname"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of hostnames", + "schema": {"format": "hostname"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of date strings", + "schema": {"format": "date"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of date-time strings", + "schema": {"format": "date-time"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of time strings", + "schema": {"format": "time"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of JSON pointers", + "schema": {"format": "json-pointer"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of relative JSON pointers", + "schema": {"format": "relative-json-pointer"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of IRIs", + "schema": {"format": "iri"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of IRI references", + "schema": {"format": "iri-reference"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of URIs", + "schema": {"format": "uri"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of URI references", + "schema": {"format": "uri-reference"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "validation of URI templates", + "schema": {"format": "uri-template"}, + "tests": [ + { + "description": "ignores integers", + "data": 12, + "valid": true + }, + { + "description": "ignores floats", + "data": 13.7, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores booleans", + "data": false, + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + } +] diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/maximum.json b/test/JSON-Schema-Test-Suite/tests/draft7/maximum.json index 8150984..6844a39 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/maximum.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/maximum.json @@ -24,5 +24,31 @@ "valid": true } ] + }, + { + "description": "maximum validation with unsigned integer", + "schema": {"maximum": 300}, + "tests": [ + { + "description": "below the maximum is invalid", + "data": 299.97, + "valid": true + }, + { + "description": "boundary point integer is valid", + "data": 300, + "valid": true + }, + { + "description": "boundary point float is valid", + "data": 300.00, + "valid": true + }, + { + "description": "above the maximum is invalid", + "data": 300.5, + "valid": false + } + ] } ] diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/minimum.json b/test/JSON-Schema-Test-Suite/tests/draft7/minimum.json index 2a9c42b..21ae50e 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/minimum.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/minimum.json @@ -45,7 +45,17 @@ "valid": true }, { - "description": "below the minimum is invalid", + "description": "boundary point with float is valid", + "data": -2.0, + "valid": true + }, + { + "description": "float below the minimum is invalid", + "data": -2.0001, + "valid": false + }, + { + "description": "int below the minimum is invalid", "data": -3, "valid": false }, diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/oneOf.json b/test/JSON-Schema-Test-Suite/tests/draft7/oneOf.json index 76ca96c..eeb7ae8 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/oneOf.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/oneOf.json @@ -244,5 +244,31 @@ "valid": false } ] + }, + { + "description": "nested oneOf, to check validation semantics", + "schema": { + "oneOf": [ + { + "oneOf": [ + { + "type": "null" + } + ] + } + ] + }, + "tests": [ + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "anything non-null is invalid", + "data": 123, + "valid": false + } + ] } ] diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/optional/format/ecmascript-regex.json b/test/JSON-Schema-Test-Suite/tests/draft7/optional/format/ecmascript-regex.json new file mode 100644 index 0000000..106c33b --- /dev/null +++ b/test/JSON-Schema-Test-Suite/tests/draft7/optional/format/ecmascript-regex.json @@ -0,0 +1,213 @@ +[ + { + "description": "ECMA 262 regex non-compliance", + "schema": { "format": "regex" }, + "tests": [ + { + "description": "ECMA 262 has no support for \\Z anchor from .NET", + "data": "^\\S(|(.|\\n)*\\S)\\Z", + "valid": false + } + ] + }, + { + "description": "ECMA 262 regex $ does not match trailing newline", + "schema": { + "type": "string", + "pattern": "^abc$" + }, + "tests": [ + { + "description": "matches in Python, but should not in jsonschema", + "data": "abc\n", + "valid": false + }, + { + "description": "should match", + "data": "abc", + "valid": true + } + ] + }, + { + "description": "ECMA 262 regex converts \\t to horizontal tab", + "schema": { + "type": "string", + "pattern": "^\\t$" + }, + "tests": [ + { + "description": "does not match", + "data": "\\t", + "valid": false + }, + { + "description": "matches", + "data": "\u0009", + "valid": true + } + ] + }, + { + "description": "ECMA 262 regex escapes control codes with \\c and upper letter", + "schema": { + "type": "string", + "pattern": "^\\cC$" + }, + "tests": [ + { + "description": "does not match", + "data": "\\cC", + "valid": false + }, + { + "description": "matches", + "data": "\u0003", + "valid": true + } + ] + }, + { + "description": "ECMA 262 regex escapes control codes with \\c and lower letter", + "schema": { + "type": "string", + "pattern": "^\\cc$" + }, + "tests": [ + { + "description": "does not match", + "data": "\\cc", + "valid": false + }, + { + "description": "matches", + "data": "\u0003", + "valid": true + } + ] + }, + { + "description": "ECMA 262 \\d matches ascii digits only", + "schema": { + "type": "string", + "pattern": "^\\d$" + }, + "tests": [ + { + "description": "ASCII zero matches", + "data": "0", + "valid": true + }, + { + "description": "NKO DIGIT ZERO does not match (unlike e.g. Python)", + "data": "߀", + "valid": false + }, + { + "description": "NKO DIGIT ZERO (as \\u escape) does not match", + "data": "\u07c0", + "valid": false + } + ] + }, + { + "description": "ECMA 262 \\D matches everything but ascii digits", + "schema": { + "type": "string", + "pattern": "^\\D$" + }, + "tests": [ + { + "description": "ASCII zero does not match", + "data": "0", + "valid": false + }, + { + "description": "NKO DIGIT ZERO matches (unlike e.g. Python)", + "data": "߀", + "valid": true + }, + { + "description": "NKO DIGIT ZERO (as \\u escape) matches", + "data": "\u07c0", + "valid": true + } + ] + }, + { + "description": "ECMA 262 \\w matches ascii letters only", + "schema": { + "type": "string", + "pattern": "^\\w$" + }, + "tests": [ + { + "description": "ASCII 'a' matches", + "data": "a", + "valid": true + }, + { + "description": "latin-1 e-acute does not match (unlike e.g. Python)", + "data": "é", + "valid": false + } + ] + }, + { + "description": "ECMA 262 \\w matches everything but ascii letters", + "schema": { + "type": "string", + "pattern": "^\\W$" + }, + "tests": [ + { + "description": "ASCII 'a' does not match", + "data": "a", + "valid": false + }, + { + "description": "latin-1 e-acute matches (unlike e.g. Python)", + "data": "é", + "valid": true + } + ] + }, + { + "description": "ECMA 262 \\s matches ascii whitespace only", + "schema": { + "type": "string", + "pattern": "^\\s$" + }, + "tests": [ + { + "description": "ASCII space matches", + "data": " ", + "valid": true + }, + { + "description": "latin-1 non-breaking-space does not match (unlike e.g. Python)", + "data": "\u00a0", + "valid": false + } + ] + }, + { + "description": "ECMA 262 \\S matches everything but ascii whitespace", + "schema": { + "type": "string", + "pattern": "^\\S$" + }, + "tests": [ + { + "description": "ASCII space does not match", + "data": " ", + "valid": false + }, + { + "description": "latin-1 non-breaking-space matches (unlike e.g. Python)", + "data": "\u00a0", + "valid": true + } + ] + } +] diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/optional/format/relative-json-pointer.json b/test/JSON-Schema-Test-Suite/tests/draft7/optional/format/relative-json-pointer.json index ceeb743..17816c9 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/optional/format/relative-json-pointer.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/optional/format/relative-json-pointer.json @@ -9,7 +9,7 @@ "valid": true }, { - "description": "a valid downwards RJP", + "description": "a valid downwards RJP", "data": "0/foo/bar", "valid": true }, @@ -27,6 +27,11 @@ "description": "an invalid RJP that is a valid JSON Pointer", "data": "/foo/bar", "valid": false + }, + { + "description": "negative prefix", + "data": "-1/foo/bar", + "valid": false } ] } diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/optional/non-bmp-regex.json b/test/JSON-Schema-Test-Suite/tests/draft7/optional/non-bmp-regex.json new file mode 100644 index 0000000..dd67af2 --- /dev/null +++ b/test/JSON-Schema-Test-Suite/tests/draft7/optional/non-bmp-regex.json @@ -0,0 +1,82 @@ +[ + { + "description": "Proper UTF-16 surrogate pair handling: pattern", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { "pattern": "^🐲*$" }, + "tests": [ + { + "description": "matches empty", + "data": "", + "valid": true + }, + { + "description": "matches single", + "data": "🐲", + "valid": true + }, + { + "description": "matches two", + "data": "🐲🐲", + "valid": true + }, + { + "description": "doesn't match one", + "data": "🐉", + "valid": false + }, + { + "description": "doesn't match two", + "data": "🐉🐉", + "valid": false + }, + { + "description": "doesn't match one ASCII", + "data": "D", + "valid": false + }, + { + "description": "doesn't match two ASCII", + "data": "DD", + "valid": false + } + ] + }, + { + "description": "Proper UTF-16 surrogate pair handling: patternProperties", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { + "patternProperties": { + "^🐲*$": { + "type": "integer" + } + } + }, + "tests": [ + { + "description": "matches empty", + "data": { "": 1 }, + "valid": true + }, + { + "description": "matches single", + "data": { "🐲": 1 }, + "valid": true + }, + { + "description": "matches two", + "data": { "🐲🐲": 1 }, + "valid": true + }, + { + "description": "doesn't match one", + "data": { "🐲": "hello" }, + "valid": false + }, + { + "description": "doesn't match two", + "data": { "🐲🐲": "hello" }, + "valid": false + } + ] + } +] diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/pattern.json b/test/JSON-Schema-Test-Suite/tests/draft7/pattern.json index 25e7299..92db0f9 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/pattern.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/pattern.json @@ -14,9 +14,34 @@ "valid": false }, { - "description": "ignores non-strings", + "description": "ignores booleans", "data": true, "valid": true + }, + { + "description": "ignores integers", + "data": 123, + "valid": true + }, + { + "description": "ignores floats", + "data": 1.0, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true } ] }, diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/ref.json b/test/JSON-Schema-Test-Suite/tests/draft7/ref.json index 230c6d0..44b8ed2 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/ref.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/ref.json @@ -271,7 +271,7 @@ "tests": [ { "description": "valid tree", - "data": { + "data": { "meta": "root", "nodes": [ { @@ -300,7 +300,7 @@ }, { "description": "invalid tree", - "data": { + "data": { "meta": "root", "nodes": [ { diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/type.json b/test/JSON-Schema-Test-Suite/tests/draft7/type.json index ea33b18..8304647 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/type.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/type.json @@ -8,6 +8,11 @@ "data": 1, "valid": true }, + { + "description": "a float with zero fractional part is an integer", + "data": 1.0, + "valid": true + }, { "description": "a float is not an integer", "data": 1.1, @@ -54,6 +59,11 @@ "data": 1, "valid": true }, + { + "description": "a float with zero fractional part is a number (and an integer)", + "data": 1.0, + "valid": true + }, { "description": "a float is a number", "data": 1.1, diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json b/test/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json index d0a94d8..ea256a0 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json @@ -169,5 +169,176 @@ "valid": false } ] + }, + { + "description": "uniqueItems=false validation", + "schema": { "uniqueItems": false }, + "tests": [ + { + "description": "unique array of integers is valid", + "data": [1, 2], + "valid": true + }, + { + "description": "non-unique array of integers is valid", + "data": [1, 1], + "valid": true + }, + { + "description": "numbers are unique if mathematically unequal", + "data": [1.0, 1.00, 1], + "valid": true + }, + { + "description": "false is not equal to zero", + "data": [0, false], + "valid": true + }, + { + "description": "true is not equal to one", + "data": [1, true], + "valid": true + }, + { + "description": "unique array of objects is valid", + "data": [{"foo": "bar"}, {"foo": "baz"}], + "valid": true + }, + { + "description": "non-unique array of objects is valid", + "data": [{"foo": "bar"}, {"foo": "bar"}], + "valid": true + }, + { + "description": "unique array of nested objects is valid", + "data": [ + {"foo": {"bar" : {"baz" : true}}}, + {"foo": {"bar" : {"baz" : false}}} + ], + "valid": true + }, + { + "description": "non-unique array of nested objects is valid", + "data": [ + {"foo": {"bar" : {"baz" : true}}}, + {"foo": {"bar" : {"baz" : true}}} + ], + "valid": true + }, + { + "description": "unique array of arrays is valid", + "data": [["foo"], ["bar"]], + "valid": true + }, + { + "description": "non-unique array of arrays is valid", + "data": [["foo"], ["foo"]], + "valid": true + }, + { + "description": "1 and true are unique", + "data": [1, true], + "valid": true + }, + { + "description": "0 and false are unique", + "data": [0, false], + "valid": true + }, + { + "description": "unique heterogeneous types are valid", + "data": [{}, [1], true, null, 1], + "valid": true + }, + { + "description": "non-unique heterogeneous types are valid", + "data": [{}, [1], true, null, {}, 1], + "valid": true + } + ] + }, + { + "description": "uniqueItems=false with an array of items", + "schema": { + "items": [{"type": "boolean"}, {"type": "boolean"}], + "uniqueItems": false + }, + "tests": [ + { + "description": "[false, true] from items array is valid", + "data": [false, true], + "valid": true + }, + { + "description": "[true, false] from items array is valid", + "data": [true, false], + "valid": true + }, + { + "description": "[false, false] from items array is valid", + "data": [false, false], + "valid": true + }, + { + "description": "[true, true] from items array is valid", + "data": [true, true], + "valid": true + }, + { + "description": "unique array extended from [false, true] is valid", + "data": [false, true, "foo", "bar"], + "valid": true + }, + { + "description": "unique array extended from [true, false] is valid", + "data": [true, false, "foo", "bar"], + "valid": true + }, + { + "description": "non-unique array extended from [false, true] is valid", + "data": [false, true, "foo", "foo"], + "valid": true + }, + { + "description": "non-unique array extended from [true, false] is valid", + "data": [true, false, "foo", "foo"], + "valid": true + } + ] + }, + { + "description": "uniqueItems=false with an array of items and additionalItems=false", + "schema": { + "items": [{"type": "boolean"}, {"type": "boolean"}], + "uniqueItems": false, + "additionalItems": false + }, + "tests": [ + { + "description": "[false, true] from items array is valid", + "data": [false, true], + "valid": true + }, + { + "description": "[true, false] from items array is valid", + "data": [true, false], + "valid": true + }, + { + "description": "[false, false] from items array is valid", + "data": [false, false], + "valid": true + }, + { + "description": "[true, true] from items array is valid", + "data": [true, true], + "valid": true + }, + { + "description": "extra items are invalid even if unique", + "data": [false, true, null], + "valid": false + } + ] } ]