aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Zhukov <mussitantesmortem@gmail.com>2021-11-20 22:57:10 +0300
committerMaxim Zhukov <mussitantesmortem@gmail.com>2021-11-20 22:57:10 +0300
commit586b4461e6317f93903ec034739a14955a10a33e (patch)
treec2ccd46a85933d8a18c153de404cccbbe5b31044
parent78418c84f1621c9a919c480d1e400f0fe4d1eca1 (diff)
downloadjansson-586b4461e6317f93903ec034739a14955a10a33e.zip
jansson-586b4461e6317f93903ec034739a14955a10a33e.tar.gz
jansson-586b4461e6317f93903ec034739a14955a10a33e.tar.bz2
tests: add some cases in fixed size test
Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
-rw-r--r--test/suites/api/test_fixed_size.c23
1 files changed, 23 insertions, 0 deletions
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);
}