Skip to content

Commit

Permalink
add unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
bluehero committed Aug 5, 2017
1 parent 7c1f208 commit 9eb7bf8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/unittest/documenttest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ TEST(Document, ParseStream_AutoUTFInputStream) {
EXPECT_EQ(0, memcmp(bos.GetString(), bos2.GetString(), bos2.GetSize()));
}

TEST(Document, Assignment) {
Value x(1234);
Document d;
d = x;
EXPECT_TRUE(x.IsNull()); // move semantic
EXPECT_EQ(1234, d.GetInt());
}

TEST(Document, Swap) {
Document d1;
Document::AllocatorType& a = d1.GetAllocator();
Expand All @@ -300,7 +308,14 @@ TEST(Document, Swap) {
o.SetObject().AddMember("a", 1, a);

// Swap between Document and Value
// d1.Swap(o); // doesn't compile
d1.Swap(o);
EXPECT_TRUE(d1.IsObject());
EXPECT_TRUE(o.IsArray());

d1.Swap(o);
EXPECT_TRUE(d1.IsArray());
EXPECT_TRUE(o.IsObject());

o.Swap(d1);
EXPECT_TRUE(d1.IsObject());
EXPECT_TRUE(o.IsArray());
Expand Down

0 comments on commit 9eb7bf8

Please sign in to comment.