diff options
author | allen <leloucharcher@163.com> | 2019-10-15 17:13:12 +0800 |
---|---|---|
committer | allen <leloucharcher@163.com> | 2019-10-15 17:41:57 +0800 |
commit | 010092c7bd21aabaea5d37162b30f526d46c25c4 (patch) | |
tree | daf290b0046772c2a437c6f78583311ecfc9e277 /test/suites/api | |
parent | 672b6df4743dbf76e059c640ad3fe45f7c795594 (diff) | |
download | jansson-010092c7bd21aabaea5d37162b30f526d46c25c4.zip jansson-010092c7bd21aabaea5d37162b30f526d46c25c4.tar.gz jansson-010092c7bd21aabaea5d37162b30f526d46c25c4.tar.bz2 |
fix typo & add negative test case for test_equal_complex
Diffstat (limited to 'test/suites/api')
-rw-r--r-- | test/suites/api/test_equal.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/test/suites/api/test_equal.c b/test/suites/api/test_equal.c index 339bab6..ed1023f 100644 --- a/test/suites/api/test_equal.c +++ b/test/suites/api/test_equal.c @@ -159,7 +159,7 @@ static void test_equal_object() static void test_equal_complex() { - json_t *value1, *value2; + json_t *value1, *value2, *value3; const char *complex_json = "{" @@ -176,15 +176,25 @@ static void test_equal_complex() value1 = json_loads(complex_json, 0, NULL); value2 = json_loads(complex_json, 0, NULL); + value3 = json_loads(complex_json, 0, NULL); if(!value1 || !value2) fail("unable to parse JSON"); if(!json_equal(value1, value2)) - fail("json_equal fails for two inequal strings"); + fail("json_equal fails for two equal objects"); + + json_array_set_new(json_object_get(json_object_get(value2, "object"), + "array-in-object"), 1, json_false()); + if(json_equal(value1, value2)) + fail("json_equal fails for two inequal objects"); + + json_object_set_new(json_object_get(json_object_get(value3, "object"), + "object-in-object"), "foo", json_string("baz")); + if(json_equal(value1, value3)) + fail("json_equal fails for two inequal objects"); json_decref(value1); json_decref(value2); - - /* TODO: There's no negative test case here */ + json_decref(value3); } static void run_tests() |