tests/test_json.c

changeset 978
1da52af18ac3
parent 977
a941b01b684f
equal deleted inserted replaced
977:a941b01b684f 978:1da52af18ac3
240 CX_TEST_ASSERT(cxJsonAsInteger(d10) == 47); 240 CX_TEST_ASSERT(cxJsonAsInteger(d10) == 47);
241 241
242 CX_TEST_ASSERT(json.states != json.states_internal); 242 CX_TEST_ASSERT(json.states != json.states_internal);
243 CX_TEST_ASSERT(json.states_alloc > cx_nmemb(json.states_internal)); 243 CX_TEST_ASSERT(json.states_alloc > cx_nmemb(json.states_internal));
244 244
245 cxJsonValueFree(d1);
245 cxJsonDestroy(&json); 246 cxJsonDestroy(&json);
246 } 247 }
247 } 248 }
248 249
249 CX_TEST(test_json_number) { 250 CX_TEST(test_json_number) {
256 cxJsonFill(&json, "3.1415 "); 257 cxJsonFill(&json, "3.1415 ");
257 result = cxJsonNext(&json, &v); 258 result = cxJsonNext(&json, &v);
258 CX_TEST_ASSERT(result == 1); 259 CX_TEST_ASSERT(result == 1);
259 CX_TEST_ASSERT(cxJsonIsNumber(v)); 260 CX_TEST_ASSERT(cxJsonIsNumber(v));
260 CX_TEST_ASSERT(cxJsonAsDouble(v) == 3.1415); 261 CX_TEST_ASSERT(cxJsonAsDouble(v) == 3.1415);
262 cxJsonValueFree(v);
261 cxJsonFill(&json, "-47.11e2 "); 263 cxJsonFill(&json, "-47.11e2 ");
262 result = cxJsonNext(&json, &v); 264 result = cxJsonNext(&json, &v);
263 CX_TEST_ASSERT(result == 1); 265 CX_TEST_ASSERT(result == 1);
264 CX_TEST_ASSERT(cxJsonIsNumber(v)); 266 CX_TEST_ASSERT(cxJsonIsNumber(v));
265 CX_TEST_ASSERT(cxJsonAsDouble(v) == -4711.0); 267 CX_TEST_ASSERT(cxJsonAsDouble(v) == -4711.0);
268 cxJsonValueFree(v);
266 } 269 }
267 cxJsonDestroy(&json); 270 cxJsonDestroy(&json);
268 } 271 }
269 272
270 CX_TEST(test_json_multiple_values) { 273 CX_TEST(test_json_multiple_values) {

mercurial