21static 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);
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);
123 document.
Parse(json);
C-runtime library allocator.
A document for parsing JSON text as DOM.
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
bool IterativeParseNext(InputStream &is, Handler &handler)
Parse one token from JSON text.
void IterativeParseInit()
Initialize JSON text token-by-token parsing.
RAPIDJSON_FORCEINLINE bool IterativeParseComplete() const
Check if token-by-token parsing JSON text is complete.
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
#define EXPECT_TRUE(condition)
#define TEST(test_case_name, test_name)
#define EXPECT_FALSE(condition)
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
@ kParseDefaultFlags
Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS.
@ kParseIterativeFlag
Iterative(constant complexity in terms of function call stack size) parsing.
unsigned __int64 uint64_t
bool String(const char *, SizeType, bool)
bool Key(const char *, SizeType, bool)
bool RawNumber(const char *, SizeType, bool)