Classes | Macros | Functions
unittest/schematest.cpp File Reference
#include "unittest.h"
#include "rapidjson/schema.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
Include dependency graph for unittest/schematest.cpp:

Go to the source code of this file.

Classes

class  RemoteSchemaDocumentProvider< SchemaDocumentType >
 

Macros

#define INVALIDATE(schema, json, invalidSchemaPointer, invalidSchemaKeyword, invalidDocumentPointer)
 
#define TEST_HASHER(json1, json2, expected)
 
#define VALIDATE(schema, json, expected)
 

Functions

template<typename Allocator >
static char * ReadFile (const char *filename, Allocator &allocator)
 
 TEST (SchemaValidator, Hasher)
 
 TEST (SchemaValidator, Typeless)
 
 TEST (SchemaValidator, MultiType)
 
 TEST (SchemaValidator, Enum_Typed)
 
 TEST (SchemaValidator, Enum_Typless)
 
 TEST (SchemaValidator, Enum_InvalidType)
 
 TEST (SchemaValidator, AllOf)
 
 TEST (SchemaValidator, AnyOf)
 
 TEST (SchemaValidator, OneOf)
 
 TEST (SchemaValidator, Not)
 
 TEST (SchemaValidator, Ref)
 
 TEST (SchemaValidator, Ref_AllOf)
 
 TEST (SchemaValidator, String)
 
 TEST (SchemaValidator, String_LengthRange)
 
 TEST (SchemaValidator, Integer)
 
 TEST (SchemaValidator, Integer_Range)
 
 TEST (SchemaValidator, Integer_Range64Boundary)
 
 TEST (SchemaValidator, Integer_RangeU64Boundary)
 
 TEST (SchemaValidator, Integer_Range64BoundaryExclusive)
 
 TEST (SchemaValidator, Integer_MultipleOf)
 
 TEST (SchemaValidator, Integer_MultipleOf64Boundary)
 
 TEST (SchemaValidator, Number_Range)
 
 TEST (SchemaValidator, Number_RangeInt)
 
 TEST (SchemaValidator, Number_RangeDouble)
 
 TEST (SchemaValidator, Number_RangeDoubleU64Boundary)
 
 TEST (SchemaValidator, Number_MultipleOf)
 
 TEST (SchemaValidator, Number_MultipleOfOne)
 
 TEST (SchemaValidator, Object)
 
 TEST (SchemaValidator, Object_Properties)
 
 TEST (SchemaValidator, Object_AdditionalPropertiesBoolean)
 
 TEST (SchemaValidator, Object_AdditionalPropertiesObject)
 
 TEST (SchemaValidator, Object_Required)
 
 TEST (SchemaValidator, Object_PropertiesRange)
 
 TEST (SchemaValidator, Object_PropertyDependencies)
 
 TEST (SchemaValidator, Object_SchemaDependencies)
 
 TEST (SchemaValidator, Array)
 
 TEST (SchemaValidator, Array_ItemsList)
 
 TEST (SchemaValidator, Array_ItemsTuple)
 
 TEST (SchemaValidator, Array_AdditionalItmes)
 
 TEST (SchemaValidator, Array_ItemsRange)
 
 TEST (SchemaValidator, Array_UniqueItems)
 
 TEST (SchemaValidator, Boolean)
 
 TEST (SchemaValidator, Null)
 
 TEST (SchemaValidator, ObjectInArray)
 
 TEST (SchemaValidator, MultiTypeInObject)
 
 TEST (SchemaValidator, MultiTypeWithObject)
 
 TEST (SchemaValidator, AllOf_Nested)
 
 TEST (SchemaValidator, EscapedPointer)
 
 TEST (SchemaValidator, ValidateMetaSchema)
 
 TEST (SchemaValidator, ValidateMetaSchema_UTF16)
 
 TEST (SchemaValidator, TestSuite)
 
 TEST (SchemaValidatingReader, Simple)
 
 TEST (SchemaValidatingReader, Invalid)
 
 TEST (SchemaValidatingWriter, Simple)
 
 TEST (Schema, Issue848)
 
 TEST (SchemaValidator, Issue608)
 
 TEST (SchemaValidator, Issue728_AllOfRef)
 
 TEST (SchemaValidator, Issue825)
 
 TEST (SchemaValidator, Issue1017_allOfHandler)
 

Macro Definition Documentation

#define INVALIDATE (   schema,
  json,
  invalidSchemaPointer,
  invalidSchemaKeyword,
  invalidDocumentPointer 
)
Value:
{\
SchemaValidator validator(schema);\
/*printf("\n%s\n", json);*/\
d.Parse(json);\
EXPECT_FALSE(d.HasParseError());\
EXPECT_FALSE(d.Accept(validator));\
EXPECT_FALSE(validator.IsValid());\
if (validator.GetInvalidSchemaPointer() != Pointer(invalidSchemaPointer)) {\
validator.GetInvalidSchemaPointer().Stringify(sb);\
printf("GetInvalidSchemaPointer() Expected: %s Actual: %s\n", invalidSchemaPointer, sb.GetString());\
ADD_FAILURE();\
}\
ASSERT_TRUE(validator.GetInvalidSchemaKeyword() != 0);\
if (strcmp(validator.GetInvalidSchemaKeyword(), invalidSchemaKeyword) != 0) {\
printf("GetInvalidSchemaKeyword() Expected: %s Actual %s\n", invalidSchemaKeyword, validator.GetInvalidSchemaKeyword());\
ADD_FAILURE();\
}\
if (validator.GetInvalidDocumentPointer() != Pointer(invalidDocumentPointer)) {\
validator.GetInvalidDocumentPointer().Stringify(sb);\
printf("GetInvalidDocumentPointer() Expected: %s Actual: %s\n", invalidDocumentPointer, sb.GetString());\
ADD_FAILURE();\
}\
}
d
GenericPointer< Value, CrtAllocator > Pointer
Definition: fwd.h:126
static const char json[]
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition: document.h:2477
GenericStringBuffer< UTF8< char >, CrtAllocator > StringBuffer
Definition: fwd.h:59
GenericSchemaValidator< SchemaDocument, BaseReaderHandler< UTF8< char >, void >, CrtAllocator > SchemaValidator
Definition: fwd.h:145

Definition at line 125 of file unittest/schematest.cpp.

#define TEST_HASHER (   json1,
  json2,
  expected 
)
Value:
{\
Document d1, d2;\
d1.Parse(json1);\
ASSERT_FALSE(d1.HasParseError());\
d2.Parse(json2);\
ASSERT_FALSE(d2.HasParseError());\
internal::Hasher<Value, CrtAllocator> h1, h2;\
d1.Accept(h1);\
d2.Accept(h2);\
ASSERT_TRUE(h1.IsValid());\
ASSERT_TRUE(h2.IsValid());\
/*printf("%s: 0x%016llx\n%s: 0x%016llx\n\n", json1, h1.GetHashCode(), json2, h2.GetHashCode());*/\
EXPECT_TRUE(expected == (h1.GetHashCode() == h2.GetHashCode()));\
}
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition: document.h:2477
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
Definition: document.h:2296

Definition at line 27 of file unittest/schematest.cpp.

#define VALIDATE (   schema,
  json,
  expected 
)
Value:
{\
SchemaValidator validator(schema);\
/*printf("\n%s\n", json);*/\
d.Parse(json);\
EXPECT_FALSE(d.HasParseError());\
EXPECT_TRUE(expected == d.Accept(validator));\
EXPECT_TRUE(expected == validator.IsValid());\
if ((expected) && !validator.IsValid()) {\
validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);\
printf("Invalid schema: %s\n", sb.GetString());\
printf("Invalid keyword: %s\n", validator.GetInvalidSchemaKeyword());\
sb.Clear();\
validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);\
printf("Invalid document: %s\n", sb.GetString());\
}\
}
d
static const char json[]
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition: document.h:2477
GenericStringBuffer< UTF8< char >, CrtAllocator > StringBuffer
Definition: fwd.h:59
GenericSchemaValidator< SchemaDocument, BaseReaderHandler< UTF8< char >, void >, CrtAllocator > SchemaValidator
Definition: fwd.h:145

Definition at line 105 of file unittest/schematest.cpp.

Function Documentation

template<typename Allocator >
static char* ReadFile ( const char *  filename,
Allocator allocator 
)
static

Definition at line 977 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Hasher   
)

Definition at line 43 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Typeless   
)

Definition at line 153 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
MultiType   
)

Definition at line 163 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Enum_Typed   
)

Definition at line 173 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Enum_Typless   
)

Definition at line 182 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Enum_InvalidType   
)

Definition at line 193 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
AllOf   
)

Definition at line 202 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
AnyOf   
)

Definition at line 221 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
OneOf   
)

Definition at line 231 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Not   
)

Definition at line 242 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Ref   
)

Definition at line 252 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Ref_AllOf   
)

Definition at line 280 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
String   
)

Definition at line 317 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
String_LengthRange   
)

Definition at line 330 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Integer   
)

Definition at line 364 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Integer_Range   
)

Definition at line 379 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Integer_Range64Boundary   
)

Definition at line 392 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Integer_RangeU64Boundary   
)

Definition at line 409 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Integer_Range64BoundaryExclusive   
)

Definition at line 426 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Integer_MultipleOf   
)

Definition at line 437 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Integer_MultipleOf64Boundary   
)

Definition at line 450 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Number_Range   
)

Definition at line 460 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Number_RangeInt   
)

Definition at line 476 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Number_RangeDouble   
)

Definition at line 496 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Number_RangeDoubleU64Boundary   
)

Definition at line 520 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Number_MultipleOf   
)

Definition at line 536 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Number_MultipleOfOne   
)

Definition at line 555 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Object   
)

Definition at line 565 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Object_Properties   
)

Definition at line 576 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Object_AdditionalPropertiesBoolean   
)

Definition at line 597 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Object_AdditionalPropertiesObject   
)

Definition at line 618 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Object_Required   
)

Definition at line 639 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Object_PropertiesRange   
)

Definition at line 660 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Object_PropertyDependencies   
)

Definition at line 672 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Object_SchemaDependencies   
)

Definition at line 695 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Array   
)

Definition at line 763 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Array_ItemsList   
)

Definition at line 773 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Array_ItemsTuple   
)

Definition at line 789 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Array_AdditionalItmes   
)

Definition at line 820 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Array_ItemsRange   
)

Definition at line 850 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Array_UniqueItems   
)

Definition at line 862 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Boolean   
)

Definition at line 872 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Null   
)

Definition at line 883 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
ObjectInArray   
)

Definition at line 896 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
MultiTypeInObject   
)

Definition at line 906 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
MultiTypeWithObject   
)

Definition at line 924 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
AllOf_Nested   
)

Definition at line 942 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
EscapedPointer   
)

Definition at line 963 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
ValidateMetaSchema   
)

Definition at line 1007 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
ValidateMetaSchema_UTF16   
)

Definition at line 1028 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
TestSuite   
)

Definition at line 1123 of file unittest/schematest.cpp.

TEST ( SchemaValidatingReader  ,
Simple   
)

Definition at line 1227 of file unittest/schematest.cpp.

TEST ( SchemaValidatingReader  ,
Invalid   
)

Definition at line 1242 of file unittest/schematest.cpp.

TEST ( SchemaValidatingWriter  ,
Simple   
)

Definition at line 1260 of file unittest/schematest.cpp.

TEST ( Schema  ,
Issue848   
)

Definition at line 1284 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Issue608   
)

Definition at line 1308 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Issue728_AllOfRef   
)

Definition at line 1318 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Issue825   
)

Definition at line 1325 of file unittest/schematest.cpp.

TEST ( SchemaValidator  ,
Issue1017_allOfHandler   
)

Definition at line 1332 of file unittest/schematest.cpp.



choreo_rapidjson
Author(s):
autogenerated on Thu Jul 18 2019 03:59:09