update to latest JSON-Schema-Test-Suite

This commit is contained in:
Patrick Boettcher 2021-09-06 16:20:26 +02:00
parent 89ed13d76b
commit efb0a3127b
17 changed files with 673 additions and 187 deletions

View File

@ -61,9 +61,9 @@ void rfc3339_time_check(const std::string &value)
throw std::invalid_argument(value + " is not a time string according to RFC 3339."); throw std::invalid_argument(value + " is not a time string according to RFC 3339.");
} }
const auto hour = std::stoi(matches[1].str()); auto hour = std::stoi(matches[1].str());
const auto minute = std::stoi(matches[2].str()); auto minute = std::stoi(matches[2].str());
const auto second = std::stoi(matches[3].str()); auto second = std::stoi(matches[3].str());
// const auto secfrac = std::stof( matches[4].str() ); // const auto secfrac = std::stof( matches[4].str() );
range_check(hour, 0, 23); range_check(hour, 0, 23);
@ -79,6 +79,8 @@ void rfc3339_time_check(const std::string &value)
range_check(offsetHour, -23, 23); range_check(offsetHour, -23, 23);
range_check(offsetMinute, 0, 59); range_check(offsetMinute, 0, 59);
if (offsetHour < 0)
offsetMinute *= -1;
} }
/** /**
@ -86,7 +88,14 @@ void rfc3339_time_check(const std::string &value)
* correct maximum in {58,59,60}. This current solution might match some invalid dates * correct maximum in {58,59,60}. This current solution might match some invalid dates
* but it won't lead to false negatives. This only works if we know the full date, however * but it won't lead to false negatives. This only works if we know the full date, however
*/ */
if (((hour - offsetHour) % 24) == 23 && ((minute - offsetMinute) % 60) == 59)
auto day_minutes = hour * 60 + minute - (offsetHour * 60 + offsetMinute);
if (day_minutes < 0)
day_minutes += 60 * 24;
hour = day_minutes % 24;
minute = day_minutes / 24;
if (hour == 23 && minute == 59)
range_check(second, 0, 60); // possible leap-second range_check(second, 0, 60); // possible leap-second
else else
range_check(second, 0, 59); range_check(second, 0, 59);

View File

@ -50,7 +50,6 @@ if(JSON_SCHEMA_TEST_SUITE_PATH)
# some optional tests will fail # some optional tests will fail
set_tests_properties( set_tests_properties(
JSON-Suite::Optional::bignum JSON-Suite::Optional::bignum
JSON-Suite::Optional::zeroTerminatedFloats
JSON-Suite::Optional::non-bmp-regex JSON-Suite::Optional::non-bmp-regex
JSON-Suite::Optional::float-overflow JSON-Suite::Optional::float-overflow
@ -64,6 +63,7 @@ if(JSON_SCHEMA_TEST_SUITE_PATH)
JSON-Suite::Optional::Format::uri-reference JSON-Suite::Optional::Format::uri-reference
JSON-Suite::Optional::Format::uri-template JSON-Suite::Optional::Format::uri-template
JSON-Suite::Optional::Format::uri JSON-Suite::Optional::Format::uri
JSON-Suite::Optional::unicode
PROPERTIES PROPERTIES
WILL_FAIL ON) WILL_FAIL ON)

View File

@ -125,5 +125,26 @@
"valid": false "valid": false
} }
] ]
},
{
"description": "contains with false if subschema",
"schema": {
"contains": {
"if": false,
"else": true
}
},
"tests": [
{
"description": "any non-empty array is valid",
"data": ["foo"],
"valid": true
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
}
]
} }
] ]

View File

@ -1,611 +1,611 @@
[ [
{ {
"description": "validation of e-mail addresses", "description": "email format",
"schema": { "format": "email" }, "schema": { "format": "email" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of IDN e-mail addresses", "description": "idn-email format",
"schema": { "format": "idn-email" }, "schema": { "format": "idn-email" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of regexes", "description": "regex format",
"schema": { "format": "regex" }, "schema": { "format": "regex" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of IP addresses", "description": "ipv4 format",
"schema": { "format": "ipv4" }, "schema": { "format": "ipv4" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of IPv6 addresses", "description": "ipv6 format",
"schema": { "format": "ipv6" }, "schema": { "format": "ipv6" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of IDN hostnames", "description": "idn-hostname format",
"schema": { "format": "idn-hostname" }, "schema": { "format": "idn-hostname" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of hostnames", "description": "hostname format",
"schema": { "format": "hostname" }, "schema": { "format": "hostname" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of date strings", "description": "date format",
"schema": { "format": "date" }, "schema": { "format": "date" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of date-time strings", "description": "date-time format",
"schema": { "format": "date-time" }, "schema": { "format": "date-time" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of time strings", "description": "time format",
"schema": { "format": "time" }, "schema": { "format": "time" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of JSON pointers", "description": "json-pointer format",
"schema": { "format": "json-pointer" }, "schema": { "format": "json-pointer" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of relative JSON pointers", "description": "relative-json-pointer format",
"schema": { "format": "relative-json-pointer" }, "schema": { "format": "relative-json-pointer" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of IRIs", "description": "iri format",
"schema": { "format": "iri" }, "schema": { "format": "iri" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of IRI references", "description": "iri-reference format",
"schema": { "format": "iri-reference" }, "schema": { "format": "iri-reference" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of URIs", "description": "uri format",
"schema": { "format": "uri" }, "schema": { "format": "uri" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of URI references", "description": "uri-reference format",
"schema": { "format": "uri-reference" }, "schema": { "format": "uri-reference" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }
] ]
}, },
{ {
"description": "validation of URI templates", "description": "uri-template format",
"schema": { "format": "uri-template" }, "schema": { "format": "uri-template" },
"tests": [ "tests": [
{ {
"description": "ignores integers", "description": "all string formats ignore integers",
"data": 12, "data": 12,
"valid": true "valid": true
}, },
{ {
"description": "ignores floats", "description": "all string formats ignore floats",
"data": 13.7, "data": 13.7,
"valid": true "valid": true
}, },
{ {
"description": "ignores objects", "description": "all string formats ignore objects",
"data": {}, "data": {},
"valid": true "valid": true
}, },
{ {
"description": "ignores arrays", "description": "all string formats ignore arrays",
"data": [], "data": [],
"valid": true "valid": true
}, },
{ {
"description": "ignores booleans", "description": "all string formats ignore booleans",
"data": false, "data": false,
"valid": true "valid": true
}, },
{ {
"description": "ignores null", "description": "all string formats ignore nulls",
"data": null, "data": null,
"valid": true "valid": true
} }

View File

@ -7,6 +7,11 @@
"description": "a bignum is an integer", "description": "a bignum is an integer",
"data": 12345678910111213141516171819202122232425262728293031, "data": 12345678910111213141516171819202122232425262728293031,
"valid": true "valid": true
},
{
"description": "a negative bignum is an integer",
"data": -12345678910111213141516171819202122232425262728293031,
"valid": true
} }
] ]
}, },
@ -18,24 +23,7 @@
"description": "a bignum is a number", "description": "a bignum is a number",
"data": 98249283749234923498293171823948729348710298301928331, "data": 98249283749234923498293171823948729348710298301928331,
"valid": true "valid": true
}
]
}, },
{
"description": "integer",
"schema": {"type": "integer"},
"tests": [
{
"description": "a negative bignum is an integer",
"data": -12345678910111213141516171819202122232425262728293031,
"valid": true
}
]
},
{
"description": "number",
"schema": {"type": "number"},
"tests": [
{ {
"description": "a negative bignum is a number", "description": "a negative bignum is a number",
"data": -98249283749234923498293171823948729348710298301928331, "data": -98249283749234923498293171823948729348710298301928331,

View File

@ -8,7 +8,7 @@
"tests": [ "tests": [
{ {
"description": "matches in Python, but should not in jsonschema", "description": "matches in Python, but should not in jsonschema",
"data": "abc\n", "data": "abc\\n",
"valid": false "valid": false
}, },
{ {

View File

@ -57,6 +57,16 @@
"description": "invalid non-padded day dates", "description": "invalid non-padded day dates",
"data": "1963-06-1T08:30:06.283185Z", "data": "1963-06-1T08:30:06.283185Z",
"valid": false "valid": false
},
{
"description": "non-ascii digits should be rejected in the date portion",
"data": "1963-06-1T00:00:00Z",
"valid": false
},
{
"description": "non-ascii digits should be rejected in the time portion",
"data": "1963-06-11T0:00:00Z",
"valid": false
} }
] ]
} }

View File

@ -9,7 +9,142 @@
"valid": true "valid": true
}, },
{ {
"description": "an invalid date-time string", "description": "a valid date string with 31 days in January",
"data": "2020-01-31",
"valid": true
},
{
"description": "a invalid date string with 32 days in January",
"data": "2020-01-32",
"valid": false
},
{
"description": "a valid date string with 28 days in February (normal)",
"data": "2021-02-28",
"valid": true
},
{
"description": "a invalid date string with 29 days in February (normal)",
"data": "2021-02-29",
"valid": false
},
{
"description": "a valid date string with 29 days in February (leap)",
"data": "2020-02-29",
"valid": true
},
{
"description": "a invalid date string with 30 days in February (leap)",
"data": "2020-02-30",
"valid": false
},
{
"description": "a valid date string with 31 days in March",
"data": "2020-03-31",
"valid": true
},
{
"description": "a invalid date string with 32 days in March",
"data": "2020-03-32",
"valid": false
},
{
"description": "a valid date string with 30 days in April",
"data": "2020-04-30",
"valid": true
},
{
"description": "a invalid date string with 31 days in April",
"data": "2020-04-31",
"valid": false
},
{
"description": "a valid date string with 31 days in May",
"data": "2020-05-31",
"valid": true
},
{
"description": "a invalid date string with 32 days in May",
"data": "2020-05-32",
"valid": false
},
{
"description": "a valid date string with 30 days in June",
"data": "2020-06-30",
"valid": true
},
{
"description": "a invalid date string with 31 days in June",
"data": "2020-06-31",
"valid": false
},
{
"description": "a valid date string with 31 days in July",
"data": "2020-07-31",
"valid": true
},
{
"description": "a invalid date string with 32 days in July",
"data": "2020-07-32",
"valid": false
},
{
"description": "a valid date string with 31 days in August",
"data": "2020-08-31",
"valid": true
},
{
"description": "a invalid date string with 32 days in August",
"data": "2020-08-32",
"valid": false
},
{
"description": "a valid date string with 30 days in September",
"data": "2020-09-30",
"valid": true
},
{
"description": "a invalid date string with 31 days in September",
"data": "2020-09-31",
"valid": false
},
{
"description": "a valid date string with 31 days in October",
"data": "2020-10-31",
"valid": true
},
{
"description": "a invalid date string with 32 days in October",
"data": "2020-10-32",
"valid": false
},
{
"description": "a valid date string with 30 days in November",
"data": "2020-11-30",
"valid": true
},
{
"description": "a invalid date string with 31 days in November",
"data": "2020-11-31",
"valid": false
},
{
"description": "a valid date string with 31 days in December",
"data": "2020-12-31",
"valid": true
},
{
"description": "a invalid date string with 32 days in December",
"data": "2020-12-32",
"valid": false
},
{
"description": "a invalid date string with invalid month",
"data": "2020-13-01",
"valid": false
},
{
"description": "an invalid date string",
"data": "06/19/1963", "data": "06/19/1963",
"valid": false "valid": false
}, },
@ -19,14 +154,39 @@
"valid": false "valid": false
}, },
{ {
"description": "invalidates non-padded month dates", "description": "non-padded month dates are not valid",
"data": "1998-1-20", "data": "1998-1-20",
"valid": false "valid": false
}, },
{ {
"description": "invalidates non-padded day dates", "description": "non-padded day dates are not valid",
"data": "1998-01-1", "data": "1998-01-1",
"valid": false "valid": false
},
{
"description": "invalid month",
"data": "1998-13-01",
"valid": false
},
{
"description": "invalid month-day combination",
"data": "1998-04-31",
"valid": false
},
{
"description": "2021 is not a leap year",
"data": "2021-02-29",
"valid": false
},
{
"description": "2020 is a leap year",
"data": "2020-02-29",
"valid": true
},
{
"description": "non-ascii digits should be rejected",
"data": "1963-06-1",
"valid": false
} }
] ]
} }

View File

@ -43,6 +43,11 @@
"description": "value without leading zero is valid", "description": "value without leading zero is valid",
"data": "87.10.0.1", "data": "87.10.0.1",
"valid": true "valid": true
},
{
"description": "non-ascii digits should be rejected",
"data": "1২7.0.0.1",
"valid": false
} }
] ]
} }

View File

@ -147,6 +147,16 @@
"description": "a long invalid ipv6, below length limit, second", "description": "a long invalid ipv6, below length limit, second",
"data": "100:100:100:100:100:100:100:255.255.255.255", "data": "100:100:100:100:100:100:100:255.255.255.255",
"valid": false "valid": false
},
{
"description": "non-ascii digits should be rejected",
"data": "1:2:3:4:5:6:7:",
"valid": false
},
{
"description": "non-ascii digits should be rejected in the ipv4 portion also",
"data": "1:2::192.16.0.1",
"valid": false
} }
] ]
} }

View File

@ -32,6 +32,21 @@
"description": "negative prefix", "description": "negative prefix",
"data": "-1/foo/bar", "data": "-1/foo/bar",
"valid": false "valid": false
},
{
"description": "## is not a valid json-pointer",
"data": "0##",
"valid": false
},
{
"description": "zero cannot be followed by other digits, plus json-pointer",
"data": "01/a",
"valid": false
},
{
"description": "zero cannot be followed by other digits, plus octothorpe",
"data": "01#",
"valid": false
} }
] ]
} }

View File

@ -9,15 +9,75 @@
"valid": true "valid": true
}, },
{ {
"description": "a valid time string with leap second", "description": "a valid time string with leap second, Zulu",
"data": "23:59:60Z", "data": "23:59:60Z",
"valid": true "valid": true
}, },
{ {
"description": "a valid time string with leap second with offset", "description": "invalid leap second, Zulu (wrong hour)",
"data": "22:59:60Z",
"valid": false
},
{
"description": "invalid leap second, Zulu (wrong minute)",
"data": "23:58:60Z",
"valid": false
},
{
"description": "valid leap second, zero time-offset",
"data": "23:59:60+00:00",
"valid": true
},
{
"description": "invalid leap second, zero time-offset (wrong hour)",
"data": "22:59:60+00:00",
"valid": false
},
{
"description": "invalid leap second, zero time-offset (wrong minute)",
"data": "23:58:60+00:00",
"valid": false
},
{
"description": "valid leap second, positive time-offset",
"data": "01:29:60+01:30",
"valid": true
},
{
"description": "valid leap second, large positive time-offset",
"data": "23:29:60+23:30",
"valid": true
},
{
"description": "invalid leap second, positive time-offset (wrong hour)",
"data": "23:59:60+01:00",
"valid": false
},
{
"description": "invalid leap second, positive time-offset (wrong minute)",
"data": "23:59:60+00:30",
"valid": false
},
{
"description": "valid leap second, negative time-offset",
"data": "15:59:60-08:00", "data": "15:59:60-08:00",
"valid": true "valid": true
}, },
{
"description": "valid leap second, large negative time-offset",
"data": "00:29:60-23:30",
"valid": true
},
{
"description": "invalid leap second, negative time-offset (wrong hour)",
"data": "23:59:60-01:00",
"valid": false
},
{
"description": "invalid leap second, negative time-offset (wrong minute)",
"data": "23:59:60-00:30",
"valid": false
},
{ {
"description": "a valid time string with second fraction", "description": "a valid time string with second fraction",
"data": "23:20:50.52Z", "data": "23:20:50.52Z",
@ -84,7 +144,7 @@
"valid": false "valid": false
}, },
{ {
"description": "an invalid time string", "description": "an invalid offset indicator",
"data": "08:30:06 PST", "data": "08:30:06 PST",
"valid": false "valid": false
}, },
@ -92,6 +152,16 @@
"description": "only RFC3339 not all of ISO 8601 are valid", "description": "only RFC3339 not all of ISO 8601 are valid",
"data": "01:01:01,1111", "data": "01:01:01,1111",
"valid": false "valid": false
},
{
"description": "no time offset",
"data": "12:00:00",
"valid": false
},
{
"description": "non-ascii digits should be rejected",
"data": "1২:00:00Z",
"valid": false
} }
] ]
} }

View File

@ -0,0 +1,146 @@
[
{
"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": true
},
"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": true
},
"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+$": true
},
"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
}
]
}
]

View File

@ -1,15 +0,0 @@
[
{
"description": "some languages do not distinguish between different types of numeric value",
"schema": {
"type": "integer"
},
"tests": [
{
"description": "a float without fractional part is an integer",
"data": 1.0,
"valid": true
}
]
}
]

View File

@ -43,6 +43,35 @@
} }
] ]
}, },
{
"description": "propertyNames validation with pattern",
"schema": {
"propertyNames": { "pattern": "^a+$" }
},
"tests": [
{
"description": "matching property names valid",
"data": {
"a": {},
"aa": {},
"aaa": {}
},
"valid": true
},
{
"description": "non-matching property name is invalid",
"data": {
"aaA": {}
},
"valid": false
},
{
"description": "object without properties is valid",
"data": {},
"valid": true
}
]
},
{ {
"description": "propertyNames with boolean schema true", "description": "propertyNames with boolean schema true",
"schema": {"propertyNames": true}, "schema": {"propertyNames": true},

View File

@ -175,6 +175,42 @@
} }
] ]
}, },
{
"description": "$ref prevents a sibling $id from changing the base uri",
"schema": {
"$id": "http://localhost:1234/sibling_id/base/",
"definitions": {
"foo": {
"$id": "http://localhost:1234/sibling_id/foo.json",
"minimum": 2
},
"base_foo": {
"$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json",
"$id": "foo.json",
"minimum": 5
}
},
"allOf": [
{
"$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not ttp://localhost:1234/sibling_id/foo.json",
"$id": "http://localhost:1234/sibling_id/",
"$ref": "foo.json"
}
]
},
"tests": [
{
"description": "$ref resolves to /definitions/foo, data validates",
"data": 10,
"valid": true
},
{
"description": "$ref resolves to /definitions/foo, data does not validate",
"data": 1,
"valid": false
}
]
},
{ {
"description": "remote ref, containing refs itself", "description": "remote ref, containing refs itself",
"schema": {"$ref": "http://json-schema.org/draft-07/schema#"}, "schema": {"$ref": "http://json-schema.org/draft-07/schema#"},

View File

@ -172,7 +172,9 @@
"description": "remote ref with ref to definitions", "description": "remote ref with ref to definitions",
"schema": { "schema": {
"$id": "http://localhost:1234/schema-remote-ref-ref-defs1.json", "$id": "http://localhost:1234/schema-remote-ref-ref-defs1.json",
"$ref": "ref-and-definitions.json" "allOf": [
{ "$ref": "ref-and-definitions.json" }
]
}, },
"tests": [ "tests": [
{ {