fix typo & add negative test case for test_equal_complex
This commit is contained in:
parent
672b6df474
commit
010092c7bd
@ -159,7 +159,7 @@ static void test_equal_object()
|
|||||||
|
|
||||||
static void test_equal_complex()
|
static void test_equal_complex()
|
||||||
{
|
{
|
||||||
json_t *value1, *value2;
|
json_t *value1, *value2, *value3;
|
||||||
|
|
||||||
const char *complex_json =
|
const char *complex_json =
|
||||||
"{"
|
"{"
|
||||||
@ -176,15 +176,25 @@ static void test_equal_complex()
|
|||||||
|
|
||||||
value1 = json_loads(complex_json, 0, NULL);
|
value1 = json_loads(complex_json, 0, NULL);
|
||||||
value2 = json_loads(complex_json, 0, NULL);
|
value2 = json_loads(complex_json, 0, NULL);
|
||||||
|
value3 = json_loads(complex_json, 0, NULL);
|
||||||
if(!value1 || !value2)
|
if(!value1 || !value2)
|
||||||
fail("unable to parse JSON");
|
fail("unable to parse JSON");
|
||||||
if(!json_equal(value1, value2))
|
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(value1);
|
||||||
json_decref(value2);
|
json_decref(value2);
|
||||||
|
json_decref(value3);
|
||||||
/* TODO: There's no negative test case here */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_tests()
|
static void run_tests()
|
||||||
|
Loading…
Reference in New Issue
Block a user