diff options
author | Corey Farrell <git@cfware.com> | 2018-02-13 04:35:37 -0500 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2018-02-15 10:12:31 -0500 |
commit | 73c22de51672cb40fdc29c95331923d4dcebb6fa (patch) | |
tree | cc7dae71f9f2fff1c0066adf12b3def6337c2e56 /test/suites/api/test_equal.c | |
parent | 6dddf687d84306ea5d4ff9b13a28dc22282c77e6 (diff) | |
download | jansson-73c22de51672cb40fdc29c95331923d4dcebb6fa.zip jansson-73c22de51672cb40fdc29c95331923d4dcebb6fa.tar.gz jansson-73c22de51672cb40fdc29c95331923d4dcebb6fa.tar.bz2 |
Improve test coverage.
* Test equality of different length strings.
* Add tab to json_pack whitespace test.
* Test json_sprintf with empty result and invalid UTF.
* Test json_get_alloc_funcs with NULL arguments.
* Test invalid arguments.
* Add test_chaos to test allocation failure code paths.
* Remove redundant json_is_string checks from json_string_equal and
json_string_copy. Both functions are static and can only be called
with a json string.
Fixes to issues found by test_chaos:
* Fix crash on OOM in pack_unpack.c:read_string().
* Unconditionally free string in string_create upon allocation failure.
Update load.c:parse_value() to reflect this. This resolves a leak on
allocation failure for pack_unpack.c:pack_string() and
value.c:json_sprintf().
Although not visible from CodeCoverage these changes significantly
increase branch coverage. Especially in src/value.c where we previously
covered 67.4% of branches and now cover 96.3% of branches.
Diffstat (limited to 'test/suites/api/test_equal.c')
-rw-r--r-- | test/suites/api/test_equal.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/suites/api/test_equal.c b/test/suites/api/test_equal.c index 7a17636..339bab6 100644 --- a/test/suites/api/test_equal.c +++ b/test/suites/api/test_equal.c @@ -74,6 +74,13 @@ static void test_equal_simple() fail("unable to create an string"); if(json_equal(value1, value2)) fail("json_equal fails for two inequal strings"); + json_decref(value2); + + value2 = json_string("bar2"); + if(!value2) + fail("unable to create an string"); + if(json_equal(value1, value2)) + fail("json_equal fails for two inequal length strings"); json_decref(value1); json_decref(value2); |