* Safely assert upon passing NULL string without length
(requires usage of RAPIDJSON_ASSERT within an expression)
* Allow using a NULL string together with an explicit length 0
(GenericStringRef, GenericValue::SetString, ...), see #817
* Add GenericValue::SetString(StringRefType, Allocator&) overload
* Add tests for the various cases
note that std::numeric_limits<uint64_t>::max() and
std::numeric_limits<int64_t>::max() aren't exactly representable in a
double, so we need to be strictly less to be definitely lossless
UBSAN gave during Value.IsLosslessDouble test:
include/rapidjson/document.h:955:42: runtime error: value 1.84467e+19 is outside the range of representable values of type 'unsigned long'
maybe these tests should just be deleted?
UBSAN gave:
runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long'
runtime error: signed integer overflow: -9223372036854775808 - 2 cannot be represented in type 'long'
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`.
The tests state the current traits of types Document, Value and
StringBuffer. There are slight differences between them. It seems like a
good idea to extend this approach across more types, and to review the
expected traits across the board.