40 CX_TEST_ASSERT(json.states_size == 1); |
40 CX_TEST_ASSERT(json.states_size == 1); |
41 CX_TEST_ASSERT(json.states_capacity >= 8); |
41 CX_TEST_ASSERT(json.states_capacity >= 8); |
42 CX_TEST_ASSERT(json.vbuf == json.vbuf_internal); |
42 CX_TEST_ASSERT(json.vbuf == json.vbuf_internal); |
43 CX_TEST_ASSERT(json.vbuf_size == 0); |
43 CX_TEST_ASSERT(json.vbuf_size == 0); |
44 CX_TEST_ASSERT(json.vbuf_capacity >= 8); |
44 CX_TEST_ASSERT(json.vbuf_capacity >= 8); |
|
45 cxJsonDestroy(&json); |
45 } |
46 } |
46 } |
47 } |
47 |
48 |
48 CX_TEST(test_json_simple_object) { |
49 CX_TEST(test_json_simple_object) { |
49 cxstring text = cx_str( |
50 cxstring text = cx_str( |
135 CX_TEST_ASSERT(cxJsonIsString(object)); |
136 CX_TEST_ASSERT(cxJsonIsString(object)); |
136 CX_TEST_ASSERT(0 == cx_strcmp( |
137 CX_TEST_ASSERT(0 == cx_strcmp( |
137 cxJsonAsCxString(object), |
138 cxJsonAsCxString(object), |
138 CX_STR("{\n\t\"object\":null\n}")) |
139 CX_STR("{\n\t\"object\":null\n}")) |
139 ); |
140 ); |
|
141 cxJsonValueFree(obj); |
140 } |
142 } |
141 cxJsonDestroy(&json); |
143 cxJsonDestroy(&json); |
142 } |
144 } |
143 |
145 |
144 CX_TEST(test_json_object_incomplete_token) { |
146 CX_TEST(test_json_object_incomplete_token) { |
363 cxJsonFill(&json, "0.815e-3 "); |
365 cxJsonFill(&json, "0.815e-3 "); |
364 result = cxJsonNext(&json, &v); |
366 result = cxJsonNext(&json, &v); |
365 CX_TEST_ASSERT(result == CX_JSON_NO_ERROR); |
367 CX_TEST_ASSERT(result == CX_JSON_NO_ERROR); |
366 CX_TEST_ASSERT(cxJsonIsNumber(v)); |
368 CX_TEST_ASSERT(cxJsonIsNumber(v)); |
367 CX_TEST_ASSERT(cxJsonAsDouble(v) == 0.000815); |
369 CX_TEST_ASSERT(cxJsonAsDouble(v) == 0.000815); |
|
370 cxJsonValueFree(v); |
368 |
371 |
369 cxJsonFill(&json, "1.23E4 "); |
372 cxJsonFill(&json, "1.23E4 "); |
370 result = cxJsonNext(&json, &v); |
373 result = cxJsonNext(&json, &v); |
371 CX_TEST_ASSERT(result == CX_JSON_NO_ERROR); |
374 CX_TEST_ASSERT(result == CX_JSON_NO_ERROR); |
372 CX_TEST_ASSERT(cxJsonIsNumber(v)); |
375 CX_TEST_ASSERT(cxJsonIsNumber(v)); |
373 CX_TEST_ASSERT(cxJsonAsInteger(v) == 12300); |
376 CX_TEST_ASSERT(cxJsonAsInteger(v) == 12300); |
374 CX_TEST_ASSERT(cxJsonAsDouble(v) == 12300.0); |
377 CX_TEST_ASSERT(cxJsonAsDouble(v) == 12300.0); |
375 |
|
376 cxJsonValueFree(v); |
378 cxJsonValueFree(v); |
377 } |
379 } |
378 cxJsonDestroy(&json); |
380 cxJsonDestroy(&json); |
379 } |
381 } |
380 |
382 |