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);
81 char*
json = ReadFile(filename, length);
83 printf(
"jsonchecker file %s not found", filename);
101 reader.IterativeParseInit();
102 while (!reader.IterativeParseComplete()) {
112 for (
int i = 1; i <= 3; i++) {
113 sprintf(filename,
"pass%d.json", i);
115 char*
json = ReadFile(filename, length);
117 printf(
"jsonchecker file %s not found", filename);
134 reader.IterativeParseInit();
135 while (!reader.IterativeParseComplete()) {
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.
#define EXPECT_TRUE(condition)
C-runtime library allocator.
Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS. ...
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
unsigned __int64 uint64_t
TEST(JsonChecker, Reader)
bool RawNumber(const char *, SizeType, bool)
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
bool String(const char *, SizeType, bool)
#define EXPECT_FALSE(condition)
bool Key(const char *, SizeType, bool)
A document for parsing JSON text as DOM.