92 Commits

Author SHA1 Message Date
Philipp A. Hartmann
47c3c1ec9f Improved handling of NULL strings
* 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
2017-07-09 14:46:59 +02:00
Eli Fidler
c52cec7e51 fix undefined double to uint64_t cast
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'
2016-06-14 07:01:41 -07:00
Eli Fidler
760ea4316c avoid signed-integer underflow, which is undefined behavior
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'
2016-06-14 07:01:41 -07:00
Eli Fidler
5c77c9248c with recent clang, this triggers -Wunevaluated-expression
specifically, "expression with side effects has no effect in an unevaluated context"
2016-06-13 07:24:26 -07:00
Milo Yip
c71825f80e Improve Value::IsFloat() coverage 2016-04-16 22:14:38 +08:00
Milo Yip
c843a2655b Try to fix all /W4 warnings in VC2015 2016-04-04 15:01:34 +08:00
Milo Yip
01b2d463f7 Fix #573 2016-03-05 10:34:00 +08:00
Milo Yip
d9cf99baf6 Normalize all line endings 2016-03-04 09:44:01 +08:00
Sergey Kosarevsky
1ffb335915 Added RawNumber() to fix unit tests 2016-02-29 18:05:05 +01:00
Milo Yip
770f3a47b1 Bypass a VC2010 problem on IsLosslessDouble() 2016-02-21 14:57:08 +08:00
Milo Yip
4620fa60f5 Fix VS2010 compilation errors 2016-02-21 12:52:14 +08:00
Milo Yip
b8c83c53b1 Resolve conflicts 2016-02-19 23:40:48 +08:00
Milo Yip
46dc8e9240 Add implicit constructors of GenericValue for GenercArray|Object
Also remove SetArray|Object(…)
2016-02-19 00:49:05 +08:00
Milo Yip
d13be6c721 Change pointer to reference in GenericArray|Object 2016-02-18 19:04:22 +08:00
Milo Yip
e731726c56 Optimize memory consumption with RAPIDJSON_48BITPOINTER_OPTIMIZATION
#330
2016-02-15 11:20:00 +08:00
Milo Yip
1634395378 Add object helper 2016-02-14 13:49:52 +08:00
Milo Yip
960324a95b Try to fix gcc compilation error 2016-02-13 23:07:26 +08:00
Milo Yip
2a78b4da8c Fix Value.String test compilation error 2016-02-13 22:11:12 +08:00
Milo Yip
0b098eb38d Rectify constness of Array 2016-02-13 22:09:14 +08:00
Milo Yip
59309b5dd2 Add GenericArray helper class with range-based for 2016-02-13 19:06:03 +08:00
Milo Yip
513fe7894e Add templated accessors for C string 2016-02-12 23:06:49 +08:00
Milo Yip
4d648fdcd8 Add templated accessors 2016-02-12 18:23:32 +08:00
Milo Yip
8b4c999888 Add Value::GetFloat(), Value::IsLossLessFloat/Double()
Fix #341
2016-02-12 16:33:31 +08:00
Milo Yip
c828037784 Make a stackoverflow solution 2016-02-06 16:55:15 +08:00
Milo Yip
d8c793f23f Disable type_traits 2016-01-23 15:27:59 +08:00
Milo Yip
a6eb15d274 Fix warnings in clang for C++11 2016-01-23 14:37:15 +08:00
Milo Yip
c6384da755 Try to fix clang and gcc warnings problems again x11 2015-12-18 20:53:07 +08:00
Milo Yip
6d6381f596 Try to fix clang and gcc warnings problems again x7 2015-12-18 20:15:11 +08:00
Milo Yip
d72039f3ef Try to fix clang and gcc warnings problems again x6 2015-12-18 20:06:58 +08:00
Milo Yip
d6478991d0 Try to fix clang and gcc warnings problems again x4 2015-12-18 19:54:10 +08:00
Milo Yip
74c8dcfd57 Fix clang -Weverything 2015-12-18 18:34:04 +08:00
Philipp A. Hartmann
46e1696316 add free inline swap functions 2015-07-13 09:35:15 +02:00
miloyip
6e1d10ec6b Add GenericValue::EraseMember(string types) APIs 2015-05-21 16:12:33 +08:00
miloyip
2786103abd Add Value::XXXMember(...) overloads for std::string 2015-05-12 22:48:14 +08:00
miloyip
8d39282af5 Update license headers for tests 2015-04-18 21:41:38 +08:00
miloyip
933c4a6cb1 Improve Value deep-clone coverage 2015-04-13 23:12:57 +08:00
miloyip
59ffb9e5f0 Try to fix a gcc/clang error 2015-04-13 18:32:11 +08:00
miloyip
d439f989bf Add valuetest coverage 2015-04-13 18:10:07 +08:00
Milo Yip
d7ad55f49e Another two warnings 2015-04-11 00:20:10 +08:00
Milo Yip
09448e980b Another warning in valuetest 2015-04-11 00:12:15 +08:00
Milo Yip
2452afbf3c Fix -Wfloat-equal warnings in Value::operator== and valuetest 2015-04-11 00:02:17 +08:00
Philipp A. Hartmann
06c3ddbac5 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`.
2015-03-10 19:11:27 +01:00
unknown
63ad11c367 add support for AppVeyor CI for checking Windows builds 2015-02-17 10:42:43 +01:00
Milo Yip
24563b28fb Correct Value(kStringType) and more assertions 2015-01-13 23:49:53 +08:00
Milo Yip
c8bed6b8cc Fix compilation errors in unit tests for VC 2014-11-23 08:38:48 +08:00
Drew Noakes
6aa664eeef Document traits of types using <type_traits> and static_assert in tests.
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.
2014-10-31 11:00:57 +00:00
Zhihao Yuan
7303d92990 Disambiguate GenericValue's [0] and ["string"] 2014-10-23 21:50:39 -04:00
Milo Yip
bc9d7866be Merge pull request #128 from pah/feature/cxx11-move
Initial C++11 move support
2014-09-03 09:37:35 +08:00
Milo Yip
15d70d6a7b Merge pull request #127 from pah/feature/value-different-allocators
GenericValue: accept values with different allocators for read-only access
2014-09-03 09:37:15 +08:00
Kosta
08e81097eb final fix for the unit test case... 2014-09-01 12:54:50 +02:00