635 Commits

Author SHA1 Message Date
ylavic
92f99bc2ee RAPIDJSON_NOEXCEPT_ASSERT() should never throw.
clang warns about throwing from RAPIDJSON_NOEXCEPT_ASSERT() in a nothrow
context.

If RAPIDJSON_ASSERT() throws it can never be used for _NOEXCEPT_ASSERT(),
so use C assert() instead.

Finally (and originally), since RAPIDJSON_ASSERT() in "unittest.h" throws,
make it define RAPIDJSON_ASSERT_THROWS for RAPIDJSON_NOEXCEPT_ASSERT() to
now do the right thing.
2019-05-09 13:37:49 +02:00
Milo Yip
b56eb28575
Merge branch 'master' into pointer_less_than 2018-12-18 09:32:09 +08:00
ylavic
2ce91b823c Pointer tests now need <algorithm> (for std::swap), but no tabs. 2018-12-17 14:45:23 +01:00
ylavic
a66cf7924c Allow to (std::)Swap two pointers. 2018-12-17 14:33:32 +01:00
ylavic
eb6ee17d2d Speed up Pointer::operator<().
Speed is more important than alphabetical order (which makes few sense in
JSON in general, and with pointers especially). The use case is indexing
in std containers, i.e. O(log n) with rbtree, so the faster comparison
the better.
2018-12-12 22:32:56 +01:00
ylavic
0e34ed43f4 Rework Pointer::operator<() loop.
I must be too dumb to understand the mess MSVC (32bit only) did with the
previous loop, and to figure out how it might have make it never end.
Anyway, hopefully any compiler can grok this new loop...
2018-12-12 15:15:43 +01:00
ylavic
af17f196c6 Unit test for Pointer::operator<(). 2018-12-11 00:19:13 +01:00
Milo Yip
66eb6067b1
Merge pull request #1425 from ylavic/filereadstream_peek4
Fix off by one in FileReadStream::Peek4()
2018-12-06 23:44:10 +08:00
ylavic
38d25d7458 Fix FileReadStream::Peek4().
Until Read() reaches EOF, Peek4() must not take off by one in
bufferLast_ into account; otherwise a buffer of size exactly 4 always
returns NULL.
2018-12-06 08:38:21 +01:00
ylavic
8c14787398 Unit test for invalid GenericRegex (unclosed parenthesis). 2018-12-03 11:49:34 +01:00
Philipp A. Hartmann
0cc44c82c9
Update test/unittest/pointertest.cpp
Co-Authored-By: yhager <yhager@users.noreply.github.com>
2018-10-31 20:31:04 -07:00
Yuval Hager
a77b49dcb8 silence clang-7 self-assign-overloaded warning 2018-10-26 14:58:57 -07:00
Lele Gaifax
91d50c849d Add test case on kParseNumbersAsStringsFlag being able to load big ints
See issue #1368.
2018-10-08 10:21:25 +02:00
Milo Yip
f5f6052c56
Merge pull request #1327 from gongminmin/FixCompileInVS
Fix the compiling problems in VS
2018-09-10 11:23:26 +08:00
Milo Yip
08b1a8a41e
Merge pull request #1302 from chwarr/min-max-guard
Guard against min/max being macros in reader.h
2018-09-10 11:22:28 +08:00
Lele Gaifax
c9eabf9e13 Extend the test on issue #1336 to cover all basic types 2018-08-05 09:44:15 +02:00
Lele Gaifax
3fc9299b84 Add simple test for issue #1336 2018-08-03 12:34:03 +02:00
Veselin Georgiev
748a652f04 Fix SIGBUS due to unaligned access
Update RAPIDJSON_ALIGN() to always align on an 8-byte boundary
unless otherwise overridden.

On some platforms (such as ARM), 64-bit items (such as doubles and
64-bit integers) must be aligned to an 8 byte address, even though the
architecture is only 32-bits. On these platforms, MemoryPoolAllocator
must match the malloc() behavior and return a 8 byte aligned allocation.
This eliminates any alignment issues that may occur at the expense of
additional memory overhead.

Failure to do so caused a SIGBUS signal when calling
GenericValue::SetNull(). The size of the data_ member of the
GenericValue class is 16 bytes in 32-bit mode and its constructor
requires an 8-byte aligned access.

While parsing a JSON formatted string using Document::ParseStream(), a
stack object containing GenericValue items was constructed. Since the
stack was 8-byte aligned, the constructor calls would succeed. When the
lifetime of the object ends, SetObjectRaw() is invoked. This triggered
an allocation with 4-byte alignment to which the previously 8-byte
aligned GenericValue array was copied. After this, any call to a
GenericValue API that triggered the constructor and thus the placement
new operation on the Data type member would trigger a SIGBUS.

Signed-off-by: Veselin Georgiev <veselin.georgiev@garmin.com>
Signed-off-by: Joshua Watt <Joshua.Watt@garmin.com>
2018-07-31 09:02:26 -05:00
Minmin Gong
ff76343336 Update the code to adapt the new gtest. 2018-07-16 20:36:20 -07:00
Philipp A Hartmann
a26267d16d Fix -Wsign-conversion warnings/errors
GCC 8 (incorrectly) warns about sign conversions in (constant)
array size expressions:

error: conversion to 'long unsigned int' from 'int' may
change the sign of the result [-Werror=sign-conversion]
     char schemaBuffer_[128 * 1024];

Make these expressions unsigned by adding a 'u' suffix to
the first operands.
2018-07-15 16:01:02 +02:00
Christopher Warrington
960b9cfd19 Guard against min/max being macros in reader.h
Sometimes, particularly when Microsoft's windows.h is included, min/max
are defined as macros, interfering with use of
std::numeric_limits::min() and the like.

To guard against this, the function name is wrapped in an extra set of
parenthesis, which inhibits function-style macro expansion.

This is a similar commit to 6e38649ec6, but fixes uses of
std::numeric_limits added after that commit, like those introduced in
2ea43433e2.
2018-07-10 11:08:41 -07:00
Milo Yip
7e68aa0a21
Merge pull request #1252 from StilesCrisis/issue-1251-test
Unit Test: Parsing "128.74836467836484838364836483643636483648e-336" causes a crash
2018-06-19 12:43:54 +08:00
Milo Yip
c511ce303f
Merge pull request #1250 from StilesCrisis/issue-1249-test
Unit Test: Parsing "0e100" in full precision mode causes UB
2018-06-18 23:54:53 +08:00
abolz
7101911d9b Run all the new tests in full-precision mode only
until I know what the normal-precision algorithm really does...
2018-06-16 15:23:44 +02:00
abolz
319944a11a Disable failing test for now 2018-06-16 14:55:07 +02:00
abolz
a757a2aeb8 Add more tests
Some more need to be fixed.
2018-06-16 14:31:48 +02:00
abolz
179277817d Add a test for BigInteger::operator<< 2018-06-16 13:48:33 +02:00
abolz
a0f9c5fc46 [Debug - clean up] 2018-06-16 12:32:17 +02:00
abolz
8b98f4a782 Workaround incorrect rounding in MSVC 2018-06-16 09:40:40 +02:00
abolz
292f787c04 [Debug] 2018-06-15 15:10:50 +02:00
abolz
a78c8e3a4f Add more tests (which need to be fixed) 2018-06-15 12:59:39 +02:00
abolz
7acbb87c2b Some more tests 2018-06-15 11:39:45 +02:00
abolz
4e9b4f6d6a Return 0 if binary exponent is too small 2018-06-15 11:32:32 +02:00
abolz
80dba56aca Add tests for issues with string-to-double conversions (#849, #1249, #1251, #1253, #1256, #1259) 2018-06-15 10:15:45 +02:00
bogaotory
6f7dcb30d9 again, in relation to solving issue #784, use SizeType-typed variable to indicate a none-zero length string has been given in the schema as default value for the json property; added an unittest Object_Required_PassWithDefault 2018-06-01 21:16:26 +01:00
Florin Malita
8269bc2bc2 Prevent int underflow when parsing exponents
When parsing negative exponents, the current implementation takes
precautions for |exp| to not underflow int.

But that is not sufficient: later on [1], |exp + expFrac| is also
stored to an int - so we must ensure that the sum stays within int
representable values.

Update the exp clamping logic to take expFrac into account.

[1] https://github.com/Tencent/rapidjson/blob/master/include/rapidjson/reader.h#L1690
2018-05-15 22:48:07 -04:00
John Stiles
1329cdecce Added test for issue #1251 2018-05-11 15:57:11 -07:00
John Stiles
cad3805737
Update readertest.cpp 2018-05-11 15:19:11 -07:00
John Stiles
f7d2cd2228 added test for parsing 0e100 2018-05-11 15:16:46 -07:00
Zoltan Kovago
0fdd8040ce fix compilation on windows with clang 2018-04-09 15:47:17 +02:00
Christian Semmler
9640209f78 remove superfluous typename 2018-03-26 13:29:52 +02:00
Christian Semmler
f8c8c32b42 fix C++03 compatibility 2018-03-26 13:16:31 +02:00
Christian Semmler
c8530d022f add test case for remote ref issue 2018-03-26 13:04:35 +02:00
MaximeBF
27424d5c09 Change long/ulong as int/uint on MSC unit tests to be more inline with other templated functions unit tests 2018-03-14 08:44:00 -04:00
MaximeBF
a37f9d1ecd Fix unsigned long as unsigned unit test 2018-03-08 07:33:26 -05:00
MaximeBF
a040fc3347 Add unittest for long as int in MSC platforms 2018-03-08 07:28:51 -05:00
Milo Yip
966987625c Add transcoding/validation to Writer::RawValue()
Fix #1152
2018-02-13 10:58:41 +08:00
Milo Yip
daabb88e00
Merge pull request #1068 from yurikhan/violationDetails
Schema violation details
2018-01-26 11:26:27 +08:00
Milo Yip
7641af690e
Merge pull request #1122 from svart-riddare/issue-1108
Suggestion for issue #1108
2018-01-26 10:59:11 +08:00
Milo Yip
b1e556d713
Merge branch 'master' into violationDetails 2018-01-13 22:34:58 +08:00