Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/json-schema-draft4/additionalItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
},
"tests": [
{
"description": "no additional items present",
"description": "fewer number of items present",
"data": [ 1, 2 ],
"valid": true
},
{
"description": "equal number of items present",
"data": [ 1, 2, 3 ],
"valid": true
},
Expand Down
13 changes: 13 additions & 0 deletions test/json-schema-draft4/ecmascript-regex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"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
}
]
}
]
5 changes: 5 additions & 0 deletions test/json-schema-draft4/format.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"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",
Expand Down
32 changes: 32 additions & 0 deletions test/json-schema-draft4/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
"description": "ignores non-arrays",
"data": {"foo" : "bar"},
"valid": true
},
{
"description": "JavaScript pseudo-array is valid",
"data": {
"0": "invalid",
"length": 1
},
"valid": true
}
]
},
Expand All @@ -40,6 +48,30 @@
"description": "wrong types",
"data": [ "foo", 1 ],
"valid": false
},
{
"description": "incomplete array of items",
"data": [ 1 ],
"valid": true
},
{
"description": "array with additional items",
"data": [ 1, "foo", true ],
"valid": true
},
{
"description": "empty array",
"data": [ ],
"valid": true
},
{
"description": "JavaScript pseudo-array is valid",
"data": {
"0": "invalid",
"1": "valid",
"length": 2
},
"valid": true
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions test/json-schema-draft4/maxLength.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
"description": "ignores non-strings",
"data": 100,
"valid": true
},
{
"description": "two supplementary Unicode code points is long enough",
"data": "\uD83D\uDCA9\uD83D\uDCA9",
"valid": true
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions test/json-schema-draft4/maximum.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
"data": 2.6,
"valid": true
},
{
"description": "boundary point is valid",
"data": 3.0,
"valid": true
},
{
"description": "above the maximum is invalid",
"data": 3.5,
Expand Down
5 changes: 5 additions & 0 deletions test/json-schema-draft4/minLength.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
"description": "ignores non-strings",
"data": 1,
"valid": true
},
{
"description": "one supplementary Unicode code point is not long enough",
"data": "\uD83D\uDCA9",
"valid": false
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions test/json-schema-draft4/minimum.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
"data": 2.6,
"valid": true
},
{
"description": "boundary point is valid",
"data": 1.1,
"valid": true
},
{
"description": "below the minimum is invalid",
"data": 0.6,
Expand Down
36 changes: 0 additions & 36 deletions test/json-schema-draft4/multipleOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,41 +56,5 @@
"valid": false
}
]
},
{
"description": "by decimal number where floating point precision is wrong",
"schema": {"multipleOf": 0.01},
"tests": [
{
"description": "Number 2 is multiple of 0.01",
"data": 2,
"valid": true
},
{
"description": "Number 2.1 is multiple of 0.01",
"data": 2.1,
"valid": true
},
{
"description": "Number 2.2 is multiple of 0.01",
"data": 2.2,
"valid": true
},
{
"description": "Number 2.3 is multiple of 0.01",
"data": 2.3,
"valid": true
},
{
"description": "Number 2.4 is multiple of 0.01",
"data": 2.4,
"valid": true
},
{
"description": "Number 1.211 is not multiple of 0.01",
"data": 1.211,
"valid": false
}
]
}
]
11 changes: 11 additions & 0 deletions test/json-schema-draft4/pattern.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,16 @@
"valid": true
}
]
},
{
"description": "pattern is not anchored",
"schema": {"pattern": "a+"},
"tests": [
{
"description": "matches a substring",
"data": "xxaayy",
"valid": true
}
]
}
]
178 changes: 175 additions & 3 deletions test/json-schema-draft4/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,34 @@
},
"tests": [
{
"description": "slash",
"description": "slash invalid",
"data": {"slash": "aoeu"},
"valid": false
},
{
"description": "tilda",
"description": "tilda invalid",
"data": {"tilda": "aoeu"},
"valid": false
},
{
"description": "percent",
"description": "percent invalid",
"data": {"percent": "aoeu"},
"valid": false
},
{
"description": "slash valid",
"data": {"slash": 123},
"valid": true
},
{
"description": "tilda valid",
"data": {"tilda": 123},
"valid": true
},
{
"description": "percent valid",
"data": {"percent": 123},
"valid": true
}
]
},
Expand All @@ -124,5 +139,162 @@
"valid": false
}
]
},
{
"description": "ref overrides any sibling keywords",
"schema": {
"definitions": {
"reffed": {
"type": "array"
}
},
"properties": {
"foo": {
"$ref": "#/definitions/reffed",
"maxItems": 2
}
}
},
"tests": [
{
"description": "ref valid",
"data": { "foo": [] },
"valid": true
},
{
"description": "ref valid, maxItems ignored",
"data": { "foo": [ 1, 2, 3] },
"valid": true
},
{
"description": "ref invalid",
"data": { "foo": "string" },
"valid": false
}
]
},
{
"description": "remote ref, containing refs itself",
"schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
"tests": [
{
"description": "remote ref valid",
"data": {"minLength": 1},
"valid": true
},
{
"description": "remote ref invalid",
"data": {"minLength": -1},
"valid": false
}
]
},
{
"description": "property named $ref that is not a reference",
"schema": {
"properties": {
"$ref": {"type": "string"}
}
},
"tests": [
{
"description": "property named $ref valid",
"data": {"$ref": "a"},
"valid": true
},
{
"description": "property named $ref invalid",
"data": {"$ref": 2},
"valid": false
}
]
},
{
"description": "Recursive references between schemas",
"schema": {
"id": "http://localhost:1234/tree",
"description": "tree of nodes",
"type": "object",
"properties": {
"meta": {"type": "string"},
"nodes": {
"type": "array",
"items": {"$ref": "node"}
}
},
"required": ["meta", "nodes"],
"definitions": {
"node": {
"id": "http://localhost:1234/node",
"description": "node",
"type": "object",
"properties": {
"value": {"type": "number"},
"subtree": {"$ref": "tree"}
},
"required": ["value"]
}
}
},
"tests": [
{
"description": "valid tree",
"data": {
"meta": "root",
"nodes": [
{
"value": 1,
"subtree": {
"meta": "child",
"nodes": [
{"value": 1.1},
{"value": 1.2}
]
}
},
{
"value": 2,
"subtree": {
"meta": "child",
"nodes": [
{"value": 2.1},
{"value": 2.2}
]
}
}
]
},
"valid": true
},
{
"description": "invalid tree",
"data": {
"meta": "root",
"nodes": [
{
"value": 1,
"subtree": {
"meta": "child",
"nodes": [
{"value": "string is invalid"},
{"value": 1.2}
]
}
},
{
"value": 2,
"subtree": {
"meta": "child",
"nodes": [
{"value": 2.1},
{"value": 2.2}
]
}
}
]
},
"valid": false
}
]
}
]