MCPcopy Create free account
hub / github.com/bytedance/sonic-cpp / TestSuccess

Function TestSuccess

tests/parse_schema_test.cpp:24–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22using namespace sonic_json;
23
24void 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
52void TestFailed(const std::string schema, const std::string json) {
53 Document doc;

Callers 1

TESTFunction · 0.85

Calls 4

ParseMethod · 0.80
HasParseErrorMethod · 0.80
GetErrorOffsetMethod · 0.80
DumpMethod · 0.80

Tested by

no test coverage detected