Fixed issue 18 from 0.1x branch
git-svn-id: https://rapidjson.googlecode.com/svn/trunk@64 c5894555-1306-4e8d-425f-1f6f381ee07c
This commit is contained in:
parent
3d77ef8ee9
commit
4fdd805c7d
@ -298,9 +298,9 @@ public:
|
|||||||
RAPIDJSON_ASSERT(data_.o.size > 0);
|
RAPIDJSON_ASSERT(data_.o.size > 0);
|
||||||
RAPIDJSON_ASSERT(data_.o.members != 0);
|
RAPIDJSON_ASSERT(data_.o.members != 0);
|
||||||
|
|
||||||
if (data_.o.size > 1) {
|
Member* last = data_.o.members + (data_.o.size - 1);
|
||||||
|
if (data_.o.size > 1 && m != last) {
|
||||||
// Move the last one to this place
|
// Move the last one to this place
|
||||||
Member* last = data_.o.members + (data_.o.size - 1);
|
|
||||||
m->name = last->name;
|
m->name = last->name;
|
||||||
m->value = last->value;
|
m->value = last->value;
|
||||||
}
|
}
|
||||||
|
@ -576,3 +576,17 @@ TEST(Value, BigNestedObject) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue 18: Error removing last element of object
|
||||||
|
// http://code.google.com/p/rapidjson/issues/detail?id=18
|
||||||
|
TEST(Value, RemoveLastElement) {
|
||||||
|
rapidjson::Document doc;
|
||||||
|
rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
|
||||||
|
rapidjson::Value objVal(rapidjson::kObjectType);
|
||||||
|
objVal.AddMember("var1", 123, allocator);
|
||||||
|
objVal.AddMember("var2", "444", allocator);
|
||||||
|
objVal.AddMember("var3", 555, allocator);
|
||||||
|
EXPECT_TRUE(objVal.HasMember("var3"));
|
||||||
|
objVal.RemoveMember("var3"); // Assertion here in r61
|
||||||
|
EXPECT_FALSE(objVal.HasMember("var3"));
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user