projects
/
jansson.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Better argument validation
[jansson.git]
/
test
/
testprogs
/
test_object.c
diff --git
a/test/testprogs/test_object.c
b/test/testprogs/test_object.c
index
f9839c7
..
540109e
100644
(file)
--- a/
test/testprogs/test_object.c
+++ b/
test/testprogs/test_object.c
@@
-29,6
+29,12
@@
int main()
if(json_object_set(object, "a", string))
fail("unable to set value");
if(json_object_set(object, "a", string))
fail("unable to set value");
+ if(!json_object_set(object, NULL, string))
+ fail("able to set NULL key");
+
+ if(!json_object_set(object, "a", NULL))
+ fail("able to set NULL value");
+
iter = json_object_iter(object);
if(!iter)
fail("unable to get iterator");
iter = json_object_iter(object);
if(!iter)
fail("unable to get iterator");
@@
-105,11
+111,19
@@
int main()
fail("unable to set value");
fail("unable to set value");
- json_object_set_new(object, "foo", json_integer(123));
+ if(json_object_set_new(object, "foo", json_integer(123)))
+ fail("unable to set new value");
+
value = json_object_get(object, "foo");
if(!json_is_integer(value) || json_integer_value(value) != 123)
fail("json_object_set_new works incorrectly");
value = json_object_get(object, "foo");
if(!json_is_integer(value) || json_integer_value(value) != 123)
fail("json_object_set_new works incorrectly");
+ if(!json_object_set_new(object, NULL, json_integer(432)))
+ fail("able to set_new NULL key");
+
+ if(!json_object_set_new(object, "foo", NULL))
+ fail("able to set_new NULL value");
+
json_decref(string);
json_decref(other_string);
json_decref(object);
json_decref(string);
json_decref(other_string);
json_decref(object);