| 77 | |
| 78 | template <typename Allocator, typename StackAllocator> |
| 79 | void ParseTest() { |
| 80 | typedef GenericDocument<UTF8<>, Allocator, StackAllocator> DocumentType; |
| 81 | DocumentType doc; |
| 82 | |
| 83 | const char* json = " { \"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3, 4] } "; |
| 84 | |
| 85 | doc.Parse(json); |
| 86 | ParseCheck(doc); |
| 87 | |
| 88 | doc.SetNull(); |
| 89 | StringStream s(json); |
| 90 | doc.template ParseStream<0>(s); |
| 91 | ParseCheck(doc); |
| 92 | |
| 93 | doc.SetNull(); |
| 94 | char *buffer = strdup(json); |
| 95 | doc.ParseInsitu(buffer); |
| 96 | ParseCheck(doc); |
| 97 | free(buffer); |
| 98 | |
| 99 | // Parse(const Ch*, size_t) |
| 100 | size_t length = strlen(json); |
| 101 | buffer = reinterpret_cast<char*>(malloc(length * 2)); |
| 102 | memcpy(buffer, json, length); |
| 103 | memset(buffer + length, 'X', length); |
| 104 | #if RAPIDJSON_HAS_STDSTRING |
| 105 | std::string s2(buffer, length); // backup buffer |
| 106 | #endif |
| 107 | doc.SetNull(); |
| 108 | doc.Parse(buffer, length); |
| 109 | free(buffer); |
| 110 | ParseCheck(doc); |
| 111 | |
| 112 | #if RAPIDJSON_HAS_STDSTRING |
| 113 | // Parse(std::string) |
| 114 | doc.SetNull(); |
| 115 | doc.Parse(s2); |
| 116 | ParseCheck(doc); |
| 117 | #endif |
| 118 | } |
| 119 | |
| 120 | TEST(Document, Parse) { |
| 121 | ParseTest<MemoryPoolAllocator<>, CrtAllocator>(); |
nothing calls this directly
no test coverage detected