26 Commits

Author SHA1 Message Date
Tero Kinnunen
2d55c7445f
Parse large floats as infinity (#1349) (#1353)
Return 1.9.1 functionality where values too large to fit in
double are converted to positive or negative infinity.

Commit 645cd04 changed functionality so that large floats cause
parse error, while version 1.9.1 accepted them as infinite.
This is problematic because writer outputs infinity values
as `1e+9999`, which could no longer be parsed back.

Fixed also legacy Reader even though it did not parse large values
even before breaking change, due to problematic output/parse asymmetry.

`>>` operator sets value to numeric_limits::max/lowest value if
representation is too large to fit to double. [1][2] In macos
value appears to be parsed to infinity.

> | value in *val*           | description |
> |--------------------------|-------------|
> | numeric_limits::max()    | The sequence represents a value too large for the type of val |
> | numeric_limits::lowest() | The sequence represents a value too large negative for the type of val |

[1] https://www.cplusplus.com/reference/istream/istream/operator%3E%3E/
[2] https://www.cplusplus.com/reference/locale/num_get/get/

Signed-off-by: Tero Kinnunen <tero.kinnunen@vaisala.com>

Co-authored-by: Tero Kinnunen <tero.kinnunen@vaisala.com>
2021-12-14 18:00:28 -08:00
Christopher Dunn
be4a512887
Remove trailing space characters (#1256)
Also add two newlines

(rebased from `aaronfranke/formatting`)

resolves #1220

Co-authored-by: Aaron Franke <arnfranke@yahoo.com>
2021-01-09 22:39:07 -06:00
Jordan Bayles
9be5895985
Issue 1182: Fix fuzzing bug (#1183)
This patch fixes a fuzzing bug by resolving a bad fallthrough in the
setComment logic.

The result is that we get a proper error instead of an assert, making
the library friendlier to use and less likely to cause issue for
consumers.

See related Chromium project bug:
https://bugs.chromium.org/p/chromium/issues/detail?id=989851

Issue: 1182
2020-05-30 20:20:20 -07:00
Jacob Bundgaard
554d961625 Allow trailing comma in arrays if dropped null placeholders are not allowed 2019-11-14 00:05:24 -06:00
Jacob Bundgaard
01db7b7430 Allow trailing comma in objects 2019-11-14 00:05:24 -06:00
Jordan Bayles
645cd0412c Number fixes (#1053)
* cleaning up the logic for parsing numbers

* Add Testcases for new Reader in jsontestrunner
2019-11-09 11:49:16 +08:00
Kirill V. Lyadvinsky
ac372d2b00 Added stack overflow test 2016-11-02 15:33:57 +03:00
Christopher Dunn
8d15e51228 add test_comment_00
one-element array with comment, for issue #103
2015-01-23 14:28:21 -06:00
Christopher Dunn
c407f1407f test-data for #103
passes
2015-01-20 15:16:46 -06:00
Christopher Dunn
37644abd77 test comment before several types
* array
* double
* string
* true
* false
* null
2015-01-20 12:23:18 -06:00
Christopher Dunn
94b0297dc5 Revert "consider these as binary, so git will not alter line-endings"
This reverts commit 8f3aa220dbab931bfd5a32bdb7d7e77c785c1796.

We will find a better fix for #116. In the meantime, we want to see
diffs for changes to test-data.
2015-01-20 12:06:12 -06:00
Christopher Dunn
8f3aa220db consider these as binary, so git will not alter line-endings
issue #116
2015-01-16 16:29:07 -06:00
Cory Quammen
fd06bfca79 Removed unneeded newlines from parsed comments
Newlines from comments separated by lines are retained when comments
are appended, so adding a newline between separate comments for a
node is not needed.
2014-10-09 16:33:29 -04:00
Cory Quammen
4d23492d11 Added printing of comments to *.actual test files
This enables testing of comment-handling code. Updated *.expected test
result files to account for printing of comments.
2014-10-09 16:33:29 -04:00
Christopher Dunn
09439b7bc7 Comment reading/write improvements
This patch fixes some aspects of reading and writing comments:
- Multiple C++-style comments before a Json value had extra newlines appended to them. This patch removes the addition of those newlines.
- Comments written before Json values in the StyledWriter were not indented to match the indentation level of the value. This patch adds indentation to comments.
- Fixed inconsistency in newlines following C- and C++-style comments being saved as part of the comment. All newlines at the end of a comment are now removed.
- Added an additional test of comments.

https://sourceforge.net/p/jsoncpp/patches/25/
2014-04-19 21:19:24 +00:00
Christopher Dunn
468564b3fe More eol changes. 2011-06-21 21:53:02 +00:00
Aaron Jacobs
4b819c2309 Added a few test cases that Google is using internally for patches made
in the past.
2011-05-26 06:58:14 +00:00
Aaron Jacobs
ae9ffb5443 Fixed a parsing bug in decodeNumber, updating the failing test cases to be
correct in the process. (The test cases incorrectly used exact integers instead
of scientific notation.)
2011-05-24 03:59:24 +00:00
Aaron Jacobs
e656c5fa2d Added some test cases that catch a parsing bug. 2011-05-24 03:19:50 +00:00
Baptiste Lepilleur
9c98f2277b Fixed bug #3139677: JSON [1 2 3] was incorrectly parsed as [1, 3]. Error is now correctly detected.
Modified runjsontests.py to allow test that expect failure in jsoncpp test suite.
2011-05-01 15:40:47 +00:00
Baptiste Lepilleur
402c13eb3d - added unit test and roadmap for handling of escape sequence "\/" 2010-04-27 16:37:50 +00:00
Baptiste Lepilleur
201fb2cf0d - Moved definition of Json::Int and Json::UInt to config.h which compiler detection logic to define them to 64 bits integer if JSON_NO_INT64 is not defined.
- Added Json::ArrayIndex as an unsigned int to forwards.h
- Modified Json::Value to consistently use Json::ArrayIndex.
- Added int/unsigned int constructor overload to Json::Value to avoid ambiguous constructor call.
- Modified jsontestrunner/main.cpp to use Json::valueToString for Value::asInt() conversion to string.
- Modified Json::Reader to only overflow to double when the number is too large (previous code relied on the fact that an int fitted in a double without precision loss).
- Generalized uintToString() helpers and buffer size to automatically adapt to the precision of Json::UInt.
- Added specific conversion logic for UInt to double conversion on Microsoft Visual Studio 6 which only support __int64 to double conversion (unsigned __int64 conversion is not supported)
- Added test for 64 bits parsing/writing. Notes: those will fail when compiled with JSON_NO_INT64 (more dev required to adapt).
2010-04-19 07:37:41 +00:00
Baptiste Lepilleur
7a866553bb - added a large test that cause(d?) crash with experimental JSON_VALUE_USE_INTERNAL_MAP 2010-02-21 10:44:12 +00:00
Baptiste Lepilleur
a894f775bb - fixed failing test 2010-02-19 05:09:54 +00:00
Baptiste Lepilleur
2bcfb63362 Added another failing unicode test case 2009-11-26 10:52:18 +00:00
Baptiste Lepilleur
7dec64f57e Moved jsontestrunner data from test/ to test/data. 2009-11-21 18:20:25 +00:00