| 22 | using namespace sonic_json; |
| 23 | |
| 24 | void TestSuccess(const std::string schema, const std::string json, |
| 25 | const std::string expect) { |
| 26 | Document doc; |
| 27 | doc.Parse(schema); |
| 28 | if (doc.HasParseError()) |
| 29 | FAIL() << "failed parsing schema: " << schema << std::endl |
| 30 | << "failed start: " << schema.substr(doc.GetErrorOffset()) |
| 31 | << std::endl; |
| 32 | |
| 33 | doc.ParseSchema(json); |
| 34 | |
| 35 | if (doc.HasParseError()) |
| 36 | FAIL() << "failed parsing json: " << json << std::endl |
| 37 | << "failed start: " << json.substr(doc.GetErrorOffset()) |
| 38 | << std::endl; |
| 39 | |
| 40 | Document expect_doc; |
| 41 | expect_doc.Parse(expect); |
| 42 | if (expect_doc.HasParseError()) |
| 43 | FAIL() << "failed parsing expect: " << expect << std::endl |
| 44 | << "failed start: " << expect.substr(expect_doc.GetErrorOffset()) |
| 45 | << std::endl; |
| 46 | |
| 47 | EXPECT_TRUE(doc == expect_doc) |
| 48 | << "doc: " << doc.Dump() << std::endl |
| 49 | << "expect doc: " << expect_doc.Dump() << std::endl; |
| 50 | } |
| 51 | |
| 52 | void TestFailed(const std::string schema, const std::string json) { |
| 53 | Document doc; |
no test coverage detected