Ejemplo n.º 1
0
static void cjson_add_object_should_fail_with_null_pointers(void)
{
    cJSON *root = cJSON_CreateObject();

    TEST_ASSERT_NULL(cJSON_AddObjectToObject(NULL, "object"));
    TEST_ASSERT_NULL(cJSON_AddObjectToObject(root, NULL));

    cJSON_Delete(root);
}
Ejemplo n.º 2
0
static void cJSON_add_object_should_add_object(void)
{
    cJSON *root = cJSON_CreateObject();
    cJSON *object = NULL;

    cJSON_AddObjectToObject(root, "object");
    TEST_ASSERT_NOT_NULL(object = cJSON_GetObjectItemCaseSensitive(root, "object"));
    TEST_ASSERT_EQUAL_INT(object->type, cJSON_Object);

    cJSON_Delete(root);
}
Ejemplo n.º 3
0
static void cjson_add_object_should_fail_on_allocation_failure(void)
{
    cJSON *root = cJSON_CreateObject();

    cJSON_InitHooks(&failing_hooks);

    TEST_ASSERT_NULL(cJSON_AddObjectToObject(root, "object"));

    cJSON_InitHooks(NULL);

    cJSON_Delete(root);
}
Ejemplo n.º 4
0
cJSON * makeJSON(){
	cJSON *root = NULL;
	root = cJSON_CreateObject();
	cJSON_AddStringToObject(root,"name","СÃ÷");
	cJSON_AddNumberToObject(root,"age",21);
	cJSON_AddNumberToObject(root,"money",12345.67);
	cJSON *child = cJSON_CreateObject();
    cJSON_AddObjectToObject(root,child,"child");
	cJSON_AddStringToObject(child,"name2","ÀÏÍõ");
	cJSON_AddNumberToObject(child,"age2",38);
	cJSON_AddNumberToObject(child,"money2",54321.89);
	cJSON_Print(root);
	return root;
}