Commit Graph

131 Commits

Author SHA1 Message Date
Eric Haszlakiewicz
4a94ddbd8b Merge pull request #500 from andy5995/add_missing_test_deps
test/Makefile.am:add missing deps for test1 and test2
2019-07-26 09:48:34 -04:00
Eric Haszlakiewicz
68abf12afa Issue #498: Fix a memory leak bug introduced in test_double_serializer in 485f2a02 by adding a json_object_put call. 2019-07-26 03:35:38 +00:00
andy5995
8ab8df1170 test/Makefile.am:add missing deps for test1 and test2
Allows the tests to pass when running `make distcheck`

This fixes the 2 broken tests I mentioned at
https://github.com/json-c/json-c/pull/499#discussion_r306998261
2019-07-25 14:59:56 -05:00
Pierce Lopez
634900d270 tests: appease -Wwrite-strings 2019-06-09 12:17:06 -04:00
Eric Haszlakiewicz
485f2a02c7 Issue #486: append a missing ".0" to negative double values too. 2019-05-28 02:44:22 +00:00
Darjan Krijan
7a9075c16b Added test cases for spaced pretty and pretty_tab used together 2018-12-07 17:30:15 +01:00
janczer
8bd62177e7 Fixed typos 2018-04-24 16:00:38 +02:00
Eric Haszlakiewicz
da4b34355d Add an parse test for content starting with a UTF8 BOM, which is _not_ a valid start to a JSON message. 2018-03-25 18:23:42 -04:00
Eric Haszlakiewicz
d5da847f51 PR#394: don't always append the ".0" if the double value rounds to zero because some custom formats *will* include it (e.g. %.2f).
Also try to accomodate formats to explicitly exclude the decimal (e.g. %.0f).
2017-12-24 13:45:52 -05:00
Eric Haszlakiewicz
0992aac61f Remove the TRUE and FALSE defines. 2017-12-23 09:42:17 -05:00
Eric Haszlakiewicz
11ab365324 Deprecated a few typedefs, add docs on json_object_iter, move json_number_chars and json_hex-chars to json_object_private.h. 2017-12-05 09:20:59 -05:00
Eric Haszlakiewicz
a47eafe868 Cast to int64_t instead of long in test_int_add to fix the test on 32-bit platforms. 2017-12-05 04:32:12 +00:00
Eric Haszlakiewicz
e00a07b885 Clean up *.vg.out files too to "make distcheck" works. 2017-11-30 18:17:04 -05:00
Eric Haszlakiewicz
5dae561d33 In json_object_deep_copy(), copy over _userdata, at least for json_type_string's with the default serializer set, and provide a way for people using custom serializers to provide a custom shallow_copy method. 2017-11-29 23:35:38 -05:00
Eric Haszlakiewicz
96efeadd6e Always build the json_object_deep_copy() code, but conditionalize running it on a --benchmark command line option. 2017-11-29 17:58:57 -05:00
Eric Haszlakiewicz
4dd92180c6 Merge branch 'json_deep_copy' of https://github.com/commodo/json-c into commodo-json_deep_copy 2017-11-29 09:12:59 -05:00
Eric Haszlakiewicz
3628f16dd6 Rename json_object_add_int() to json_object_int_inc() and eliminate the "int64" variant since we store 64-bit values internally anyway. 2017-11-27 17:57:36 -05:00
Alexandru Ardelean
1eab22f0da tests: add test_deep_copy test
Seems to perform better than outputting to string
and re-parsing it.

BENCHMARK - 1000000 iterations of 'dst2 = json_tokener_parse(json_object_get_string(src2))' took 20 seconds
BENCHMARK - 1000000 iterations of 'dst2 = json_tokener_parse(json_object_get_string(src2))' took 7 seconds

It should make a difference on embedded systems.
The test was performed on a i5 desktop CPU [~3.5 years of age].

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2017-11-27 16:17:48 +02:00
Eric Haszlakiewicz
91662a5b69 Merge pull request #363 from jvijtiuk/integer_addition
Issue #338, add json_object_add_int functions
2017-11-27 09:06:39 -05:00
Eric Haszlakiewicz
9c9529f798 Update test_parse.expected to match the code. 2017-11-27 08:48:08 -05:00
Eric Haszlakiewicz
31a6c2fac8 Add a few more tests to the partial parse to cover bytes after "Infinity". 2017-11-27 00:18:55 -05:00
Eric Haszlakiewicz
ba11d334db Save proper expected output for test_parse from the previous commit. 2017-11-27 00:08:59 -05:00
Eric Haszlakiewicz
48f7e389fb Fix parsing of "-Infinity" when the "-" and "Infinity" are split across multiple calls.
Add several additional test cases for partial parsing of infinity values.
2017-11-27 00:04:33 -05:00
Eric Haszlakiewicz
4d1e0b4409 Issue #371: fix parsing of "-Infinity" (although in a somewhat different location than PR#372 used), and add a case to test_parse to check for this. 2017-11-26 22:44:39 -05:00
Eric Haszlakiewicz
2a22858fe7 Add a few extra cases to test_parse to show how trailing bytes are handled, especially for parsing "Infinity". 2017-11-26 22:34:43 -05:00
Eric Haszlakiewicz
b8738dd623 Rewrite test_basic_parse() to factor out a single_basic_parse() to avoid lots of duplicate boiler plate code.
Also, emit the input string in the output so it's easier to see what's going on.
2017-11-26 22:33:36 -05:00
Eric Haszlakiewicz
e424af32b7 Fix definition of NELEM in the tests. 2017-10-22 22:28:35 -04:00
Juraj Vijtiuk
1110e84cce Add json_object_add_int functions 2017-09-14 09:36:12 -04:00
Eric Haszlakiewicz
81f6edbfd5 PR#331: for Visual Studio, use a snprintf/vsnprintf wrapper that ensures the string is terminated. 2017-08-25 01:15:39 -04:00
Eric Haszlakiewicz
fcad0ec015 PR #336: since we can't use function overriding (due to problems with it on
OSX) always include the _json_c_strerror function but only enable it with a flag
 during tests.
2017-07-15 07:12:44 -07:00
Eric Haszlakiewicz
40317f079e Allow USE_VALGRIND to be set to anything starting with 0, N or n to disable valgrind during tests. 2017-07-15 07:03:18 -07:00
Alexandru Ardelean
fb72160caf build: make strerror() override-able
If we want to override `strerror()` in libjson-c
to make tests consistent across platforms, we
need to do it build-wide as configure/build
option.

Apple linkers make it really hard to override functions
at link-time, and this seems to be locked down on travis-ci.org
[ for security reasons I assume ].
While I got it to work locally, it did not work
when running on travis.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2017-07-13 10:27:24 +03:00
Alexandru Ardelean
7b9432d564 tests: fix leak in test_util_file ; found by cppcheck
Which now seems to fail the build.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2017-07-13 09:05:13 +03:00
Alexandru Ardelean
9d47ae824c tests: compress test_utile_file with test_basic
More code compression/de-duplication.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2017-07-11 10:38:25 +03:00
Eric Haszlakiewicz
33db761551 Updated expected test1 output which should have been included in commit fd9b3b2. 2017-07-09 15:22:53 -07:00
Eric Haszlakiewicz
fd9b3b2260 Issue #332: fix a long-standing bug in array_list_put_idx() where it would attempt to free previously free'd entries due to not checking the current array length.
Add a test that triggers the problem to ensure it stays fixed.
2017-07-08 19:04:35 -07:00
Alexandru Ardelean
73636c2ed0 tests: symlink basic tests to a single file that has the common code
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2017-06-22 10:08:26 +03:00
Eric Haszlakiewicz
e8e574fbe4 Issue #161: add a json_object_to_fd() function. 2017-06-18 18:44:45 +00:00
Eric Haszlakiewicz
23e064ad29 Fix test_double_serializer expected output. 2017-06-18 18:34:41 +00:00
Eric Haszlakiewicz
1a94c70336 Add a json_c_set_serialization_double_format() function to set the *library-wide* format for how doubles are written to a serialized JSON output. 2017-06-18 18:12:07 +00:00
Eric Haszlakiewicz
8c86207258 Add a few more cases to test_parse to provide some examples of how parsing works; should help address the questions raised in Issue #302. 2017-02-26 16:22:45 +00:00
Eric Haszlakiewicz
3948fcad2d Issue #300: Cast size_t values to int instead of unsigned long long to work around broken behavior of MinGW. 2017-02-05 17:00:35 +00:00
Eric Haszlakiewicz
bad6c9a427 Issue #300: Some platforms, such as MinGW, don't have ETXTBSY and ENOTBLK, so skip those there. 2017-02-05 04:44:30 +00:00
Eric Haszlakiewicz
9a64fd7d55 Issue #300: Use %p instead of %lx in test_util_file since some platforms' pointers are larger than "unsigned long".
Also, there's no need to worry about output consistency here, since it'll be
 different anyway due to different pointer values.
2017-02-05 04:38:53 +00:00
Eric Haszlakiewicz
3fab117e4e Merge pull request #299 from qlyoung/perf-improvements
Improve json_object -> string performance
2017-02-04 11:13:14 -05:00
Quentin Young
f6f852fd93 Restore sprintbuf(), add macro for string literals
Hawciz pointed out that the previous commit modifies the public
interface of printbuf. Per his suggestion, sprintbuf() was restored
and a new pair of macros was added that wraps printbuf_memappend().

Using a wrapper macro instead of modifying sprintbuf() also reduces
function call overhead, bringing total performance gains to
approximately 400%.
2017-02-04 01:02:00 +00:00
Eric Haszlakiewicz
75825a9f01 Use strdup instead of strndup in test1.c, there's no need for the latter because json_object_to_json_string_length() will always return a properly sized string. 2017-02-03 17:10:27 +00:00
Quentin Young
9ff0f4987f Improve json_object -> string performance
Removes variadic prints for ~3x performance improvement.
2017-02-02 17:33:54 +00:00
Eric Haszlakiewicz
0a010a59eb Change a memcpy that should be a memmove within json_pointer_get, and fix memory leaks in of one the json_pointer tests. 2016-12-18 14:33:41 -05:00
Jan Gerhards
61db4cfac5 testbench: add test for floating point representation 2016-11-27 11:50:48 +01:00