Issue #189: Eliminate use of MC_ERROR from json_util.c, and add a json_util_get_last_err() function to retrieve the error for those callers that care about it.

Add tests and descriptions for the functions in json_util.c
This commit is contained in:
Eric Haszlakiewicz
2016-06-26 02:20:05 +00:00
parent 595891729e
commit 29ef73f21d
9 changed files with 351 additions and 16 deletions

View File

@@ -0,0 +1,21 @@
OK: json_object_from_fd(/home/erh/json-c/json-c/tests/valid.json)={ "foo": 123 }
OK: json_object_from_file(not_present.json) correctly returned NULL: json_object_from_file: error opening file /home/erh/json-c/json-c/tests/not_present.json: ERRNO=ENOENT
OK: json_object_from_fd(closed_fd), expecting NULL, EBADF, got:0x0, json_object_from_fd: error reading fd 3: ERRNO=EBADF
OK: json_object_to_file(json.out, jso)=0
file[json.out], size=336, contents={"foo":1234,"foo1":"abcdefghijklmnopqrstuvwxyz","foo2":"abcdefghijklmnopqrstuvwxyz","foo3":"abcdefghijklmnopqrstuvwxyz","foo4":"abcdefghijklmnopqrstuvwxyz","foo5":"abcdefghijklmnopqrstuvwxyz","foo6":"abcdefghijklmnopqrstuvwxyz","foo7":"abcdefghijklmnopqrstuvwxyz","foo8":"abcdefghijklmnopqrstuvwxyz","foo9":"abcdefghijklmnopqrstuvwxyz"}
OK: json_object_to_file_ext(json2.out, jso, JSON_C_TO_STRING_PRETTY)=0
file[json2.out], size=367, contents={
"foo":1234,
"foo1":"abcdefghijklmnopqrstuvwxyz",
"foo2":"abcdefghijklmnopqrstuvwxyz",
"foo3":"abcdefghijklmnopqrstuvwxyz",
"foo4":"abcdefghijklmnopqrstuvwxyz",
"foo5":"abcdefghijklmnopqrstuvwxyz",
"foo6":"abcdefghijklmnopqrstuvwxyz",
"foo7":"abcdefghijklmnopqrstuvwxyz",
"foo8":"abcdefghijklmnopqrstuvwxyz",
"foo9":"abcdefghijklmnopqrstuvwxyz"
}