Skip to content

Commit 281c28b

Browse files
committed
Merge git://github.com/IreneKnapp/JSON-Schema-Test-Suite
2 parents 6f55ff5 + 6c28d7c commit 281c28b

File tree

7 files changed

+529
-0
lines changed

7 files changed

+529
-0
lines changed

tests/draft3/additionalItems.json

+65
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,70 @@
6363
"valid": true
6464
}
6565
]
66+
},
67+
{
68+
"description": "additionalItems are allowed by default",
69+
"schema": {
70+
"items": [{"type": "integer"},
71+
{"type": "string"}]
72+
},
73+
"tests": [
74+
{
75+
"description": "only the first items are validated",
76+
"data": [1, "foo", false],
77+
"valid": true
78+
}
79+
]
80+
},
81+
{
82+
"description": "additional items",
83+
"schema": {
84+
"items" : [{"type": "integer"}, {"type" : "string"}],
85+
"additionalItems": false
86+
},
87+
"tests": [
88+
{
89+
"description": "no additional",
90+
"data": [1, "foo"],
91+
"valid": true
92+
},
93+
{
94+
"description": "additional",
95+
"data": [1, "foo", false],
96+
"valid": false
97+
}
98+
]
99+
},
100+
{
101+
"description": "additionalItems schema",
102+
"schema": {
103+
"items" : [{"type" : "integer"}, {"type" : "string"}],
104+
"additionalItems" : {"type" : "integer"}
105+
},
106+
"tests": [
107+
{
108+
"description": "match",
109+
"data": [1, "foo", 3],
110+
"valid": true
111+
},
112+
{
113+
"description": "no match",
114+
"data": [1, "foo", "bar"],
115+
"valid": false
116+
}
117+
]
118+
},
119+
{
120+
"description": "additionalItems ignored when items is not tuple",
121+
"schema": {
122+
"additionalItems": false
123+
},
124+
"tests": [
125+
{
126+
"description": "simple array",
127+
"data": [1, 2],
128+
"valid": true
129+
}
130+
]
66131
}
67132
]

tests/draft3/dependencies.json

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
[
2+
{
3+
"description": "dependencies",
4+
"schema": {
5+
"dependencies": {"bar": "foo"}
6+
},
7+
"tests": [
8+
{
9+
"description": "neither",
10+
"data": {},
11+
"valid": true
12+
},
13+
{
14+
"description": "nondependant",
15+
"data": {"foo": 1},
16+
"valid": true
17+
},
18+
{
19+
"description": "with dependency",
20+
"data": {"foo": 1, "bar": 2},
21+
"valid": true
22+
},
23+
{
24+
"description": "missing dependency",
25+
"data": {"bar": 2},
26+
"valid": false
27+
}
28+
]
29+
},
30+
{
31+
"description": "multiple dependencies",
32+
"schema": {
33+
"dependencies": {"quux": ["foo", "bar"]}
34+
},
35+
"tests": [
36+
{
37+
"description": "neither",
38+
"data": {},
39+
"valid": true
40+
},
41+
{
42+
"description": "nondependants",
43+
"data": {"foo": 1, "bar": 2},
44+
"valid": true
45+
},
46+
{
47+
"description": "with dependencies",
48+
"data": {"foo": 1, "bar": 2, "quux": 3},
49+
"valid": true
50+
},
51+
{
52+
"description": "missing dependency",
53+
"data": {"foo": 1, "quux": 2},
54+
"valid": false
55+
},
56+
{
57+
"description": "missing other dependency",
58+
"data": {"bar": 1, "quux": 2},
59+
"valid": false
60+
},
61+
{
62+
"description": "missing both dependencies",
63+
"data": {"quux": 1},
64+
"valid": false
65+
}
66+
]
67+
},
68+
{
69+
"description": "multiple dependencies subschema",
70+
"schema": {
71+
"dependencies": {
72+
"bar": {
73+
"properties": {
74+
"foo": {"type": "integer"},
75+
"bar": {"type": "integer"}
76+
}
77+
}
78+
}
79+
},
80+
"tests": [
81+
{
82+
"description": "valid",
83+
"data": {"foo": 1, "bar": 2},
84+
"valid": true
85+
},
86+
{
87+
"description": "wrong type",
88+
"data": {"foo": "quux", "bar": 2},
89+
"valid": false
90+
},
91+
{
92+
"description": "wrong type other",
93+
"data": {"foo": 2, "bar": "quux"},
94+
"valid": false
95+
},
96+
{
97+
"description": "wrong type both",
98+
"data": {"foo": "quux", "bar": "quux"},
99+
"valid": false
100+
}
101+
]
102+
}
103+
]

tests/draft3/disallow.json

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
[
2+
{
3+
"description": "disallow",
4+
"schema": {
5+
"disallow": "integer"
6+
},
7+
"tests": [
8+
{
9+
"description": "allowed",
10+
"data": "foo",
11+
"valid": true
12+
},
13+
{
14+
"description": "disallowed",
15+
"data": 1,
16+
"valid": false
17+
}
18+
]
19+
},
20+
{
21+
"description": "multiple disallow",
22+
"schema": {
23+
"disallow": ["integer", "boolean"]
24+
},
25+
"tests": [
26+
{
27+
"description": "valid",
28+
"data": "foo",
29+
"valid": true
30+
},
31+
{
32+
"description": "mismatch",
33+
"data": 1,
34+
"valid": false
35+
},
36+
{
37+
"description": "other mismatch",
38+
"data": true,
39+
"valid": false
40+
}
41+
]
42+
},
43+
{
44+
"description": "multiple disallow subschema",
45+
"schema": {
46+
"disallow":
47+
["string",
48+
{
49+
"type": "object",
50+
"properties": {
51+
"foo": {
52+
"type": "string"
53+
}
54+
}
55+
}]
56+
},
57+
"tests": [
58+
{
59+
"description": "match",
60+
"data": 1,
61+
"valid": true
62+
},
63+
{
64+
"description": "other match",
65+
"data": {"foo": 1},
66+
"valid": true
67+
},
68+
{
69+
"description": "mismatch",
70+
"data": "foo",
71+
"valid": false
72+
},
73+
{
74+
"description": "other mismatch",
75+
"data": {"foo": "bar"},
76+
"valid": false
77+
}
78+
]
79+
}
80+
]

tests/draft3/divisibleBy.json

+48
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,53 @@
1919
"valid": false
2020
}
2121
]
22+
},
23+
{
24+
"description": "by int",
25+
"schema": {"divisibleBy": 2},
26+
"tests": [
27+
{
28+
"description": "int by int",
29+
"data": 10,
30+
"valid": true
31+
},
32+
{
33+
"description": "int by int fail",
34+
"data": 7,
35+
"valid": false
36+
}
37+
]
38+
},
39+
{
40+
"description": "by number small",
41+
"schema": {"divisibleBy": 0.0001},
42+
"tests": [
43+
{
44+
"description": "number by number small",
45+
"data": 0.0075,
46+
"valid": true
47+
},
48+
{
49+
"description": "number by number small fail",
50+
"data": 0.00751,
51+
"valid": false
52+
}
53+
]
54+
},
55+
{
56+
"description": "by number again",
57+
"schema": {"divisibleBy": 0.01},
58+
"tests": [
59+
{
60+
"description": "number by number again",
61+
"data": 1.09,
62+
"valid": true
63+
},
64+
{
65+
"description": "number by number again 2",
66+
"data": 1.89,
67+
"valid": true
68+
}
69+
]
2270
}
2371
]

0 commit comments

Comments
 (0)