From 602f87545ecfca0f1a98f1dc730686a6b7518e7a Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sat, 2 May 2015 10:28:10 +0800 Subject: [PATCH] Add a failed case --- include/rapidjson/schema.h | 1 + test/unittest/schematest.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h index 0c5a2b7d..1817263c 100644 --- a/include/rapidjson/schema.h +++ b/include/rapidjson/schema.h @@ -870,6 +870,7 @@ private: if (CurrentContext().valueSchema) PushSchema(*CurrentContext().valueSchema); + return true; } } diff --git a/test/unittest/schematest.cpp b/test/unittest/schematest.cpp index d675150b..c9664166 100644 --- a/test/unittest/schematest.cpp +++ b/test/unittest/schematest.cpp @@ -425,3 +425,13 @@ TEST(SchemaValidator, Null) { VALIDATE(s, "0", false); VALIDATE(s, "\"\"", false); } + +TEST(SchemaValidator, ObjectInArray) { + Document sd; + sd.Parse("{\"type\":\"array\", \"items\": { \"type\":\"string\" }}"); + Schema s(sd); + + VALIDATE(s, "[]", true); + VALIDATE(s, "[1]", false); + VALIDATE(s, "[{}]", false); +} \ No newline at end of file