Implement additionalItems

This commit is contained in:
Milo Yip
2015-05-02 10:06:48 +08:00
parent 33b5c59e5d
commit 05ae593583
2 changed files with 71 additions and 18 deletions

View File

@@ -350,6 +350,36 @@ TEST(SchemaValidator, Array_ItemsTuple) {
VALIDATE(s, "[1600, \"Pennsylvania\", \"Avenue\", \"NW\", \"Washington\"]", true);
}
TEST(SchemaValidator, Array_AdditionalItmes) {
Document sd;
sd.Parse(
"{"
" \"type\": \"array\","
" \"items\": ["
" {"
" \"type\": \"number\""
" },"
" {"
" \"type\": \"string\""
" },"
" {"
" \"type\": \"string\","
" \"enum\": [\"Street\", \"Avenue\", \"Boulevard\"]"
" },"
" {"
" \"type\": \"string\","
" \"enum\": [\"NW\", \"NE\", \"SW\", \"SE\"]"
" }"
" ],"
" \"additionalItems\": false"
"}");
Schema s(sd);
VALIDATE(s, "[1600, \"Pennsylvania\", \"Avenue\", \"NW\"]", true);
VALIDATE(s, "[1600, \"Pennsylvania\", \"Avenue\"]", true);
VALIDATE(s, "[1600, \"Pennsylvania\", \"Avenue\", \"NW\", \"Washington\"]", false);
}
TEST(SchemaValidator, Array_ItemsRange) {
Document sd;
sd.Parse("{\"type\": \"array\",\"minItems\": 2,\"maxItems\" : 3}");