Fix would-crash tests if the default allocator used were kNeedFree.
The allocator cannot be destroyed before the Document, otherwise the Value destructor double frees.
This commit is contained in:
parent
50cb424c34
commit
117276c413
@ -325,6 +325,8 @@ TEST(Document, Swap) {
|
|||||||
EXPECT_TRUE(d1.IsNull());
|
EXPECT_TRUE(d1.IsNull());
|
||||||
|
|
||||||
// reset document, including allocator
|
// reset document, including allocator
|
||||||
|
// so clear o before so that it doesnt contain dangling elements
|
||||||
|
o.Clear();
|
||||||
Document().Swap(d2);
|
Document().Swap(d2);
|
||||||
EXPECT_TRUE(d2.IsNull());
|
EXPECT_TRUE(d2.IsNull());
|
||||||
EXPECT_NE(&d2.GetAllocator(), &a);
|
EXPECT_NE(&d2.GetAllocator(), &a);
|
||||||
|
@ -1078,9 +1078,9 @@ static void TestArray(T& x, Allocator& allocator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Value, Array) {
|
TEST(Value, Array) {
|
||||||
|
Value::AllocatorType allocator;
|
||||||
Value x(kArrayType);
|
Value x(kArrayType);
|
||||||
const Value& y = x;
|
const Value& y = x;
|
||||||
Value::AllocatorType allocator;
|
|
||||||
|
|
||||||
EXPECT_EQ(kArrayType, x.GetType());
|
EXPECT_EQ(kArrayType, x.GetType());
|
||||||
EXPECT_TRUE(x.IsArray());
|
EXPECT_TRUE(x.IsArray());
|
||||||
@ -1491,9 +1491,9 @@ static void TestObject(T& x, Allocator& allocator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Value, Object) {
|
TEST(Value, Object) {
|
||||||
|
Value::AllocatorType allocator;
|
||||||
Value x(kObjectType);
|
Value x(kObjectType);
|
||||||
const Value& y = x; // const version
|
const Value& y = x; // const version
|
||||||
Value::AllocatorType allocator;
|
|
||||||
|
|
||||||
EXPECT_EQ(kObjectType, x.GetType());
|
EXPECT_EQ(kObjectType, x.GetType());
|
||||||
EXPECT_TRUE(x.IsObject());
|
EXPECT_TRUE(x.IsObject());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user