From 586b4461e6317f93903ec034739a14955a10a33e Mon Sep 17 00:00:00 2001 From: Maxim Zhukov Date: Sat, 20 Nov 2021 22:57:10 +0300 Subject: [PATCH] tests: add some cases in fixed size test Signed-off-by: Maxim Zhukov --- test/suites/api/test_fixed_size.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/suites/api/test_fixed_size.c b/test/suites/api/test_fixed_size.c index e4495ee..4ae9e07 100644 --- a/test/suites/api/test_fixed_size.c +++ b/test/suites/api/test_fixed_size.c @@ -127,6 +127,7 @@ static void test_keylen(void) { static void test_invalid_keylen(void) { json_t *obj = json_object(); + json_t *empty_obj = json_object(); const char key[] = {'t', 'e', 's', 't', '1'}; json_object_set_new_nocheck(obj, "test1", json_true()); @@ -149,7 +150,14 @@ static void test_invalid_keylen(void) { if (!json_object_del(obj, NULL)) fail("json_object_del with NULL failed"); + if (!json_object_deln(empty_obj, key, sizeof(key))) + fail("json_object_deln with empty object failed"); + + if (!json_object_deln(obj, key, sizeof(key) - 1)) + fail("json_object_deln with incomplete key failed"); + json_decref(obj); + json_decref(empty_obj); } static void test_binary_keys(void) { @@ -166,6 +174,21 @@ static void test_binary_keys(void) { if (!json_is_true(json_object_getn(obj, (const char *)&key1, sizeof(key2)))) fail("cannot get integer key2"); + if (json_object_size(obj) != 2) + fail("binary object size missmatch"); + + if (json_object_deln(obj, (const char *)&key1, sizeof(key1))) + fail("cannot del integer key1"); + + if (json_object_size(obj) != 1) + fail("binary object size missmatch"); + + if (json_object_deln(obj, (const char *)&key2, sizeof(key2))) + fail("cannot del integer key2"); + + if (json_object_size(obj) != 0) + fail("binary object size missmatch"); + json_decref(obj); }