Commit Graph

104 Commits

Author SHA1 Message Date
Eric Haszlakiewicz
e424af32b7 Fix definition of NELEM in the tests. 2017-10-22 22:28:35 -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
Jan Gerhards
ca7a1973e2 bugfix: floating point representaion without fractional part
closes https://github.com/json-c/json-c/issues/278
2016-11-27 11:47:00 +01:00
Alexandru Ardelean
c0da680f13 test_json_pointer: update test with a few printf variants
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2016-11-22 16:37:18 +02:00
Alexandru Ardelean
ee7fc26de1 tests: add test_json_pointer test
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2016-11-04 09:59:43 +02:00
Alexandru Ardelean
2fbdee19da tests/strerror_override.c: fix compilation error
I got this on Mac OS X at least.
Not sure if it shows up in other envs

error:
```
strerror_override.c:53:13: error: incompatible redeclaration of library function 'strerror' [-Werror,-Wincompatible-library-redeclaration]
const char *strerror(int errno_in)
```

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2016-11-04 09:51:44 +02:00
Eric Haszlakiewicz
33339ae595 Use json_visit() to clear the serializer data set when parsing so the output from test_parse reflects the actual values parsed. 2016-10-29 15:13:16 -04:00
Eric Haszlakiewicz
ecdc14f535 Add a json_c_visit() function to provide a way to iterate over a tree of json-c objects. 2016-10-29 15:01:20 -04:00
Eric Haszlakiewicz
7e12b9f47c Fix broken key-order test in test_compare. 2016-10-10 00:13:39 -04:00
Eric Haszlakiewicz
818156f6f7 Merge pull request #277 from ALLTERCO/json_object_set_xxx
Json object set xxx
2016-10-08 12:08:53 -04:00
Stoian Ivanov
e518b22b72 string set and tests 2016-10-07 00:51:24 +03:00
Stoian Ivanov
9a313f767f gitignore test; add double value set checks in test 2016-10-06 23:32:19 +03:00
Stoian Ivanov
6a0667567d some simple tests 2016-10-06 23:16:29 +03:00
Eric Haszlakiewicz
36a28fcb0c Issue #275: fix out of bounds read when handling unicode surrogate pairs. 2016-10-05 23:15:51 -04:00
Eric Haszlakiewicz
0fcf1d1ae7 Fix memory leak and inconsistent output (due to varying fd numbers) in test_util_file. 2016-08-20 23:06:22 -04:00
Eric Haszlakiewicz
5fccfed4f4 Issue #260: add a check to prevent trivial loops in the object tree, even though it is up to the callers to avoid doing so in more complex cases. 2016-08-20 22:42:59 -04:00
Eric Haszlakiewicz
61cd433131 Merge branch 'tests' of https://github.com/RyDroid/json-c into RyDroid-tests
Conflicts:
	tests/test_util_file.c
2016-08-13 09:17:01 -04:00
Nicola Spanti (RyDroid)
8215c0ac0e Very minor changes to some tests 2016-08-13 00:53:33 +02:00
Eric Haszlakiewicz
f3db59d990 Merge branch 'issue-165' of https://github.com/jobol/json-c into jobol-issue-165
Conflicts:
	tests/test_util_file.c
2016-08-09 07:36:54 -04:00
Nicola Spanti (RyDroid)
36b4003118 Adding a test with cppcheck for Travis CI 2016-08-08 15:23:27 +02:00
Eric Haszlakiewicz
9688f343a5 Issue #246: Include xlocale.h too, to get locale_t defined, since not all OSes include that in locale.h 2016-08-02 22:25:05 -04:00
José Bollo
1fceb2207a test: add test of 'json_object_to_json_string_length'
The test is implied in test1.

The idea is to check that the returned lengths and strings
are identical to what is expected to return the already
tested function 'json_object_to_json_string_ext'.

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-08-01 15:04:54 +02:00
Eric Haszlakiewicz
fa76e4a8c9 Issue #195: Actually call uselocale() in the new locale handling code in json_tokener.
Also, be sure the right locale_t is freed if we fail on the second uselocale.
Finally, fix test_locale so it *doesn't* use json_object_to_json_string as
 that will simple re-emit the original parsed string values.
2016-07-31 14:43:14 -04:00
Eric Haszlakiewicz
4091b9c87e Issue #195: use uselocale() instead of setlocale() in json_tokener to behave better in threaded environments. 2016-07-30 21:34:58 -04:00
Eric Haszlakiewicz
7d637362b7 Linux's %p format doesn't return "0x0" for NULL pointers, so switch to using %lx for consistency. 2016-07-30 15:09:51 -04:00
Eric Haszlakiewicz
deb9fa482d Issue #240: add arbitrary use of val's in foreach loops to squash warnings about unused variables. 2016-07-30 18:27:53 +00:00
José Bollo
54ae254537 Fix a compiling error
The function fstat isn't declared without this include
on debian strect/sid and Fedora-23

Change-Id: I660a32ff173dcba04674aed51ed855b4fa55ac67
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-07-27 14:42:25 +02:00
Eric Haszlakiewicz
2b255d0ebf Fix absolute paths in test_util_file that vary depending on where it is run. 2016-06-27 04:30:10 +00:00
Eric Haszlakiewicz
1071385896 Issue #113: add "new" files to appropriate variables in Makefile, and note the need to run "make distcheck" as part of the release process.
Fix issues with the test script so it works under distcheck too.
2016-06-27 04:15:30 +00:00