diff options
author | dota17 <chenguopingdota@163.com> | 2020-04-14 09:20:51 +0800 |
---|---|---|
committer | dota17 <chenguopingdota@163.com> | 2020-04-14 09:20:51 +0800 |
commit | 74bbe349c4cf0308ec0c9aac1ced038c73ec8545 (patch) | |
tree | e61cf8916f86e02cd493367633b51958eeef4908 | |
parent | 110c60fcdd1742c1a7f9dbee5c9fb971790bb9e7 (diff) | |
download | json-c-74bbe349c4cf0308ec0c9aac1ced038c73ec8545.tar.gz |
clang-format test1.c
-rw-r--r-- | tests/test1.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/test1.c b/tests/test1.c index 7cf6aba..98546bf 100644 --- a/tests/test1.c +++ b/tests/test1.c @@ -149,37 +149,37 @@ void test_array_list_expand_internal() my_array = make_array(); printf("my_array=\n"); - for(ii = 0; ii < json_object_array_length(my_array); ii++) + for (ii = 0; ii < json_object_array_length(my_array); ii++) { json_object *obj = json_object_array_get_idx(my_array, ii); printf("\t[%d]=%s\n", (int)ii, json_object_to_json_string(obj)); } printf("my_array.to_string()=%s\n", json_object_to_json_string(my_array)); - + /* Put iNdex < array->size, no expand. */ rc = json_object_array_put_idx(my_array, 5, json_object_new_int(6)); printf("put_idx(5,6)=%d\n", rc); - + /* array->size < Put Index < array->size * 2 <= SIZE_T_MAX, the size = array->size * 2. */ idx = ARRAY_LIST_DEFAULT_SIZE * 2 - 1; rc = json_object_array_put_idx(my_array, idx, json_object_new_int(0)); printf("put_idx(%d,0)=%d\n", (int)(idx), rc); - + /* array->size * 2 < Put Index, the size = Put Index. */ idx = ARRAY_LIST_DEFAULT_SIZE * 2 * 2 + 1; rc = json_object_array_put_idx(my_array, idx, json_object_new_int(0)); printf("put_idx(%d,0)=%d\n", (int)(idx), rc); - + /* SIZE_T_MAX <= Put Index, it will fail and the size will no change. */ idx = SIZE_MAX; // SIZE_MAX = SIZE_T_MAX - json_object* tmp = json_object_new_int(10); + json_object *tmp = json_object_new_int(10); rc = json_object_array_put_idx(my_array, idx, tmp); printf("put_idx(SIZE_T_MAX,0)=%d\n", rc); if (rc == -1) { json_object_put(tmp); } - + json_object_put(my_array); } @@ -270,10 +270,11 @@ int main(int argc, char **argv) printf("\t[%d]=%s\n", (int)i, json_object_to_json_string(obj)); } printf("my_array.to_string()=%s\n", json_object_to_json_string(my_array)); - - json_object* one = json_object_new_int(1); - json_object* result = json_object_array_bsearch(one, my_array, sort_fn); - printf("find json_object(1) in my_array successfully: %s\n", json_object_to_json_string(result)); + + json_object *one = json_object_new_int(1); + json_object *result = json_object_array_bsearch(one, my_array, sort_fn); + printf("find json_object(1) in my_array successfully: %s\n", + json_object_to_json_string(result)); json_object_put(one); my_object = json_object_new_object(); |