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:
Philipp A. Hartmann
2015-03-10 19:11:27 +01:00
parent c745c953ad
commit 06c3ddbac5
2 changed files with 52 additions and 2 deletions

View File

@@ -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
{