ext/rj_schema/rapidjson/test/unittest/schematest.cpp in rj_schema-0.1.4 vs ext/rj_schema/rapidjson/test/unittest/schematest.cpp in rj_schema-0.2.0
- old
+ new
@@ -18,10 +18,13 @@
#include "rapidjson/writer.h"
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(variadic-macros)
+#elif defined(_MSC_VER)
+RAPIDJSON_DIAG_PUSH
+RAPIDJSON_DIAG_OFF(4822) // local class member function does not have a body
#endif
using namespace rapidjson;
#define TEST_HASHER(json1, json2, expected) \
@@ -1044,11 +1047,38 @@
" \"instanceRef\": \"#\", \"schemaRef\": \"#\","
" \"missing\": [\"name\", \"email\"]"
"}}");
}
+TEST(SchemaValidator, Object_Required_PassWithDefault) {
+ Document sd;
+ sd.Parse(
+ "{"
+ " \"type\": \"object\","
+ " \"properties\" : {"
+ " \"name\": { \"type\": \"string\", \"default\": \"William Shakespeare\" },"
+ " \"email\" : { \"type\": \"string\", \"default\": \"\" },"
+ " \"address\" : { \"type\": \"string\" },"
+ " \"telephone\" : { \"type\": \"string\" }"
+ " },"
+ " \"required\":[\"name\", \"email\"]"
+ "}");
+ SchemaDocument s(sd);
+ VALIDATE(s, "{ \"email\" : \"bill@stratford-upon-avon.co.uk\", \"address\" : \"Henley Street, Stratford-upon-Avon, Warwickshire, England\", \"authorship\" : \"in question\"}", true);
+ INVALIDATE(s, "{ \"name\": \"William Shakespeare\", \"address\" : \"Henley Street, Stratford-upon-Avon, Warwickshire, England\" }", "", "required", "",
+ "{ \"required\": {"
+ " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
+ " \"missing\": [\"email\"]"
+ "}}");
+ INVALIDATE(s, "{}", "", "required", "",
+ "{ \"required\": {"
+ " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
+ " \"missing\": [\"email\"]"
+ "}}");
+}
+
TEST(SchemaValidator, Object_PropertiesRange) {
Document sd;
sd.Parse("{\"type\":\"object\", \"minProperties\":2, \"maxProperties\":3}");
SchemaDocument s(sd);
@@ -1730,11 +1760,11 @@
static const size_t kCount = 4;
SchemaDocumentType* sd_[kCount];
typename DocumentType::AllocatorType documentAllocator_;
typename SchemaDocumentType::AllocatorType schemaAllocator_;
char documentBuffer_[16384];
- char schemaBuffer_[128 * 1024];
+ char schemaBuffer_[128u * 1024];
};
TEST(SchemaValidator, TestSuite) {
const char* filenames[] = {
"additionalItems.json",
@@ -2005,10 +2035,14 @@
}
TEST(SchemaValidator, Ref_remote_issue1210) {
class SchemaDocumentProvider : public IRemoteSchemaDocumentProvider {
SchemaDocument** collection;
+
+ SchemaDocumentProvider(const SchemaDocumentProvider&);
+ SchemaDocumentProvider& operator=(const SchemaDocumentProvider&);
+
public:
SchemaDocumentProvider(SchemaDocument** collection) : collection(collection) { }
virtual const SchemaDocument* GetRemoteDocument(const char* uri, SizeType length) {
int i = 0;
while (collection[i] && SchemaDocument::URIType(uri, length) != collection[i]->GetURI()) ++i;
@@ -2031,8 +2065,8 @@
VALIDATE(sx, "{\"country\":\"UK\"}", false);
VALIDATE(sx, "{\"country\":\"US\"}", true);
}
-#ifdef __clang__
+#if defined(_MSC_VER) || defined(__clang__)
RAPIDJSON_DIAG_POP
#endif