summaryrefslogtreecommitdiff
path: root/json/tests/draft4
diff options
context:
space:
mode:
Diffstat (limited to 'json/tests/draft4')
-rw-r--r--json/tests/draft4/optional/ecmascript-regex.json260
-rw-r--r--json/tests/draft4/optional/format/date-time.json37
-rw-r--r--json/tests/draft4/optional/format/email.json32
-rw-r--r--json/tests/draft4/optional/format/hostname.json38
-rw-r--r--json/tests/draft4/optional/format/ipv4.json32
-rw-r--r--json/tests/draft4/optional/format/ipv6.json47
-rw-r--r--json/tests/draft4/optional/format/uri.json2
-rw-r--r--json/tests/draft4/optional/unicode.json146
-rw-r--r--json/tests/draft4/ref.json52
9 files changed, 485 insertions, 161 deletions
diff --git a/json/tests/draft4/optional/ecmascript-regex.json b/json/tests/draft4/optional/ecmascript-regex.json
index fb02e99..77624cf 100644
--- a/json/tests/draft4/optional/ecmascript-regex.json
+++ b/json/tests/draft4/optional/ecmascript-regex.json
@@ -288,5 +288,265 @@
"valid": true
}
]
+ },
+ {
+ "description": "unicode semantics should be used for all pattern matching",
+ "schema": { "pattern": "\\p{Letter}cole" },
+ "tests": [
+ {
+ "description": "ascii character in json string",
+ "data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.",
+ "valid": true
+ },
+ {
+ "description": "literal unicode character in json string",
+ "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
+ "valid": true
+ },
+ {
+ "description": "unicode character in hex format in string",
+ "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'\u00e9cole, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
+ "valid": true
+ },
+ {
+ "description": "unicode matching is case-sensitive",
+ "data": "LES HIVERS DE MON ENFANCE ÉTAIENT DES SAISONS LONGUES, LONGUES. NOUS VIVIONS EN TROIS LIEUX: L'ÉCOLE, L'ÉGLISE ET LA PATINOIRE; MAIS LA VRAIE VIE ÉTAIT SUR LA PATINOIRE.",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "\\w in patterns matches [A-Za-z0-9_], not unicode letters",
+ "schema": { "pattern": "\\wcole" },
+ "tests": [
+ {
+ "description": "ascii character in json string",
+ "data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.",
+ "valid": true
+ },
+ {
+ "description": "literal unicode character in json string",
+ "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
+ "valid": false
+ },
+ {
+ "description": "unicode character in hex format in string",
+ "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'\u00e9cole, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
+ "valid": false
+ },
+ {
+ "description": "unicode matching is case-sensitive",
+ "data": "LES HIVERS DE MON ENFANCE ÉTAIENT DES SAISONS LONGUES, LONGUES. NOUS VIVIONS EN TROIS LIEUX: L'ÉCOLE, L'ÉGLISE ET LA PATINOIRE; MAIS LA VRAIE VIE ÉTAIT SUR LA PATINOIRE.",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unicode characters do not match ascii ranges",
+ "schema": { "pattern": "[a-z]cole" },
+ "tests": [
+ {
+ "description": "literal unicode character in json string",
+ "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
+ "valid": false
+ },
+ {
+ "description": "unicode character in hex format in string",
+ "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'\u00e9cole, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
+ "valid": false
+ },
+ {
+ "description": "ascii characters match",
+ "data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "\\d in pattern matches [0-9], not unicode digits",
+ "schema": { "pattern": "^\\d+$" },
+ "tests": [
+ {
+ "description": "ascii digits",
+ "data": "42",
+ "valid": true
+ },
+ {
+ "description": "ascii non-digits",
+ "data": "-%#",
+ "valid": false
+ },
+ {
+ "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
+ "data": "৪২",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unicode digits are more than 0 through 9",
+ "schema": { "pattern": "^\\p{digit}+$" },
+ "tests": [
+ {
+ "description": "ascii digits",
+ "data": "42",
+ "valid": true
+ },
+ {
+ "description": "ascii non-digits",
+ "data": "-%#",
+ "valid": false
+ },
+ {
+ "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
+ "data": "৪২",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "unicode semantics should be used for all patternProperties matching",
+ "schema": {
+ "type": "object",
+ "patternProperties": {
+ "\\p{Letter}cole": {}
+ },
+ "additionalProperties": false
+ },
+ "tests": [
+ {
+ "description": "ascii character in json string",
+ "data": { "l'ecole": "pas de vraie vie" },
+ "valid": true
+ },
+ {
+ "description": "literal unicode character in json string",
+ "data": { "l'école": "pas de vraie vie" },
+ "valid": true
+ },
+ {
+ "description": "unicode character in hex format in string",
+ "data": { "l'\u00e9cole": "pas de vraie vie" },
+ "valid": true
+ },
+ {
+ "description": "unicode matching is case-sensitive",
+ "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "\\w in patternProperties matches [A-Za-z0-9_], not unicode letters",
+ "schema": {
+ "type": "object",
+ "patternProperties": {
+ "\\wcole": {}
+ },
+ "additionalProperties": false
+ },
+ "tests": [
+ {
+ "description": "ascii character in json string",
+ "data": { "l'ecole": "pas de vraie vie" },
+ "valid": true
+ },
+ {
+ "description": "literal unicode character in json string",
+ "data": { "l'école": "pas de vraie vie" },
+ "valid": false
+ },
+ {
+ "description": "unicode character in hex format in string",
+ "data": { "l'\u00e9cole": "pas de vraie vie" },
+ "valid": false
+ },
+ {
+ "description": "unicode matching is case-sensitive",
+ "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unicode characters do not match ascii ranges",
+ "schema": {
+ "type": "object",
+ "patternProperties": {
+ "[a-z]cole": {}
+ },
+ "additionalProperties": false
+ },
+ "tests": [
+ {
+ "description": "literal unicode character in json string",
+ "data": { "l'école": "pas de vraie vie" },
+ "valid": false
+ },
+ {
+ "description": "unicode character in hex format in string",
+ "data": { "l'\u00e9cole": "pas de vraie vie" },
+ "valid": false
+ },
+ {
+ "description": "ascii characters match",
+ "data": { "l'ecole": "pas de vraie vie" },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "\\d in patternProperties matches [0-9], not unicode digits",
+ "schema": {
+ "type": "object",
+ "patternProperties": {
+ "^\\d+$": {}
+ },
+ "additionalProperties": false
+ },
+ "tests": [
+ {
+ "description": "ascii digits",
+ "data": { "42": "life, the universe, and everything" },
+ "valid": true
+ },
+ {
+ "description": "ascii non-digits",
+ "data": { "-%#": "spending the year dead for tax reasons" },
+ "valid": false
+ },
+ {
+ "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
+ "data": { "৪২": "khajit has wares if you have coin" },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unicode digits are more than 0 through 9",
+ "schema": {
+ "type": "object",
+ "patternProperties": {
+ "^\\p{digit}+$": {}
+ },
+ "additionalProperties": false
+ },
+ "tests": [
+ {
+ "description": "ascii digits",
+ "data": { "42": "life, the universe, and everything" },
+ "valid": true
+ },
+ {
+ "description": "ascii non-digits",
+ "data": { "-%#": "spending the year dead for tax reasons" },
+ "valid": false
+ },
+ {
+ "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
+ "data": { "৪২": "khajit has wares if you have coin" },
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft4/optional/format/date-time.json b/json/tests/draft4/optional/format/date-time.json
index 5f911ef..119179c 100644
--- a/json/tests/draft4/optional/format/date-time.json
+++ b/json/tests/draft4/optional/format/date-time.json
@@ -1,9 +1,39 @@
[
{
"description": "validation of date-time strings",
- "schema": {"format": "date-time"},
+ "schema": { "format": "date-time" },
"tests": [
{
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
"description": "a valid date-time string",
"data": "1963-06-19T08:30:06.283185Z",
"valid": true
@@ -34,6 +64,11 @@
"valid": false
},
{
+ "description": "an invalid closing Z after time-zone offset",
+ "data": "1963-06-19T08:30:06.28123+01:00Z",
+ "valid": false
+ },
+ {
"description": "an invalid date-time string",
"data": "06/19/1963 08:30:06 PST",
"valid": false
diff --git a/json/tests/draft4/optional/format/email.json b/json/tests/draft4/optional/format/email.json
index 02396d2..d6761a4 100644
--- a/json/tests/draft4/optional/format/email.json
+++ b/json/tests/draft4/optional/format/email.json
@@ -1,9 +1,39 @@
[
{
"description": "validation of e-mail addresses",
- "schema": {"format": "email"},
+ "schema": { "format": "email" },
"tests": [
{
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
"description": "a valid e-mail address",
"data": "joe.bloggs@example.com",
"valid": true
diff --git a/json/tests/draft4/optional/format/hostname.json b/json/tests/draft4/optional/format/hostname.json
index e913aba..8a67fda 100644
--- a/json/tests/draft4/optional/format/hostname.json
+++ b/json/tests/draft4/optional/format/hostname.json
@@ -1,14 +1,49 @@
[
{
"description": "validation of host names",
- "schema": {"format": "hostname"},
+ "schema": { "format": "hostname" },
"tests": [
{
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
"description": "a valid host name",
"data": "www.example.com",
"valid": true
},
{
+ "description": "a valid punycoded IDN hostname",
+ "data": "xn--4gbwdl.xn--wgbh1c",
+ "valid": true
+ },
+ {
"description": "a host name starting with an illegal character",
"data": "-a-host-name-that-starts-with--",
"valid": false
@@ -61,4 +96,3 @@
]
}
]
-
diff --git a/json/tests/draft4/optional/format/ipv4.json b/json/tests/draft4/optional/format/ipv4.json
index 4d10927..6b166c7 100644
--- a/json/tests/draft4/optional/format/ipv4.json
+++ b/json/tests/draft4/optional/format/ipv4.json
@@ -1,9 +1,39 @@
[
{
"description": "validation of IP addresses",
- "schema": {"format": "ipv4"},
+ "schema": { "format": "ipv4" },
"tests": [
{
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
"description": "a valid IP address",
"data": "192.168.0.1",
"valid": true
diff --git a/json/tests/draft4/optional/format/ipv6.json b/json/tests/draft4/optional/format/ipv6.json
index cf629c6..6379927 100644
--- a/json/tests/draft4/optional/format/ipv6.json
+++ b/json/tests/draft4/optional/format/ipv6.json
@@ -1,9 +1,39 @@
[
{
"description": "validation of IPv6 addresses",
- "schema": {"format": "ipv6"},
+ "schema": { "format": "ipv6" },
"tests": [
{
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
"description": "a valid IPv6 address",
"data": "::1",
"valid": true
@@ -14,6 +44,16 @@
"valid": false
},
{
+ "description": "trailing 4 hex symbols is valid",
+ "data": "::abef",
+ "valid": true
+ },
+ {
+ "description": "trailing 5 hex symbols is invalid",
+ "data": "::abcef",
+ "valid": false
+ },
+ {
"description": "an IPv6 address with too many components",
"data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
"valid": false
@@ -54,6 +94,11 @@
"valid": false
},
{
+ "description": "single set of double colons in the middle is valid",
+ "data": "1:d6::42",
+ "valid": true
+ },
+ {
"description": "two sets of double colons is invalid",
"data": "1::d6::42",
"valid": false
diff --git a/json/tests/draft4/optional/format/uri.json b/json/tests/draft4/optional/format/uri.json
index 58d3085..792d71a 100644
--- a/json/tests/draft4/optional/format/uri.json
+++ b/json/tests/draft4/optional/format/uri.json
@@ -1,7 +1,7 @@
[
{
"description": "validation of URIs",
- "schema": {"format": "uri"},
+ "schema": { "format": "uri" },
"tests": [
{
"description": "a valid URL with anchor tag",
diff --git a/json/tests/draft4/optional/unicode.json b/json/tests/draft4/optional/unicode.json
deleted file mode 100644
index 8e709b4..0000000
--- a/json/tests/draft4/optional/unicode.json
+++ /dev/null
@@ -1,146 +0,0 @@
-[
- {
- "description": "unicode semantics should be used for all pattern matching",
- "schema": { "pattern": "\\wcole" },
- "tests": [
- {
- "description": "literal unicode character in json string",
- "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
- "valid": true
- },
- {
- "description": "unicode character in hex format in string",
- "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'\u00e9cole, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
- "valid": true
- },
- {
- "description": "unicode matching is case-sensitive",
- "data": "LES HIVERS DE MON ENFANCE ÉTAIENT DES SAISONS LONGUES, LONGUES. NOUS VIVIONS EN TROIS LIEUX: L'ÉCOLE, L'ÉGLISE ET LA PATINOIRE; MAIS LA VRAIE VIE ÉTAIT SUR LA PATINOIRE.",
- "valid": false
- }
- ]
- },
- {
- "description": "unicode characters do not match ascii ranges",
- "schema": { "pattern": "[a-z]cole" },
- "tests": [
- {
- "description": "literal unicode character in json string",
- "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
- "valid": false
- },
- {
- "description": "unicode character in hex format in string",
- "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'\u00e9cole, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
- "valid": false
- },
- {
- "description": "ascii characters match",
- "data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.",
- "valid": true
- }
- ]
- },
- {
- "description": "unicode digits are more than 0 through 9",
- "schema": { "pattern": "^\\d+$" },
- "tests": [
- {
- "description": "ascii digits",
- "data": "42",
- "valid": true
- },
- {
- "description": "ascii non-digits",
- "data": "-%#",
- "valid": false
- },
- {
- "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
- "data": "৪২",
- "valid": true
- }
- ]
- },
- {
- "description": "unicode semantics should be used for all patternProperties matching",
- "schema": {
- "type": "object",
- "patternProperties": {
- "\\wcole": {}
- },
- "additionalProperties": false
- },
- "tests": [
- {
- "description": "literal unicode character in json string",
- "data": { "l'école": "pas de vraie vie" },
- "valid": true
- },
- {
- "description": "unicode character in hex format in string",
- "data": { "l'\u00e9cole": "pas de vraie vie" },
- "valid": true
- },
- {
- "description": "unicode matching is case-sensitive",
- "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" },
- "valid": false
- }
- ]
- },
- {
- "description": "unicode characters do not match ascii ranges",
- "schema": {
- "type": "object",
- "patternProperties": {
- "[a-z]cole": {}
- },
- "additionalProperties": false
- },
- "tests": [
- {
- "description": "literal unicode character in json string",
- "data": { "l'école": "pas de vraie vie" },
- "valid": false
- },
- {
- "description": "unicode character in hex format in string",
- "data": { "l'\u00e9cole": "pas de vraie vie" },
- "valid": false
- },
- {
- "description": "ascii characters match",
- "data": { "l'ecole": "pas de vraie vie" },
- "valid": true
- }
- ]
- },
- {
- "description": "unicode digits are more than 0 through 9",
- "schema": {
- "type": "object",
- "patternProperties": {
- "^\\d+$": {}
- },
- "additionalProperties": false
- },
- "tests": [
- {
- "description": "ascii digits",
- "data": { "42": "life, the universe, and everything" },
- "valid": true
- },
- {
- "description": "ascii non-digits",
- "data": { "-%#": "spending the year dead for tax reasons" },
- "valid": false
- },
- {
- "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
- "data": { "৪২": "khajit has wares if you have coin" },
- "valid": true
- }
- ]
- }
-]
diff --git a/json/tests/draft4/ref.json b/json/tests/draft4/ref.json
index 7f5a211..d9978e9 100644
--- a/json/tests/draft4/ref.json
+++ b/json/tests/draft4/ref.json
@@ -182,17 +182,17 @@
"definitions": {
"foo": {
"id": "http://localhost:1234/sibling_id/foo.json",
- "minimum": 2
+ "type": "string"
},
"base_foo": {
"$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json",
"id": "foo.json",
- "minimum": 5
+ "type": "number"
}
},
"allOf": [
{
- "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not ttp://localhost:1234/sibling_id/foo.json",
+ "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json",
"id": "http://localhost:1234/sibling_id/",
"$ref": "foo.json"
}
@@ -200,14 +200,14 @@
},
"tests": [
{
- "description": "$ref resolves to /definitions/foo, data validates",
- "data": 10,
- "valid": true
+ "description": "$ref resolves to /definitions/base_foo, data does not validate",
+ "data": "a",
+ "valid": false
},
{
- "description": "$ref resolves to /definitions/foo, data does not validate",
+ "description": "$ref resolves to /definitions/base_foo, data validates",
"data": 1,
- "valid": false
+ "valid": true
}
]
},
@@ -467,5 +467,41 @@
"valid": true
}
]
+ },
+ {
+ "description": "id must be resolved against nearest parent, not just immediate parent",
+ "schema": {
+ "id": "http://example.com/a.json",
+ "definitions": {
+ "x": {
+ "id": "http://example.com/b/c.json",
+ "not": {
+ "definitions": {
+ "y": {
+ "id": "d.json",
+ "type": "number"
+ }
+ }
+ }
+ }
+ },
+ "allOf": [
+ {
+ "$ref": "http://example.com/b/d.json"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "number should pass",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "non-number should fail",
+ "data": "a",
+ "valid": false
+ }
+ ]
}
]