tests/test_json.c

changeset 975
96bf02371aef
parent 973
05910a8994f7
child 977
a941b01b684f
equal deleted inserted replaced
974:ed44741d8ab5 975:96bf02371aef
248 248
249 CX_TEST(test_json_number) { 249 CX_TEST(test_json_number) {
250 CxJson json; 250 CxJson json;
251 cxJsonInit(&json); 251 cxJsonInit(&json);
252 CX_TEST_DO { 252 CX_TEST_DO {
253 // TODO: find a better way to terminate values that are not arrays/objects
253 CxJsonValue *v; 254 CxJsonValue *v;
254 255 int result;
255 cxJsonNext(&json, &v); 256 cxJsonFill(&json, "3.1415 ");
257 result = cxJsonNext(&json, &v);
258 CX_TEST_ASSERT(result == 1);
259 CX_TEST_ASSERT(cxJsonIsNumber(v));
260 CX_TEST_ASSERT(cxJsonAsDouble(v) == 3.1415);
261 cxJsonFill(&json, "-47.11e2 ");
262 result = cxJsonNext(&json, &v);
263 CX_TEST_ASSERT(result == 1);
264 CX_TEST_ASSERT(cxJsonIsNumber(v));
265 CX_TEST_ASSERT(cxJsonAsDouble(v) == -4711.0);
256 } 266 }
257 cxJsonDestroy(&json); 267 cxJsonDestroy(&json);
258 } 268 }
259 269
260 CxTestSuite *cx_test_suite_json(void) { 270 CxTestSuite *cx_test_suite_json(void) {
263 cx_test_register(suite, test_json_init_default); 273 cx_test_register(suite, test_json_init_default);
264 cx_test_register(suite, test_json_simple_object); 274 cx_test_register(suite, test_json_simple_object);
265 cx_test_register(suite, test_json_object_incomplete_token); 275 cx_test_register(suite, test_json_object_incomplete_token);
266 cx_test_register(suite, test_json_object_error); 276 cx_test_register(suite, test_json_object_error);
267 cx_test_register(suite, test_json_large_nesting_depth); 277 cx_test_register(suite, test_json_large_nesting_depth);
278 cx_test_register(suite, test_json_number);
268 279
269 return suite; 280 return suite;
270 } 281 }
271 282

mercurial