| 162 CX_TEST_ASSERT(u32 && u32->type == CX_JSON_INTEGER); |
162 CX_TEST_ASSERT(u32 && u32->type == CX_JSON_INTEGER); |
| 163 CX_TEST_ASSERT(i64 && i64->type == CX_JSON_INTEGER); |
163 CX_TEST_ASSERT(i64 && i64->type == CX_JSON_INTEGER); |
| 164 CX_TEST_ASSERT(u64 && u64->type == CX_JSON_INTEGER); |
164 CX_TEST_ASSERT(u64 && u64->type == CX_JSON_INTEGER); |
| 165 CX_TEST_ASSERT(d && d->type == CX_JSON_NUMBER); |
165 CX_TEST_ASSERT(d && d->type == CX_JSON_NUMBER); |
| 166 |
166 |
| 167 CX_TEST_ASSERT(!cx_strcmp(str->value.string, test.str)); |
167 CX_TEST_ASSERT(!cx_strcmp(str->string, test.str)); |
| 168 CX_TEST_ASSERT(!cx_strcmp(str2->value.string, test.str2)); |
168 CX_TEST_ASSERT(!cx_strcmp(str2->string, test.str2)); |
| 169 CX_TEST_ASSERT(i8->value.integer == test.i8); |
169 CX_TEST_ASSERT(i8->integer == test.i8); |
| 170 CX_TEST_ASSERT(u8->value.integer == test.u8); |
170 CX_TEST_ASSERT(u8->integer == test.u8); |
| 171 CX_TEST_ASSERT(i16->value.integer == test.i16); |
171 CX_TEST_ASSERT(i16->integer == test.i16); |
| 172 CX_TEST_ASSERT(u16->value.integer == test.u16); |
172 CX_TEST_ASSERT(u16->integer == test.u16); |
| 173 CX_TEST_ASSERT(i32->value.integer == test.i32); |
173 CX_TEST_ASSERT(i32->integer == test.i32); |
| 174 CX_TEST_ASSERT(u32->value.integer == test.u32); |
174 CX_TEST_ASSERT(u32->integer == test.u32); |
| 175 CX_TEST_ASSERT(i64->value.integer == test.i64); |
175 CX_TEST_ASSERT(i64->integer == test.i64); |
| 176 CX_TEST_ASSERT(u64->value.integer == test.u64); |
176 CX_TEST_ASSERT(u64->integer == test.u64); |
| 177 CX_TEST_ASSERT(d->value.number < test.d + 0.1 && d->value.number > test.d - 0.1); |
177 CX_TEST_ASSERT(d->number < test.d + 0.1 && d->number > test.d - 0.1); |
| 178 |
178 |
| 179 cxJsonValueFree(value); |
179 cxJsonValueFree(value); |
| 180 } |
180 } |
| 181 } |
181 } |
| 182 |
182 |
| 205 CX_TEST_ASSERT(cxJsonIsObject(value)); |
205 CX_TEST_ASSERT(cxJsonIsObject(value)); |
| 206 |
206 |
| 207 CxJsonValue *v = cxJsonObjGet(value, "id"); |
207 CxJsonValue *v = cxJsonObjGet(value, "id"); |
| 208 CX_TEST_ASSERT(v); |
208 CX_TEST_ASSERT(v); |
| 209 CX_TEST_ASSERT(cxJsonIsInteger(v)); |
209 CX_TEST_ASSERT(cxJsonIsInteger(v)); |
| 210 CX_TEST_ASSERT(v->value.integer == t4.id); |
210 CX_TEST_ASSERT(v->integer == t4.id); |
| 211 |
211 |
| 212 v = cxJsonObjGet(value, "test2"); |
212 v = cxJsonObjGet(value, "test2"); |
| 213 CX_TEST_ASSERT(v); |
213 CX_TEST_ASSERT(v); |
| 214 CX_TEST_ASSERT(cxJsonIsObject(v)); |
214 CX_TEST_ASSERT(cxJsonIsObject(v)); |
| 215 |
215 |
| 216 CxJsonValue *s = cxJsonObjGet(v, "i"); |
216 CxJsonValue *s = cxJsonObjGet(v, "i"); |
| 217 CX_TEST_ASSERT(s); |
217 CX_TEST_ASSERT(s); |
| 218 CX_TEST_ASSERT(cxJsonIsInteger(s)); |
218 CX_TEST_ASSERT(cxJsonIsInteger(s)); |
| 219 CX_TEST_ASSERT(s->value.integer == t2_2.i); |
219 CX_TEST_ASSERT(s->integer == t2_2.i); |
| 220 |
220 |
| 221 s = cxJsonObjGet(v, "name"); |
221 s = cxJsonObjGet(v, "name"); |
| 222 CX_TEST_ASSERT(s); |
222 CX_TEST_ASSERT(s); |
| 223 CX_TEST_ASSERT(cxJsonIsString(s)); |
223 CX_TEST_ASSERT(cxJsonIsString(s)); |
| 224 CX_TEST_ASSERT(!cx_strcmp(s->value.string, t2_2.name)); |
224 CX_TEST_ASSERT(!cx_strcmp(s->string, t2_2.name)); |
| 225 |
225 |
| 226 v = cxJsonObjGet(value, "test3"); |
226 v = cxJsonObjGet(value, "test3"); |
| 227 CX_TEST_ASSERT(v); |
227 CX_TEST_ASSERT(v); |
| 228 CX_TEST_ASSERT(cxJsonIsObject(v)); |
228 CX_TEST_ASSERT(cxJsonIsObject(v)); |
| 229 |
229 |
| 230 s = cxJsonObjGet(v, "test3"); |
230 s = cxJsonObjGet(v, "test3"); |
| 231 CX_TEST_ASSERT(s); |
231 CX_TEST_ASSERT(s); |
| 232 CX_TEST_ASSERT(cxJsonIsString(s)); |
232 CX_TEST_ASSERT(cxJsonIsString(s)); |
| 233 CX_TEST_ASSERT(!cx_strcmp(s->value.string, t3.test3)); |
233 CX_TEST_ASSERT(!cx_strcmp(s->string, t3.test3)); |
| 234 |
234 |
| 235 s = cxJsonObjGet(v, "test2"); |
235 s = cxJsonObjGet(v, "test2"); |
| 236 CX_TEST_ASSERT(s); |
236 CX_TEST_ASSERT(s); |
| 237 CX_TEST_ASSERT(cxJsonIsObject(s)); |
237 CX_TEST_ASSERT(cxJsonIsObject(s)); |
| 238 |
238 |
| 239 CxJsonValue *x = cxJsonObjGet(s, "i"); |
239 CxJsonValue *x = cxJsonObjGet(s, "i"); |
| 240 CX_TEST_ASSERT(x); |
240 CX_TEST_ASSERT(x); |
| 241 CX_TEST_ASSERT(cxJsonIsInteger(x)); |
241 CX_TEST_ASSERT(cxJsonIsInteger(x)); |
| 242 CX_TEST_ASSERT(x->value.integer == t2_1.i); |
242 CX_TEST_ASSERT(x->integer == t2_1.i); |
| 243 |
243 |
| 244 x = cxJsonObjGet(s, "name"); |
244 x = cxJsonObjGet(s, "name"); |
| 245 CX_TEST_ASSERT(x); |
245 CX_TEST_ASSERT(x); |
| 246 CX_TEST_ASSERT(cxJsonIsString(x)); |
246 CX_TEST_ASSERT(cxJsonIsString(x)); |
| 247 CX_TEST_ASSERT(!cx_strcmp(x->value.string, t2_1.name)); |
247 CX_TEST_ASSERT(!cx_strcmp(x->string, t2_1.name)); |
| 248 |
248 |
| 249 cxJsonValueFree(value); |
249 cxJsonValueFree(value); |
| 250 } |
250 } |
| 251 } |
251 } |
| 252 |
252 |
| 277 CX_TEST_ASSERT(cxJsonIsObject(value)); |
277 CX_TEST_ASSERT(cxJsonIsObject(value)); |
| 278 |
278 |
| 279 CxJsonValue *v = cxJsonObjGet(value, "test"); |
279 CxJsonValue *v = cxJsonObjGet(value, "test"); |
| 280 CX_TEST_ASSERT(v); |
280 CX_TEST_ASSERT(v); |
| 281 CX_TEST_ASSERT(cxJsonIsString(v)); |
281 CX_TEST_ASSERT(cxJsonIsString(v)); |
| 282 CX_TEST_ASSERT(!cx_strcmp(v->value.string, test5.test)); |
282 CX_TEST_ASSERT(!cx_strcmp(v->string, test5.test)); |
| 283 |
283 |
| 284 v = cxJsonObjGet(value, "test2List"); |
284 v = cxJsonObjGet(value, "test2List"); |
| 285 CX_TEST_ASSERT(v); |
285 CX_TEST_ASSERT(v); |
| 286 CX_TEST_ASSERT(cxJsonIsArray(v)); |
286 CX_TEST_ASSERT(cxJsonIsArray(v)); |
| 287 |
287 |
| 288 CxJsonValue *x = cxJsonArrGet(v, 0); |
288 CxJsonValue *x = cxJsonArrGet(v, 0); |
| 289 CX_TEST_ASSERT(cxJsonIsObject(x)); |
289 CX_TEST_ASSERT(cxJsonIsObject(x)); |
| 290 CxJsonValue *z = cxJsonObjGet(x, "i"); |
290 CxJsonValue *z = cxJsonObjGet(x, "i"); |
| 291 CX_TEST_ASSERT(cxJsonIsInteger(z)); |
291 CX_TEST_ASSERT(cxJsonIsInteger(z)); |
| 292 CX_TEST_ASSERT(z->value.integer == c1.i); |
292 CX_TEST_ASSERT(z->integer == c1.i); |
| 293 z = cxJsonObjGet(x, "name"); |
293 z = cxJsonObjGet(x, "name"); |
| 294 CX_TEST_ASSERT(cxJsonIsString(z)); |
294 CX_TEST_ASSERT(cxJsonIsString(z)); |
| 295 CX_TEST_ASSERT(!cx_strcmp(z->value.string, c1.name)); |
295 CX_TEST_ASSERT(!cx_strcmp(z->string, c1.name)); |
| 296 |
296 |
| 297 x = cxJsonArrGet(v, 1); |
297 x = cxJsonArrGet(v, 1); |
| 298 CX_TEST_ASSERT(cxJsonIsObject(x)); |
298 CX_TEST_ASSERT(cxJsonIsObject(x)); |
| 299 z = cxJsonObjGet(x, "i"); |
299 z = cxJsonObjGet(x, "i"); |
| 300 CX_TEST_ASSERT(cxJsonIsInteger(z)); |
300 CX_TEST_ASSERT(cxJsonIsInteger(z)); |
| 301 CX_TEST_ASSERT(z->value.integer == c2.i); |
301 CX_TEST_ASSERT(z->integer == c2.i); |
| 302 z = cxJsonObjGet(x, "name"); |
302 z = cxJsonObjGet(x, "name"); |
| 303 CX_TEST_ASSERT(cxJsonIsString(z)); |
303 CX_TEST_ASSERT(cxJsonIsString(z)); |
| 304 CX_TEST_ASSERT(!cx_strcmp(z->value.string, c2.name)); |
304 CX_TEST_ASSERT(!cx_strcmp(z->string, c2.name)); |
| 305 |
305 |
| 306 x = cxJsonArrGet(v, 2); |
306 x = cxJsonArrGet(v, 2); |
| 307 CX_TEST_ASSERT(cxJsonIsObject(x)); |
307 CX_TEST_ASSERT(cxJsonIsObject(x)); |
| 308 z = cxJsonObjGet(x, "i"); |
308 z = cxJsonObjGet(x, "i"); |
| 309 CX_TEST_ASSERT(cxJsonIsInteger(z)); |
309 CX_TEST_ASSERT(cxJsonIsInteger(z)); |
| 310 CX_TEST_ASSERT(z->value.integer == c3.i); |
310 CX_TEST_ASSERT(z->integer == c3.i); |
| 311 z = cxJsonObjGet(x, "name"); |
311 z = cxJsonObjGet(x, "name"); |
| 312 CX_TEST_ASSERT(cxJsonIsString(z)); |
312 CX_TEST_ASSERT(cxJsonIsString(z)); |
| 313 CX_TEST_ASSERT(!cx_strcmp(z->value.string, c3.name)); |
313 CX_TEST_ASSERT(!cx_strcmp(z->string, c3.name)); |
| 314 |
314 |
| 315 cxJsonValueFree(value); |
315 cxJsonValueFree(value); |
| 316 } |
316 } |
| 317 } |
317 } |