21 static char*
ReadFile(
const char* filename,
size_t& length) {
22 const char *paths[] = {
26 "../../bin/jsonchecker",
27 "../../../bin/jsonchecker" 31 for (
size_t i = 0; i <
sizeof(paths) /
sizeof(paths[0]); i++) {
32 sprintf(buffer,
"%s/%s", paths[i], filename);
33 fp = fopen(buffer,
"rb");
41 fseek(fp, 0, SEEK_END);
42 length =
static_cast<size_t>(ftell(fp));
43 fseek(fp, 0, SEEK_SET);
44 char*
json =
static_cast<char*
>(malloc(length + 1));
45 size_t readLength = fread(json, 1, length, fp);
46 json[readLength] =
'\0';
52 bool Null() {
return true; }
53 bool Bool(
bool) {
return true; }
54 bool Int(
int) {
return true; }
55 bool Uint(
unsigned) {
return true; }
73 for (
int i = 1; i <= 33; i++) {
79 sprintf(filename,
"fail%d.json", i);
83 printf(
"jsonchecker file %s not found", filename);
101 reader.IterativeParseInit();
102 while (!reader.IterativeParseComplete()) {
106 EXPECT_TRUE(reader.HasParseError()) << filename;
112 for (
int i = 1; i <= 3; i++) {
113 sprintf(filename,
"pass%d.json", i);
117 printf(
"jsonchecker file %s not found", filename);
123 document.
Parse(json);
134 reader.IterativeParseInit();
135 while (!reader.IterativeParseComplete()) {
139 EXPECT_FALSE(reader.HasParseError()) << filename;
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Iterative(constant complexity in terms of function call stack size) parsing.
A document for parsing JSON text as DOM.
static char * ReadFile(const char *filename, size_t &length)
Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS. ...
unsigned __int64 uint64_t
bool String(const char *, SizeType, bool)
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
TEST(JsonChecker, Reader)
C-runtime library allocator.
bool RawNumber(const char *, SizeType, bool)
bool Key(const char *, SizeType, bool)
bool HasParseError() const
Whether a parse error has occured in the last parsing.