| 31 | |
| 32 | template <typename DocumentType> |
| 33 | void ParseCheck(DocumentType& doc) { |
| 34 | typedef typename DocumentType::ValueType ValueType; |
| 35 | |
| 36 | EXPECT_FALSE(doc.HasParseError()); |
| 37 | if (doc.HasParseError()) |
| 38 | printf("Error: %d at %zu\n", static_cast<int>(doc.GetParseError()), doc.GetErrorOffset()); |
| 39 | EXPECT_TRUE(static_cast<ParseResult>(doc)); |
| 40 | |
| 41 | EXPECT_TRUE(doc.IsObject()); |
| 42 | |
| 43 | EXPECT_TRUE(doc.HasMember("hello")); |
| 44 | const ValueType& hello = doc["hello"]; |
| 45 | EXPECT_TRUE(hello.IsString()); |
| 46 | EXPECT_STREQ("world", hello.GetString()); |
| 47 | |
| 48 | EXPECT_TRUE(doc.HasMember("t")); |
| 49 | const ValueType& t = doc["t"]; |
| 50 | EXPECT_TRUE(t.IsTrue()); |
| 51 | |
| 52 | EXPECT_TRUE(doc.HasMember("f")); |
| 53 | const ValueType& f = doc["f"]; |
| 54 | EXPECT_TRUE(f.IsFalse()); |
| 55 | |
| 56 | EXPECT_TRUE(doc.HasMember("n")); |
| 57 | const ValueType& n = doc["n"]; |
| 58 | EXPECT_TRUE(n.IsNull()); |
| 59 | |
| 60 | EXPECT_TRUE(doc.HasMember("i")); |
| 61 | const ValueType& i = doc["i"]; |
| 62 | EXPECT_TRUE(i.IsNumber()); |
| 63 | EXPECT_EQ(123, i.GetInt()); |
| 64 | |
| 65 | EXPECT_TRUE(doc.HasMember("pi")); |
| 66 | const ValueType& pi = doc["pi"]; |
| 67 | EXPECT_TRUE(pi.IsNumber()); |
| 68 | EXPECT_DOUBLE_EQ(3.1416, pi.GetDouble()); |
| 69 | |
| 70 | EXPECT_TRUE(doc.HasMember("a")); |
| 71 | const ValueType& a = doc["a"]; |
| 72 | EXPECT_TRUE(a.IsArray()); |
| 73 | EXPECT_EQ(4u, a.Size()); |
| 74 | for (SizeType j = 0; j < 4; j++) |
| 75 | EXPECT_EQ(j + 1, a[j].GetUint()); |
| 76 | } |
| 77 | |
| 78 | template <typename Allocator, typename StackAllocator> |
| 79 | void ParseTest() { |
no test coverage detected