| 723 | )example"; |
| 724 | |
| 725 | void TestSchemaRoundTrip(const std::shared_ptr<Schema>& schema) { |
| 726 | rj::StringBuffer sb; |
| 727 | rj::Writer<rj::StringBuffer> writer(sb); |
| 728 | |
| 729 | DictionaryFieldMapper mapper(*schema); |
| 730 | |
| 731 | writer.StartObject(); |
| 732 | ASSERT_OK(json::WriteSchema(*schema, mapper, &writer)); |
| 733 | writer.EndObject(); |
| 734 | |
| 735 | std::string json_schema = sb.GetString(); |
| 736 | |
| 737 | rj::Document d; |
| 738 | // Pass explicit size to avoid ASAN issues with |
| 739 | // SIMD loads in RapidJson. |
| 740 | d.Parse(json_schema.data(), json_schema.size()); |
| 741 | |
| 742 | DictionaryMemo in_memo; |
| 743 | ASSERT_OK_AND_ASSIGN(auto result_schema, |
| 744 | json::ReadSchema(d, default_memory_pool(), &in_memo)); |
| 745 | AssertSchemaEqual(schema, result_schema, /*check_metadata=*/true); |
| 746 | } |
| 747 | |
| 748 | void TestArrayRoundTrip(const Array& array) { |
| 749 | static std::string name = "dummy"; |