json_load* return NULL if the first argument is NULL

This commit is contained in:
Andrea Marchesini
2011-11-11 19:17:50 +01:00
committed by Petri Lehtinen
parent 72cd84b92a
commit 5ec101ec21
2 changed files with 51 additions and 5 deletions

View File

@@ -50,9 +50,32 @@ static void disable_eof_check()
json_decref(json);
}
static void load_wrong_args()
{
json_t *json;
json_error_t error;
json = json_loads(NULL, 0, &error);
if (json)
fail("json_loads should return NULL if the first argument is NULL");
json = json_loadb(NULL, 0, 0, &error);
if (json)
fail("json_loadb should return NULL if the first argument is NULL");
json = json_loadf(NULL, 0, &error);
if (json)
fail("json_loadf should return NULL if the first argument is NULL");
json = json_load_file(NULL, 0, &error);
if (json)
fail("json_loadf should return NULL if the first argument is NULL");
}
static void run_tests()
{
file_not_found();
reject_duplicates();
disable_eof_check();
load_wrong_args();
}