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

Macros

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

Functions

 TEST (SchemaValidator, Hasher)
 

Macro Definition Documentation

◆ INVALIDATE

#define INVALIDATE (   schema,
  json,
  invalidSchemaPointer,
  invalidSchemaKeyword,
  invalidDocumentPointer 
)
Value:
{\
SchemaValidator validator(schema);\
Document d;\
/*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)) {\
StringBuffer sb;\
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)) {\
StringBuffer sb;\
validator.GetInvalidDocumentPointer().Stringify(sb);\
printf("GetInvalidDocumentPointer() Expected: %s Actual: %s\n", invalidDocumentPointer, sb.GetString());\
ADD_FAILURE();\
}\
}
GenericPointer< Value, CrtAllocator > Pointer
Definition: fwd.h:126
static const char json[]
Definition: namespacetest.cpp:32
int strcmp(const char *s1, const char *s2)
Definition: compat_ctype.c:116

◆ TEST_HASHER

#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()));\
}

◆ VALIDATE

#define VALIDATE (   schema,
  json,
  expected 
)
Value:
{\
SchemaValidator validator(schema);\
Document d;\
/*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()) {\
StringBuffer sb;\
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());\
}\
}
static const char json[]
Definition: namespacetest.cpp:32

Function Documentation

◆ TEST()

TEST ( SchemaValidator  ,
Hasher   
)