mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-10-28 03:20:15 +01:00
@@ -202,7 +202,8 @@ TEST(Document, Swap) {
|
||||
o.SetObject().AddMember("a", 1, a);
|
||||
|
||||
// Swap between Document and Value
|
||||
d1.Swap(o);
|
||||
// d1.Swap(o); // doesn't compile
|
||||
o.Swap(d1);
|
||||
EXPECT_TRUE(d1.IsObject());
|
||||
EXPECT_TRUE(o.IsArray());
|
||||
|
||||
@@ -212,8 +213,19 @@ TEST(Document, Swap) {
|
||||
d1.Swap(d2);
|
||||
EXPECT_TRUE(d1.IsArray());
|
||||
EXPECT_TRUE(d2.IsObject());
|
||||
EXPECT_EQ(&d2.GetAllocator(), &a);
|
||||
|
||||
// reset value
|
||||
Value().Swap(d1);
|
||||
EXPECT_TRUE(d1.IsNull());
|
||||
|
||||
// reset document, including allocator
|
||||
Document().Swap(d2);
|
||||
EXPECT_TRUE(d2.IsNull());
|
||||
EXPECT_NE(&d2.GetAllocator(), &a);
|
||||
}
|
||||
|
||||
|
||||
// This should be slow due to assignment in inner-loop.
|
||||
struct OutputStringStream : public std::ostringstream {
|
||||
typedef char Ch;
|
||||
|
||||
Reference in New Issue
Block a user