533 cxJsonValueFree(v); |
533 cxJsonValueFree(v); |
534 } |
534 } |
535 cxJsonDestroy(&json); |
535 cxJsonDestroy(&json); |
536 } |
536 } |
537 |
537 |
|
538 CX_TEST(test_json_array_iterator) { |
|
539 CxJson json; |
|
540 cxJsonInit(&json, NULL); |
|
541 CX_TEST_DO { |
|
542 CxJsonValue *v; |
|
543 CxJsonStatus result; |
|
544 cxJsonFill(&json, "[ 0, 3, 6, 9, 12, 15 ]\n"); |
|
545 result = cxJsonNext(&json, &v); |
|
546 CX_TEST_ASSERT(result == CX_JSON_NO_ERROR); |
|
547 CX_TEST_ASSERT(cxJsonIsArray(v)); |
|
548 CxIterator iter = cxJsonArrIter(v); |
|
549 unsigned i = 0; |
|
550 cx_foreach(CxJsonValue*, elem, iter) { |
|
551 CX_TEST_ASSERT(cxJsonIsNumber(elem)); |
|
552 CX_TEST_ASSERT(i == cxJsonAsInteger(elem)); |
|
553 i += 3; |
|
554 } |
|
555 } |
|
556 cxJsonDestroy(&json); |
|
557 } |
|
558 |
538 CX_TEST(test_json_allocator) { |
559 CX_TEST(test_json_allocator) { |
539 CxTestingAllocator talloc; |
560 CxTestingAllocator talloc; |
540 cx_testing_allocator_init(&talloc); |
561 cx_testing_allocator_init(&talloc); |
541 CxAllocator *allocator = &talloc.base; |
562 CxAllocator *allocator = &talloc.base; |
542 |
563 |
608 cx_test_register(suite, test_json_subsequent_fill); |
629 cx_test_register(suite, test_json_subsequent_fill); |
609 cx_test_register(suite, test_json_large_nesting_depth); |
630 cx_test_register(suite, test_json_large_nesting_depth); |
610 cx_test_register(suite, test_json_number); |
631 cx_test_register(suite, test_json_number); |
611 cx_test_register(suite, test_json_number_format_errors); |
632 cx_test_register(suite, test_json_number_format_errors); |
612 cx_test_register(suite, test_json_multiple_values); |
633 cx_test_register(suite, test_json_multiple_values); |
|
634 cx_test_register(suite, test_json_array_iterator); |
613 cx_test_register(suite, test_json_allocator); |
635 cx_test_register(suite, test_json_allocator); |
614 cx_test_register(suite, test_json_allocator_parse_error); |
636 cx_test_register(suite, test_json_allocator_parse_error); |
615 |
637 |
616 return suite; |
638 return suite; |
617 } |
639 } |