mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-10-28 03:20:15 +01:00
GenericValue::AddMember<T>: add missing overload (closes #254)
As discovered by @felipegb94, there are missing overloads to the `GenericValue::AddMember<T>` template function, taking an explicit `GenericValue&` as a name and accepting arbitrary primitive values. This patch adds the missing overloads. The `StringRefType` overload is needed to disambiguate the addition of a string literal as value. Some tests are added to `TEST(Value, Object)` in `valuetest.cpp`.
This commit is contained in:
@@ -919,6 +919,19 @@ TEST(Value, Object) {
|
||||
EXPECT_EQ(8u, o.MemberCount());
|
||||
}
|
||||
|
||||
// AddMember<T>(Value&, T, Allocator)
|
||||
{
|
||||
Value o(kObjectType);
|
||||
|
||||
Value n("s");
|
||||
o.AddMember(n, "string", allocator);
|
||||
EXPECT_EQ(1u, o.MemberCount());
|
||||
|
||||
Value count("#");
|
||||
o.AddMember(count, o.MemberCount(), allocator);
|
||||
EXPECT_EQ(2u, o.MemberCount());
|
||||
}
|
||||
|
||||
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
||||
// AddMember(GenericValue&&, ...) variants
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user