TEST(JsonChecker, Reader) { char filename[256]; // jsonchecker/failXX.json for (int i = 1; i <= 33; i++) { if (i == 18) // fail18.json is valid in rapidjson, which has no limitation on depth of nesting. continue; sprintf(filename, "jsonchecker/fail%d.json", i); size_t length; char* json = ReadFile(filename, length); if (!json) { sprintf(filename, "../../bin/jsonchecker/fail%d.json", i); json = ReadFile(filename, length); if (!json) { printf("jsonchecker file %s not found", filename); continue; } } GenericDocument<UTF8<>, CrtAllocator> document; // Use Crt allocator to check exception-safety (no memory leak) if (!document.Parse((const char*)json).HasParseError()) FAIL(); //printf("%s(%u):%s\n", filename, (unsigned)document.GetErrorOffset(), document.GetParseError()); free(json); } // passX.json for (int i = 1; i <= 3; i++) { sprintf(filename, "jsonchecker/pass%d.json", i); size_t length; char* json = ReadFile(filename, length); if (!json) { sprintf(filename, "../../bin/jsonchecker/pass%d.json", i); json = ReadFile(filename, length); if (!json) { printf("jsonchecker file %s not found", filename); continue; } } GenericDocument<UTF8<>, CrtAllocator> document; // Use Crt allocator to check exception-safety (no memory leak) document.Parse((const char*)json); EXPECT_TRUE(!document.HasParseError()); free(json); } }
TEST_F(RapidJson, SIMD_SUFFIX(DocumentParse_CrtAllocator)) { for (size_t i = 0; i < kTrialCount; i++) { memcpy(temp_, json_, length_ + 1); GenericDocument<UTF8<>, CrtAllocator> doc; doc.Parse(temp_); ASSERT_TRUE(doc.IsObject()); } }