test/json.c

changeset 42
3c989bc611c6
parent 41
daabc9bb5445
child 43
73c1ced3a620
equal deleted inserted replaced
41:daabc9bb5445 42:3c989bc611c6
356 CX_TEST_ASSERT(obj->d < 3.1416 && obj->d > 3.1415); 356 CX_TEST_ASSERT(obj->d < 3.1416 && obj->d > 3.1415);
357 357
358 free(obj); 358 free(obj);
359 } 359 }
360 } 360 }
361
362 CX_TEST(testJsonToObjectWithObjChild) {
363 const char *jsonStr =
364 "{"
365 "\"test3\":\"testJsonToObjectWithObjChild\","
366 "\"test2\":{ \"name\":\"Test2 Object\", \"i\":-1234567 }"
367 "}";
368
369 CxJsonValue *json;
370 cxJsonFromString(NULL, jsonStr, &json);
371
372 CX_TEST_DO {
373 Test3 *obj = dbuJsonToObject(test3_class, NULL, json);
374
375 CX_TEST_ASSERT(obj);
376 CX_TEST_ASSERT(!cx_strcmp(obj->test3, "testJsonToObjectWithObjChild"));
377 CX_TEST_ASSERT(obj->test2 != NULL);
378 CX_TEST_ASSERT(!cx_strcmp(obj->test2->name, "Test2 Object"));
379 CX_TEST_ASSERT(obj->test2->i == -1234567);
380
381 free(obj);
382 }
383 }

mercurial