| 44 | } |
| 45 | |
| 46 | void TestJsonString(const std::string& json_file) { |
| 47 | std::string styled_str; |
| 48 | toft::File::ReadAll(json_file, &styled_str); |
| 49 | toft::Person pb; |
| 50 | ProtoJsonFormat::ParseFromString(styled_str, &pb); |
| 51 | |
| 52 | toft::Person expected_pb; |
| 53 | { |
| 54 | std::string content; |
| 55 | std::string path = "debug_string.txt"; |
| 56 | toft::File::ReadAll(path, &content); |
| 57 | google::protobuf::TextFormat::ParseFromString(content, &expected_pb); |
| 58 | } |
| 59 | EXPECT_EQ(pb.SerializeAsString(), expected_pb.SerializeAsString()); |
| 60 | } |
| 61 | |
| 62 | TEST(JsonFormtTest, ParseFromFastJsonString) { |
| 63 | std::string path = "json_fast_string.txt"; |