Skip to content

Commit

Permalink
documenttest.cpp: EXPECT_THROW when checking empty allocator (closes T…
Browse files Browse the repository at this point in the history
…encent#469)

In the MoveConstructor/MoveAssignment tests, a check for a `NULL` allocator
return has been used to check for the correct moved-from state of a Document.
After the merge of Tencent#426, the GetAllocator call fails with an assertion,
if the allocator of a GenericDocument is NULL.

Check for the throw, instead of NULL in the move-related tests.
Tested with GCC 4.9 on Linux with C++11 enabled.

Reported-by: @woldendans
  • Loading branch information
pah committed Nov 16, 2015
1 parent b39a898 commit c8d298b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/unittest/documenttest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ TYPED_TEST(DocumentMove, MoveConstructor) {
EXPECT_TRUE(a.IsNull());
EXPECT_TRUE(b.IsArray());
EXPECT_EQ(3u, b.Size());
EXPECT_EQ(&a.GetAllocator(), (void*)0);
EXPECT_THROW(a.GetAllocator(), AssertException);
EXPECT_EQ(&b.GetAllocator(), &allocator);

b.Parse("{\"Foo\": \"Bar\", \"Baz\": 42}");
Expand All @@ -394,7 +394,7 @@ TYPED_TEST(DocumentMove, MoveConstructor) {
EXPECT_TRUE(b.IsNull());
EXPECT_TRUE(c.IsObject());
EXPECT_EQ(2u, c.MemberCount());
EXPECT_EQ(&b.GetAllocator(), (void*)0);
EXPECT_THROW(b.GetAllocator(), AssertException);
EXPECT_EQ(&c.GetAllocator(), &allocator);
}

Expand Down Expand Up @@ -475,7 +475,7 @@ TYPED_TEST(DocumentMove, MoveAssignment) {
EXPECT_TRUE(a.IsNull());
EXPECT_TRUE(b.IsArray());
EXPECT_EQ(3u, b.Size());
EXPECT_EQ(&a.GetAllocator(), (void*)0);
EXPECT_THROW(a.GetAllocator(), AssertException);
EXPECT_EQ(&b.GetAllocator(), &allocator);

b.Parse("{\"Foo\": \"Bar\", \"Baz\": 42}");
Expand All @@ -489,7 +489,7 @@ TYPED_TEST(DocumentMove, MoveAssignment) {
EXPECT_TRUE(b.IsNull());
EXPECT_TRUE(c.IsObject());
EXPECT_EQ(2u, c.MemberCount());
EXPECT_EQ(&b.GetAllocator(), (void*)0);
EXPECT_THROW(b.GetAllocator(), AssertException);
EXPECT_EQ(&c.GetAllocator(), &allocator);
}

Expand Down

0 comments on commit c8d298b

Please sign in to comment.