Add Tests for WriteUInt64(), WriteInt64() of generic stream

This commit is contained in:
miloyip 2015-04-13 13:41:56 +08:00
parent fddffbe82b
commit 79433827e8
2 changed files with 9 additions and 5 deletions

View File

@ -25,7 +25,7 @@
using namespace rapidjson;
static const char kJson[] = "{\"hello\":\"world\",\"t\":true,\"f\":false,\"n\":null,\"i\":123,\"pi\":3.1416,\"a\":[1,2,3]}";
static const char kJson[] = "{\"hello\":\"world\",\"t\":true,\"f\":false,\"n\":null,\"i\":123,\"pi\":3.1416,\"a\":[1,2,3],\"u64\":1234567890123456789,\"i64\":-1234567890123456789}";
TEST(PrettyWriter, Basic) {
StringBuffer buffer;
@ -45,7 +45,9 @@ TEST(PrettyWriter, Basic) {
" 1,\n"
" 2,\n"
" 3\n"
" ]\n"
" ],\n"
" \"u64\": 1234567890123456789,\n"
" \"i64\": -1234567890123456789\n"
"}",
buffer.GetString());
}
@ -69,7 +71,9 @@ TEST(PrettyWriter, SetIndent) {
"\t\t1,\n"
"\t\t2,\n"
"\t\t3\n"
"\t]\n"
"\t],\n"
"\t\"u64\": 1234567890123456789,\n"
"\t\"i64\": -1234567890123456789\n"
"}",
buffer.GetString());
}

View File

@ -152,7 +152,7 @@ private:
};
TEST(Writer, OStreamWrapper) {
StringStream s("{ \"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3] } ");
StringStream s("{ \"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3], \"u64\": 1234567890123456789, \"i64\":-1234567890123456789 } ");
std::stringstream ss;
OStreamWrapper os(ss);
@ -163,7 +163,7 @@ TEST(Writer, OStreamWrapper) {
reader.Parse<0>(s, writer);
std::string actual = ss.str();
EXPECT_STREQ("{\"hello\":\"world\",\"t\":true,\"f\":false,\"n\":null,\"i\":123,\"pi\":3.1416,\"a\":[1,2,3]}", actual.c_str());
EXPECT_STREQ("{\"hello\":\"world\",\"t\":true,\"f\":false,\"n\":null,\"i\":123,\"pi\":3.1416,\"a\":[1,2,3],\"u64\":1234567890123456789,\"i64\":-1234567890123456789}", actual.c_str());
}
TEST(Writer, AssertRootMayBeAnyValue) {