summaryrefslogtreecommitdiff
path: root/json/tests/draft3
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2020-06-09 19:00:09 -0400
committerJulian Berman <Julian@GrayVines.com>2020-06-09 19:00:09 -0400
commit3f58e36754b3e2872a256874c1ffdd30c677f709 (patch)
tree157cf84b5880faee6fab531f6e90d36e326b99e7 /json/tests/draft3
parent3b85db9769390b4dc713fbf09ab76a760e48fea3 (diff)
parent4a4930a09fa25251ad0f02395f3c6aa0fd7e3a82 (diff)
downloadjsonschema-3f58e36754b3e2872a256874c1ffdd30c677f709.tar.gz
Merge commit '4a4930a09fa25251ad0f02395f3c6aa0fd7e3a82'
* commit '4a4930a09fa25251ad0f02395f3c6aa0fd7e3a82': Squashed 'json/' changes from 9d0e0eb..817b724
Diffstat (limited to 'json/tests/draft3')
-rw-r--r--json/tests/draft3/additionalItems.json21
-rw-r--r--json/tests/draft3/enum.json16
-rw-r--r--json/tests/draft3/optional/format.json227
-rw-r--r--json/tests/draft3/optional/format/color.json38
-rw-r--r--json/tests/draft3/optional/format/date-time.json28
-rw-r--r--json/tests/draft3/optional/format/date.json18
-rw-r--r--json/tests/draft3/optional/format/email.json18
-rw-r--r--json/tests/draft3/optional/format/host-name.json63
-rw-r--r--json/tests/draft3/optional/format/ip-address.json23
-rw-r--r--json/tests/draft3/optional/format/ipv6.json28
-rw-r--r--json/tests/draft3/optional/format/regex.json18
-rw-r--r--json/tests/draft3/optional/format/time.json18
-rw-r--r--json/tests/draft3/optional/format/uri.json28
-rw-r--r--json/tests/draft3/ref.json12
-rw-r--r--json/tests/draft3/uniqueItems.json20
15 files changed, 340 insertions, 236 deletions
diff --git a/json/tests/draft3/additionalItems.json b/json/tests/draft3/additionalItems.json
index 6d4bff5..3868cb4 100644
--- a/json/tests/draft3/additionalItems.json
+++ b/json/tests/draft3/additionalItems.json
@@ -40,7 +40,22 @@
},
"tests": [
{
- "description": "no additional items present",
+ "description": "empty array",
+ "data": [ ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (1)",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (2)",
+ "data": [ 1, 2 ],
+ "valid": true
+ },
+ {
+ "description": "equal number of items present",
"data": [ 1, 2, 3 ],
"valid": true
},
@@ -70,10 +85,10 @@
},
{
"description": "additionalItems are allowed by default",
- "schema": {"items": []},
+ "schema": {"items": [{"type": "integer"}]},
"tests": [
{
- "description": "only the first items are validated",
+ "description": "only the first item is validated",
"data": [1, "foo", false],
"valid": true
}
diff --git a/json/tests/draft3/enum.json b/json/tests/draft3/enum.json
index 1cc111b..5a1ab3b 100644
--- a/json/tests/draft3/enum.json
+++ b/json/tests/draft3/enum.json
@@ -98,5 +98,21 @@
"valid": false
}
]
+ },
+ {
+ "description": "nul characters in strings",
+ "schema": { "enum": [ "hello\u0000there" ] },
+ "tests": [
+ {
+ "description": "match string with nul",
+ "data": "hello\u0000there",
+ "valid": true
+ },
+ {
+ "description": "do not match string lacking nul",
+ "data": "hellothere",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft3/optional/format.json b/json/tests/draft3/optional/format.json
deleted file mode 100644
index 9864589..0000000
--- a/json/tests/draft3/optional/format.json
+++ /dev/null
@@ -1,227 +0,0 @@
-[
- {
- "description": "validation of regular expressions",
- "schema": {"format": "regex"},
- "tests": [
- {
- "description": "a valid regular expression",
- "data": "([abc])+\\s+$",
- "valid": true
- },
- {
- "description": "a regular expression with unclosed parens is invalid",
- "data": "^(abc]",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of date-time strings",
- "schema": {"format": "date-time"},
- "tests": [
- {
- "description": "a valid date-time string",
- "data": "1963-06-19T08:30:06.283185Z",
- "valid": true
- },
- {
- "description": "an invalid date-time string",
- "data": "06/19/1963 08:30:06 PST",
- "valid": false
- },
- {
- "description": "case-insensitive T and Z",
- "data": "1963-06-19t08:30:06.283185z",
- "valid": true
- },
- {
- "description": "only RFC3339 not all of ISO 8601 are valid",
- "data": "2013-350T01:01:01",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of date strings",
- "schema": {"format": "date"},
- "tests": [
- {
- "description": "a valid date string",
- "data": "1963-06-19",
- "valid": true
- },
- {
- "description": "an invalid date string",
- "data": "06/19/1963",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of time strings",
- "schema": {"format": "time"},
- "tests": [
- {
- "description": "a valid time string",
- "data": "08:30:06",
- "valid": true
- },
- {
- "description": "an invalid time string",
- "data": "8:30 AM",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of URIs",
- "schema": {"format": "uri"},
- "tests": [
- {
- "description": "a valid URI",
- "data": "http://foo.bar/?baz=qux#quux",
- "valid": true
- },
- {
- "description": "an invalid protocol-relative URI Reference",
- "data": "//foo.bar/?baz=qux#quux",
- "valid": false
- },
- {
- "description": "an invalid URI",
- "data": "\\\\WINDOWS\\fileshare",
- "valid": false
- },
- {
- "description": "an invalid URI though valid URI reference",
- "data": "abc",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of e-mail addresses",
- "schema": {"format": "email"},
- "tests": [
- {
- "description": "a valid e-mail address",
- "data": "joe.bloggs@example.com",
- "valid": true
- },
- {
- "description": "an invalid e-mail address",
- "data": "2962",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of IP addresses",
- "schema": {"format": "ip-address"},
- "tests": [
- {
- "description": "a valid IP address",
- "data": "192.168.0.1",
- "valid": true
- },
- {
- "description": "an IP address with too many components",
- "data": "127.0.0.0.1",
- "valid": false
- },
- {
- "description": "an IP address with out-of-range values",
- "data": "256.256.256.256",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of IPv6 addresses",
- "schema": {"format": "ipv6"},
- "tests": [
- {
- "description": "a valid IPv6 address",
- "data": "::1",
- "valid": true
- },
- {
- "description": "an IPv6 address with out-of-range values",
- "data": "12345::",
- "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
- },
- {
- "description": "an IPv6 address containing illegal characters",
- "data": "::laptop",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of host names",
- "schema": {"format": "host-name"},
- "tests": [
- {
- "description": "a valid host name",
- "data": "www.example.com",
- "valid": true
- },
- {
- "description": "a host name starting with an illegal character",
- "data": "-a-host-name-that-starts-with--",
- "valid": false
- },
- {
- "description": "a host name containing illegal characters",
- "data": "not_a_valid_host_name",
- "valid": false
- },
- {
- "description": "a host name with a component too long",
- "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of CSS colors",
- "schema": {"format": "color"},
- "tests": [
- {
- "description": "a valid CSS color name",
- "data": "fuchsia",
- "valid": true
- },
- {
- "description": "a valid six-digit CSS color code",
- "data": "#CC8899",
- "valid": true
- },
- {
- "description": "a valid three-digit CSS color code",
- "data": "#C89",
- "valid": true
- },
- {
- "description": "an invalid CSS color code",
- "data": "#00332520",
- "valid": false
- },
- {
- "description": "an invalid CSS color name",
- "data": "puce",
- "valid": false
- },
- {
- "description": "a CSS color name containing invalid characters",
- "data": "light_grayish_red-violet",
- "valid": false
- }
- ]
- }
-]
diff --git a/json/tests/draft3/optional/format/color.json b/json/tests/draft3/optional/format/color.json
new file mode 100644
index 0000000..e80cb69
--- /dev/null
+++ b/json/tests/draft3/optional/format/color.json
@@ -0,0 +1,38 @@
+[
+ {
+ "description": "validation of CSS colors",
+ "schema": {"format": "color"},
+ "tests": [
+ {
+ "description": "a valid CSS color name",
+ "data": "fuchsia",
+ "valid": true
+ },
+ {
+ "description": "a valid six-digit CSS color code",
+ "data": "#CC8899",
+ "valid": true
+ },
+ {
+ "description": "a valid three-digit CSS color code",
+ "data": "#C89",
+ "valid": true
+ },
+ {
+ "description": "an invalid CSS color code",
+ "data": "#00332520",
+ "valid": false
+ },
+ {
+ "description": "an invalid CSS color name",
+ "data": "puce",
+ "valid": false
+ },
+ {
+ "description": "a CSS color name containing invalid characters",
+ "data": "light_grayish_red-violet",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/date-time.json b/json/tests/draft3/optional/format/date-time.json
new file mode 100644
index 0000000..90279ba
--- /dev/null
+++ b/json/tests/draft3/optional/format/date-time.json
@@ -0,0 +1,28 @@
+[
+ {
+ "description": "validation of date-time strings",
+ "schema": {"format": "date-time"},
+ "tests": [
+ {
+ "description": "a valid date-time string",
+ "data": "1963-06-19T08:30:06.283185Z",
+ "valid": true
+ },
+ {
+ "description": "an invalid date-time string",
+ "data": "06/19/1963 08:30:06 PST",
+ "valid": false
+ },
+ {
+ "description": "case-insensitive T and Z",
+ "data": "1963-06-19t08:30:06.283185z",
+ "valid": true
+ },
+ {
+ "description": "only RFC3339 not all of ISO 8601 are valid",
+ "data": "2013-350T01:01:01",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/date.json b/json/tests/draft3/optional/format/date.json
new file mode 100644
index 0000000..bd83042
--- /dev/null
+++ b/json/tests/draft3/optional/format/date.json
@@ -0,0 +1,18 @@
+[
+ {
+ "description": "validation of date strings",
+ "schema": {"format": "date"},
+ "tests": [
+ {
+ "description": "a valid date string",
+ "data": "1963-06-19",
+ "valid": true
+ },
+ {
+ "description": "an invalid date string",
+ "data": "06/19/1963",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/email.json b/json/tests/draft3/optional/format/email.json
new file mode 100644
index 0000000..c837c84
--- /dev/null
+++ b/json/tests/draft3/optional/format/email.json
@@ -0,0 +1,18 @@
+[
+ {
+ "description": "validation of e-mail addresses",
+ "schema": {"format": "email"},
+ "tests": [
+ {
+ "description": "a valid e-mail address",
+ "data": "joe.bloggs@example.com",
+ "valid": true
+ },
+ {
+ "description": "an invalid e-mail address",
+ "data": "2962",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/host-name.json b/json/tests/draft3/optional/format/host-name.json
new file mode 100644
index 0000000..8f6e28a
--- /dev/null
+++ b/json/tests/draft3/optional/format/host-name.json
@@ -0,0 +1,63 @@
+[
+ {
+ "description": "validation of host names",
+ "schema": {"format": "host-name"},
+ "tests": [
+ {
+ "description": "a valid host name",
+ "data": "www.example.com",
+ "valid": true
+ },
+ {
+ "description": "a host name starting with an illegal character",
+ "data": "-a-host-name-that-starts-with--",
+ "valid": false
+ },
+ {
+ "description": "a host name containing illegal characters",
+ "data": "not_a_valid_host_name",
+ "valid": false
+ },
+ {
+ "description": "a host name with a component too long",
+ "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
+ "valid": false
+ },
+ {
+ "description": "starts with hyphen",
+ "data": "-hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with hyphen",
+ "data": "hostname-",
+ "valid": false
+ },
+ {
+ "description": "starts with underscore",
+ "data": "_hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with underscore",
+ "data": "hostname_",
+ "valid": false
+ },
+ {
+ "description": "contains underscore",
+ "data": "host_name",
+ "valid": false
+ },
+ {
+ "description": "maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com",
+ "valid": true
+ },
+ {
+ "description": "exceeds maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/ip-address.json b/json/tests/draft3/optional/format/ip-address.json
new file mode 100644
index 0000000..c868bfb
--- /dev/null
+++ b/json/tests/draft3/optional/format/ip-address.json
@@ -0,0 +1,23 @@
+[
+ {
+ "description": "validation of IP addresses",
+ "schema": {"format": "ip-address"},
+ "tests": [
+ {
+ "description": "a valid IP address",
+ "data": "192.168.0.1",
+ "valid": true
+ },
+ {
+ "description": "an IP address with too many components",
+ "data": "127.0.0.0.1",
+ "valid": false
+ },
+ {
+ "description": "an IP address with out-of-range values",
+ "data": "256.256.256.256",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/ipv6.json b/json/tests/draft3/optional/format/ipv6.json
new file mode 100644
index 0000000..f67559b
--- /dev/null
+++ b/json/tests/draft3/optional/format/ipv6.json
@@ -0,0 +1,28 @@
+[
+ {
+ "description": "validation of IPv6 addresses",
+ "schema": {"format": "ipv6"},
+ "tests": [
+ {
+ "description": "a valid IPv6 address",
+ "data": "::1",
+ "valid": true
+ },
+ {
+ "description": "an IPv6 address with out-of-range values",
+ "data": "12345::",
+ "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
+ },
+ {
+ "description": "an IPv6 address containing illegal characters",
+ "data": "::laptop",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/regex.json b/json/tests/draft3/optional/format/regex.json
new file mode 100644
index 0000000..d99d021
--- /dev/null
+++ b/json/tests/draft3/optional/format/regex.json
@@ -0,0 +1,18 @@
+[
+ {
+ "description": "validation of regular expressions",
+ "schema": {"format": "regex"},
+ "tests": [
+ {
+ "description": "a valid regular expression",
+ "data": "([abc])+\\s+$",
+ "valid": true
+ },
+ {
+ "description": "a regular expression with unclosed parens is invalid",
+ "data": "^(abc]",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/time.json b/json/tests/draft3/optional/format/time.json
new file mode 100644
index 0000000..e97160d
--- /dev/null
+++ b/json/tests/draft3/optional/format/time.json
@@ -0,0 +1,18 @@
+[
+ {
+ "description": "validation of time strings",
+ "schema": {"format": "time"},
+ "tests": [
+ {
+ "description": "a valid time string",
+ "data": "08:30:06",
+ "valid": true
+ },
+ {
+ "description": "an invalid time string",
+ "data": "8:30 AM",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/uri.json b/json/tests/draft3/optional/format/uri.json
new file mode 100644
index 0000000..9c4de35
--- /dev/null
+++ b/json/tests/draft3/optional/format/uri.json
@@ -0,0 +1,28 @@
+[
+ {
+ "description": "validation of URIs",
+ "schema": {"format": "uri"},
+ "tests": [
+ {
+ "description": "a valid URI",
+ "data": "http://foo.bar/?baz=qux#quux",
+ "valid": true
+ },
+ {
+ "description": "an invalid protocol-relative URI Reference",
+ "data": "//foo.bar/?baz=qux#quux",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI",
+ "data": "\\\\WINDOWS\\fileshare",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI though valid URI reference",
+ "data": "abc",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/ref.json b/json/tests/draft3/ref.json
index 31414ad..bd6b777 100644
--- a/json/tests/draft3/ref.json
+++ b/json/tests/draft3/ref.json
@@ -75,11 +75,11 @@
{
"description": "escaped pointer ref",
"schema": {
- "tilda~field": {"type": "integer"},
+ "tilde~field": {"type": "integer"},
"slash/field": {"type": "integer"},
"percent%field": {"type": "integer"},
"properties": {
- "tilda": {"$ref": "#/tilda~0field"},
+ "tilde": {"$ref": "#/tilde~0field"},
"slash": {"$ref": "#/slash~1field"},
"percent": {"$ref": "#/percent%25field"}
}
@@ -91,8 +91,8 @@
"valid": false
},
{
- "description": "tilda invalid",
- "data": {"tilda": "aoeu"},
+ "description": "tilde invalid",
+ "data": {"tilde": "aoeu"},
"valid": false
},
{
@@ -106,8 +106,8 @@
"valid": true
},
{
- "description": "tilda valid",
- "data": {"tilda": 123},
+ "description": "tilde valid",
+ "data": {"tilde": 123},
"valid": true
},
{
diff --git a/json/tests/draft3/uniqueItems.json b/json/tests/draft3/uniqueItems.json
index 58722b8..8f8dbdd 100644
--- a/json/tests/draft3/uniqueItems.json
+++ b/json/tests/draft3/uniqueItems.json
@@ -65,6 +65,26 @@
"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": "nested [1] and [true] are unique",
+ "data": [[[1], "foo"], [[true], "foo"]],
+ "valid": true
+ },
+ {
+ "description": "nested [0] and [false] are unique",
+ "data": [[[0], "foo"], [[false], "foo"]],
+ "valid": true
+ },
+ {
"description": "unique heterogeneous types are valid",
"data": [{}, [1], true, null, 1],
"valid": true