From 0c48fca4a23abb6db4f4fb2a983ea330c78b64eb Mon Sep 17 00:00:00 2001 From: lixianjing Date: Sun, 3 Jan 2021 18:42:56 +0800 Subject: [PATCH] format code --- src/fscript_ext/fscript_ext.c | 7 ++-- src/fscript_ext/fscript_math.c | 3 -- src/fscript_ext/fscript_object.c | 6 +-- src/fscript_ext/fscript_typed_array.c | 39 +++++++++---------- src/streams/serial/istream_serial.c | 2 +- src/streams/tools/serial_echo.c | 16 ++++---- src/streams/tools/serial_send.c | 4 +- src/tkc/object_rbuffer.c | 19 +++++---- src/tkc/object_typed_array.c | 22 +++++------ src/tkc/object_wbuffer.c | 21 +++++----- src/tkc/value.c | 6 +-- tests/buffer_test.cc | 2 +- tests/fscript_test.cc | 2 +- tests/typed_array_test.cc | 56 +++++++++++++-------------- 14 files changed, 99 insertions(+), 106 deletions(-) diff --git a/src/fscript_ext/fscript_ext.c b/src/fscript_ext/fscript_ext.c index 8dc8b4dcd..0a61b3aae 100644 --- a/src/fscript_ext/fscript_ext.c +++ b/src/fscript_ext/fscript_ext.c @@ -22,18 +22,17 @@ #if defined(LINUX) || defined(WINDOWS) || defined(MACOS) || defined(ANDROID) || defined(IOS) #define FSCRIPT_WITH_MATH 1 #define FSCRIPT_WITH_TYPED_ARRAY 1 -#endif/*PC*/ +#endif /*PC*/ ret_t fscript_ext_init(void) { fscript_object_register(); #ifdef FSCRIPT_WITH_MATH fscript_math_register(); -#endif/*FSCRIPT_WITH_MATH*/ +#endif /*FSCRIPT_WITH_MATH*/ #ifdef FSCRIPT_WITH_TYPED_ARRAY fscript_typed_array_register(); -#endif/*FSCRIPT_WITH_TYPED_ARRAY*/ +#endif /*FSCRIPT_WITH_TYPED_ARRAY*/ return RET_OK; } - diff --git a/src/fscript_ext/fscript_math.c b/src/fscript_ext/fscript_math.c index 251b993f2..42b77437e 100644 --- a/src/fscript_ext/fscript_math.c +++ b/src/fscript_ext/fscript_math.c @@ -14,7 +14,6 @@ * */ - #include "tkc/fscript.h" static ret_t func_pow(fscript_t* fscript, fscript_args_t* args, value_t* result) { @@ -85,5 +84,3 @@ ret_t fscript_math_register(void) { return RET_OK; } - - diff --git a/src/fscript_ext/fscript_object.c b/src/fscript_ext/fscript_object.c index 1ca58b196..de5a021f2 100644 --- a/src/fscript_ext/fscript_object.c +++ b/src/fscript_ext/fscript_object.c @@ -47,7 +47,7 @@ static ret_t func_object_get_prop(fscript_t* fscript, fscript_args_t* args, valu obj = value_object(args->args); return_value_if_fail(obj != NULL, RET_BAD_PARAMS); - object_get_prop(obj, value_str(args->args+1), result); + object_get_prop(obj, value_str(args->args + 1), result); return RET_OK; } @@ -58,7 +58,7 @@ static ret_t func_object_set_prop(fscript_t* fscript, fscript_args_t* args, valu obj = value_object(args->args); return_value_if_fail(obj != NULL, RET_BAD_PARAMS); - value_set_bool(result, object_set_prop(obj, value_str(args->args+1), args->args+2) == RET_OK); + value_set_bool(result, object_set_prop(obj, value_str(args->args + 1), args->args + 2) == RET_OK); return RET_OK; } @@ -78,6 +78,6 @@ ret_t fscript_object_register(void) { ENSURE(fscript_register_func("object_unref", func_object_unref) == RET_OK); ENSURE(fscript_register_func("object_set", func_object_set_prop) == RET_OK); ENSURE(fscript_register_func("object_get", func_object_get_prop) == RET_OK); - + return RET_OK; } diff --git a/src/fscript_ext/fscript_typed_array.c b/src/fscript_ext/fscript_typed_array.c index 0cc7a86e2..7fd3e111b 100644 --- a/src/fscript_ext/fscript_typed_array.c +++ b/src/fscript_ext/fscript_typed_array.c @@ -14,7 +14,6 @@ * */ - #include "tkc/fscript.h" #include "tkc/object_typed_array.h" @@ -25,27 +24,27 @@ static ret_t func_array_create(fscript_t* fscript, fscript_args_t* args, value_t value_type_t type = VALUE_TYPE_INT8; FSCRIPT_FUNC_CHECK(args->size == 2, RET_BAD_PARAMS); stype = value_str(args->args); - capacity = value_uint32(args->args+1); + capacity = value_uint32(args->args + 1); - if(tk_str_eq(stype, "i8")) { + if (tk_str_eq(stype, "i8")) { type = VALUE_TYPE_INT8; - } else if(tk_str_eq(stype, "i16")) { + } else if (tk_str_eq(stype, "i16")) { type = VALUE_TYPE_INT16; - } else if(tk_str_eq(stype, "i32")) { + } else if (tk_str_eq(stype, "i32")) { type = VALUE_TYPE_INT32; - } else if(tk_str_eq(stype, "i64")) { + } else if (tk_str_eq(stype, "i64")) { type = VALUE_TYPE_INT64; - } else if(tk_str_eq(stype, "u8")) { + } else if (tk_str_eq(stype, "u8")) { type = VALUE_TYPE_UINT8; - } else if(tk_str_eq(stype, "u16")) { + } else if (tk_str_eq(stype, "u16")) { type = VALUE_TYPE_UINT16; - } else if(tk_str_eq(stype, "u32")) { + } else if (tk_str_eq(stype, "u32")) { type = VALUE_TYPE_UINT32; - } else if(tk_str_eq(stype, "u64")) { + } else if (tk_str_eq(stype, "u64")) { type = VALUE_TYPE_UINT64; - } else if(tk_str_eq(stype, "f32")) { + } else if (tk_str_eq(stype, "f32")) { type = VALUE_TYPE_FLOAT32; - } else if(tk_str_eq(stype, "float")) { + } else if (tk_str_eq(stype, "float")) { type = VALUE_TYPE_DOUBLE; } else { type = VALUE_TYPE_INT32; @@ -70,8 +69,8 @@ static ret_t func_array_push(fscript_t* fscript, fscript_args_t* args, value_t* arr = get_typed_array(fscript, args); return_value_if_fail(arr != NULL, RET_BAD_PARAMS); - value_set_bool(result, typed_array_push(arr, args->args+1) == RET_OK); - + value_set_bool(result, typed_array_push(arr, args->args + 1) == RET_OK); + return RET_OK; } @@ -90,7 +89,8 @@ static ret_t func_array_set(fscript_t* fscript, fscript_args_t* args, value_t* r arr = get_typed_array(fscript, args); return_value_if_fail(arr != NULL, RET_BAD_PARAMS); - value_set_bool(result, typed_array_set(arr, value_uint32(args->args+1), args->args+2) == RET_OK); + value_set_bool(result, + typed_array_set(arr, value_uint32(args->args + 1), args->args + 2) == RET_OK); return RET_OK; } @@ -101,7 +101,7 @@ static ret_t func_array_get(fscript_t* fscript, fscript_args_t* args, value_t* r arr = get_typed_array(fscript, args); return_value_if_fail(arr != NULL, RET_BAD_PARAMS); - typed_array_get(arr, value_uint32(args->args+1), result); + typed_array_get(arr, value_uint32(args->args + 1), result); return RET_OK; } @@ -134,7 +134,8 @@ static ret_t func_array_insert(fscript_t* fscript, fscript_args_t* args, value_t arr = get_typed_array(fscript, args); return_value_if_fail(arr != NULL, RET_BAD_PARAMS); - value_set_bool(result, typed_array_insert(arr, value_uint32(args->args+1), args->args+2) == RET_OK); + value_set_bool(result, + typed_array_insert(arr, value_uint32(args->args + 1), args->args + 2) == RET_OK); return RET_OK; } @@ -145,7 +146,7 @@ static ret_t func_array_remove(fscript_t* fscript, fscript_args_t* args, value_t arr = get_typed_array(fscript, args); return_value_if_fail(arr != NULL, RET_BAD_PARAMS); - value_set_bool(result, typed_array_remove(arr, value_uint32(args->args+1)) == RET_OK); + value_set_bool(result, typed_array_remove(arr, value_uint32(args->args + 1)) == RET_OK); return RET_OK; } @@ -163,5 +164,3 @@ ret_t fscript_typed_array_register(void) { return RET_OK; } - - diff --git a/src/streams/serial/istream_serial.c b/src/streams/serial/istream_serial.c index 5da004810..0fc849b01 100644 --- a/src/streams/serial/istream_serial.c +++ b/src/streams/serial/istream_serial.c @@ -26,7 +26,7 @@ static int32_t tk_istream_serial_read(tk_istream_t* stream, uint8_t* buff, uint32_t max_size) { int32_t ret = 0; tk_istream_serial_t* istream_serial = TK_ISTREAM_SERIAL(stream); - + errno = 0; ret = serial_read(istream_serial->fd, buff, max_size); if (ret < 0) { diff --git a/src/streams/tools/serial_echo.c b/src/streams/tools/serial_echo.c index e04c51546..54539078b 100644 --- a/src/streams/tools/serial_echo.c +++ b/src/streams/tools/serial_echo.c @@ -17,18 +17,18 @@ void do_echo(tk_iostream_t* iostream) { while (ret == 0) { ret = tk_istream_read(istream, (uint8_t*)&size, sizeof(size)); - log_debug("size=%u ret=%d\n",size, ret); + log_debug("size=%u ret=%d\n", size, ret); sleep_ms(1000); } return_if_fail(ret == sizeof(size)); - - buff = TKMEM_ALLOC(size+1); - memset(buff, 0x00, size+1); - log_debug("size=%u\n",size); - ret = tk_istream_read_len(istream, (uint8_t*)buff, size, 600*1000); - log_debug("(%u==%d):%s",size, ret, buff); - if(ret > 0) { + buff = TKMEM_ALLOC(size + 1); + memset(buff, 0x00, size + 1); + log_debug("size=%u\n", size); + ret = tk_istream_read_len(istream, (uint8_t*)buff, size, 600 * 1000); + log_debug("(%u==%d):%s", size, ret, buff); + + if (ret > 0) { tk_ostream_write_len(ostream, &ret, sizeof(ret), 10000); tk_ostream_write_len(ostream, buff, ret, 600 * 1000); } diff --git a/src/streams/tools/serial_send.c b/src/streams/tools/serial_send.c index 2d1cd2cbc..f90fc1f62 100644 --- a/src/streams/tools/serial_send.c +++ b/src/streams/tools/serial_send.c @@ -20,14 +20,14 @@ void do_send(tk_iostream_t* iostream, const char* filename) { return_if_fail(data != NULL); ret = tk_ostream_write_len(ostream, (uint8_t*)&size, sizeof(size), 1000); - ret = tk_ostream_write_len(ostream, (uint8_t*)data, size, 600*1000); + ret = tk_ostream_write_len(ostream, (uint8_t*)data, size, 600 * 1000); log_debug("send size=%u ret=%d \n", size, ret); memset(data, 0x00, size); ret = tk_istream_read_len(istream, (uint8_t*)&size, sizeof(size), 1000); return_if_fail(ret == sizeof(size)); log_debug("size=%u\n", size); - ret = tk_istream_read_len(istream, (uint8_t*)data, size, 600*1000); + ret = tk_istream_read_len(istream, (uint8_t*)data, size, 600 * 1000); if (ret >= 0) { data[ret] = '\0'; diff --git a/src/tkc/object_rbuffer.c b/src/tkc/object_rbuffer.c index 4bb23c721..d8dafe192 100644 --- a/src/tkc/object_rbuffer.c +++ b/src/tkc/object_rbuffer.c @@ -37,13 +37,13 @@ static ret_t object_rbuffer_get_prop(object_t* obj, const char* name, value_t* v object_rbuffer_t* o = OBJECT_RBUFFER(obj); return_value_if_fail(o != NULL && o->rbuffer != NULL, RET_BAD_PARAMS); - if(tk_str_eq(name, "cursor")) { + if (tk_str_eq(name, "cursor")) { value_set_uint32(v, o->rbuffer->cursor); ret = RET_OK; - } else if(tk_str_eq(name, "capacity")) { + } else if (tk_str_eq(name, "capacity")) { value_set_uint32(v, o->rbuffer->capacity); ret = RET_OK; - } else if(tk_str_eq(name, "data")) { + } else if (tk_str_eq(name, "data")) { value_set_pointer(v, (void*)(o->rbuffer->data)); ret = RET_OK; } @@ -52,13 +52,12 @@ static ret_t object_rbuffer_get_prop(object_t* obj, const char* name, value_t* v } static const object_vtable_t s_object_rbuffer_vtable = {.type = "object_rbuffer", - .desc = "object_rbuffer", - .size = sizeof(object_rbuffer_t), - .is_collection = FALSE, - .on_destroy = object_rbuffer_on_destroy, - .get_prop = object_rbuffer_get_prop, - .set_prop = object_rbuffer_set_prop -}; + .desc = "object_rbuffer", + .size = sizeof(object_rbuffer_t), + .is_collection = FALSE, + .on_destroy = object_rbuffer_on_destroy, + .get_prop = object_rbuffer_get_prop, + .set_prop = object_rbuffer_set_prop}; object_t* object_rbuffer_create(const uint8_t* data, uint32_t capacity) { object_t* o = NULL; diff --git a/src/tkc/object_typed_array.c b/src/tkc/object_typed_array.c index 3fac13645..65599b163 100644 --- a/src/tkc/object_typed_array.c +++ b/src/tkc/object_typed_array.c @@ -43,13 +43,13 @@ static ret_t object_typed_array_get_prop(object_t* obj, const char* name, value_ object_typed_array_t* o = OBJECT_TYPED_ARRAY(obj); return_value_if_fail(o != NULL && o->arr != NULL, RET_BAD_PARAMS); - if(tk_str_eq(name, "size")) { + if (tk_str_eq(name, "size")) { value_set_uint32(v, o->arr->size); ret = RET_OK; - } else if(tk_str_eq(name, "byte_size")) { + } else if (tk_str_eq(name, "byte_size")) { value_set_uint32(v, o->arr->size * o->arr->element_size); ret = RET_OK; - } else if(tk_str_eq(name, "data")) { + } else if (tk_str_eq(name, "data")) { value_set_pointer(v, o->arr->data); ret = RET_OK; } @@ -57,14 +57,14 @@ static ret_t object_typed_array_get_prop(object_t* obj, const char* name, value_ return ret; } -static const object_vtable_t s_object_typed_array_vtable = {.type = "object_typed_array", - .desc = "object_typed_array", - .size = sizeof(object_typed_array_t), - .is_collection = FALSE, - .on_destroy = object_typed_array_on_destroy, - .get_prop = object_typed_array_get_prop, - .set_prop = object_typed_array_set_prop -}; +static const object_vtable_t s_object_typed_array_vtable = { + .type = "object_typed_array", + .desc = "object_typed_array", + .size = sizeof(object_typed_array_t), + .is_collection = FALSE, + .on_destroy = object_typed_array_on_destroy, + .get_prop = object_typed_array_get_prop, + .set_prop = object_typed_array_set_prop}; object_t* object_typed_array_create(value_type_t type, uint32_t capacity) { object_t* o = NULL; diff --git a/src/tkc/object_wbuffer.c b/src/tkc/object_wbuffer.c index c67ebc07f..03a0ca367 100644 --- a/src/tkc/object_wbuffer.c +++ b/src/tkc/object_wbuffer.c @@ -43,13 +43,13 @@ static ret_t object_wbuffer_get_prop(object_t* obj, const char* name, value_t* v object_wbuffer_t* o = OBJECT_WBUFFER(obj); return_value_if_fail(o != NULL && o->wbuffer != NULL, RET_BAD_PARAMS); - if(tk_str_eq(name, "cursor")) { + if (tk_str_eq(name, "cursor")) { value_set_uint32(v, o->wbuffer->cursor); ret = RET_OK; - } else if(tk_str_eq(name, "capacity")) { + } else if (tk_str_eq(name, "capacity")) { value_set_uint32(v, o->wbuffer->capacity); ret = RET_OK; - } else if(tk_str_eq(name, "data")) { + } else if (tk_str_eq(name, "data")) { value_set_pointer(v, o->wbuffer->data); ret = RET_OK; } @@ -58,13 +58,12 @@ static ret_t object_wbuffer_get_prop(object_t* obj, const char* name, value_t* v } static const object_vtable_t s_object_wbuffer_vtable = {.type = "object_wbuffer", - .desc = "object_wbuffer", - .size = sizeof(object_wbuffer_t), - .is_collection = FALSE, - .on_destroy = object_wbuffer_on_destroy, - .get_prop = object_wbuffer_get_prop, - .set_prop = object_wbuffer_set_prop -}; + .desc = "object_wbuffer", + .size = sizeof(object_wbuffer_t), + .is_collection = FALSE, + .on_destroy = object_wbuffer_on_destroy, + .get_prop = object_wbuffer_get_prop, + .set_prop = object_wbuffer_set_prop}; object_t* object_wbuffer_create_ex(bool_t extendable, uint8_t* data, uint32_t capacity) { object_t* o = NULL; @@ -75,7 +74,7 @@ object_t* object_wbuffer_create_ex(bool_t extendable, uint8_t* data, uint32_t ca wrapper = OBJECT_WBUFFER(o); return_value_if_fail(wrapper != NULL, NULL); - if(extendable) { + if (extendable) { wrapper->wbuffer = wbuffer_init_extendable(&(wrapper->awbuffer)); } else { wrapper->wbuffer = wbuffer_init(&(wrapper->awbuffer), data, capacity); diff --git a/src/tkc/value.c b/src/tkc/value.c index c9c7301ca..2ecf52c80 100644 --- a/src/tkc/value.c +++ b/src/tkc/value.c @@ -805,9 +805,9 @@ uint32_t value_type_size(value_type_t type) { case VALUE_TYPE_DOUBLE: { return sizeof(double); } - case VALUE_TYPE_OBJECT: - case VALUE_TYPE_STRING: - case VALUE_TYPE_WSTRING: + case VALUE_TYPE_OBJECT: + case VALUE_TYPE_STRING: + case VALUE_TYPE_WSTRING: case VALUE_TYPE_POINTER: { return sizeof(void*); } diff --git a/tests/buffer_test.cc b/tests/buffer_test.cc index 0aa16e601..442dd369f 100644 --- a/tests/buffer_test.cc +++ b/tests/buffer_test.cc @@ -165,7 +165,7 @@ TEST(Buffer, obj) { rbuffer_read_string(rbuffer, &str); ASSERT_STREQ(str, "hello"); - + ASSERT_EQ(object_get_prop_int(robj, "cursor", 0), 6); ASSERT_EQ(object_get_prop_int(robj, "capacity", 0), 13); ASSERT_EQ(object_get_prop_pointer(robj, "data"), (void*)(rbuffer->data)); diff --git a/tests/fscript_test.cc b/tests/fscript_test.cc index 4aaf69cde..56300710c 100644 --- a/tests/fscript_test.cc +++ b/tests/fscript_test.cc @@ -949,7 +949,7 @@ TEST(FExr, error) { fscript_eval(obj, "sin();has_error()", &v); ASSERT_EQ(value_bool(&v), TRUE); value_reset(&v); - + fscript_eval(obj, "sin(1);has_error()", &v); ASSERT_EQ(value_bool(&v), FALSE); value_reset(&v); diff --git a/tests/typed_array_test.cc b/tests/typed_array_test.cc index 298dff83f..f0619c662 100644 --- a/tests/typed_array_test.cc +++ b/tests/typed_array_test.cc @@ -18,7 +18,7 @@ TEST(TypedArray, basic) { ASSERT_EQ(value_uint8(&v), 1); ASSERT_EQ(typed_array_get(a, 2, &v), RET_OK); ASSERT_EQ(value_uint8(&v), 2); - + ASSERT_EQ(typed_array_set(a, 0, value_set_uint8(&v, 100)), RET_OK); ASSERT_EQ(typed_array_get(a, 0, &v), RET_OK); ASSERT_EQ(value_uint8(&v), 100); @@ -26,65 +26,65 @@ TEST(TypedArray, basic) { ASSERT_EQ(typed_array_set(a, 1, value_set_uint8(&v, 200)), RET_OK); ASSERT_EQ(typed_array_get(a, 1, &v), RET_OK); ASSERT_EQ(value_uint8(&v), 200); - + ASSERT_EQ(typed_array_set(a, 2, value_set_uint8(&v, 230)), RET_OK); ASSERT_EQ(typed_array_get(a, 2, &v), RET_OK); ASSERT_EQ(value_uint8(&v), 230); - + ASSERT_EQ(typed_array_remove(a, 1), RET_OK); ASSERT_EQ(typed_array_get(a, 1, &v), RET_OK); ASSERT_EQ(value_uint8(&v), 230); ASSERT_EQ(a->size, 2); - + ASSERT_EQ(typed_array_remove(a, 0), RET_OK); ASSERT_EQ(typed_array_get(a, 0, &v), RET_OK); ASSERT_EQ(value_uint8(&v), 230); ASSERT_EQ(a->size, 1); - + ASSERT_EQ(typed_array_remove(a, 0), RET_OK); ASSERT_EQ(a->size, 0); ASSERT_EQ(typed_array_remove(a, 0), RET_BAD_PARAMS); ASSERT_EQ(a->size, 0); ASSERT_EQ(typed_array_tail(a, &v), RET_BAD_PARAMS); - + typed_array_destroy(a); } TEST(TypedArray, push) { value_t v; - uint8_t i = 0; + uint8_t i = 0; typed_array_t* a = typed_array_create(VALUE_TYPE_UINT8, 0); ASSERT_EQ(a != NULL, true); - for(i = 0; i < 255; i++) { + for (i = 0; i < 255; i++) { ASSERT_EQ(a->size, i); ASSERT_EQ(typed_array_push(a, value_set_uint8(&v, i)), RET_OK); ASSERT_EQ(typed_array_tail(a, &v), RET_OK); ASSERT_EQ(value_uint8(&v), i); } - - for(; i > 0; i--) { + + for (; i > 0; i--) { ASSERT_EQ(a->size, i); ASSERT_EQ(typed_array_tail(a, &v), RET_OK); - ASSERT_EQ(value_uint8(&v), i-1); + ASSERT_EQ(value_uint8(&v), i - 1); ASSERT_EQ(typed_array_pop(a, &v), RET_OK); - ASSERT_EQ(value_uint8(&v), i-1); + ASSERT_EQ(value_uint8(&v), i - 1); } typed_array_destroy(a); } TEST(TypedArray, insert) { value_t v; - uint8_t i = 0; + uint8_t i = 0; typed_array_t* a = typed_array_create(VALUE_TYPE_UINT8, 0); ASSERT_EQ(a != NULL, true); - for(i = 0; i < 255; i++) { + for (i = 0; i < 255; i++) { ASSERT_EQ(a->size, i); ASSERT_EQ(typed_array_insert(a, 0, value_set_uint8(&v, i)), RET_OK); ASSERT_EQ(typed_array_get(a, 0, &v), RET_OK); ASSERT_EQ(value_uint8(&v), i); } - + ASSERT_EQ(typed_array_clear(a), RET_OK); ASSERT_EQ(a->size, 0); @@ -98,17 +98,17 @@ TEST(TypedArray, pointer) { TEST(TypedArray, insert_uint64) { value_t v; - uint8_t i = 0; + uint8_t i = 0; typed_array_t* a = typed_array_create(VALUE_TYPE_UINT64, 0); ASSERT_EQ(a != NULL, true); ASSERT_EQ(a->element_size, sizeof(uint64_t)); - for(i = 0; i < 255; i++) { + for (i = 0; i < 255; i++) { ASSERT_EQ(a->size, i); ASSERT_EQ(typed_array_insert(a, 0, value_set_uint64(&v, i)), RET_OK); ASSERT_EQ(typed_array_get(a, 0, &v), RET_OK); ASSERT_EQ(value_uint64(&v), i); } - + ASSERT_EQ(typed_array_set(a, 10, value_set_uint64(&v, 0x1122334455667788)), RET_OK); ASSERT_EQ(typed_array_get(a, 10, &v), RET_OK); ASSERT_EQ(value_uint64(&v), 0x1122334455667788); @@ -120,17 +120,17 @@ TEST(TypedArray, insert_uint64) { TEST(TypedArray, insert_double) { value_t v; - uint8_t i = 0; + uint8_t i = 0; typed_array_t* a = typed_array_create(VALUE_TYPE_DOUBLE, 10); ASSERT_EQ(a != NULL, true); ASSERT_EQ(a->element_size, sizeof(double_t)); - for(i = 0; i < 255; i++) { + for (i = 0; i < 255; i++) { ASSERT_EQ(a->size, i); ASSERT_EQ(typed_array_insert(a, 0, value_set_double(&v, i)), RET_OK); ASSERT_EQ(typed_array_get(a, 0, &v), RET_OK); ASSERT_EQ(value_double(&v), i); } - + ASSERT_EQ(typed_array_set(a, 10, value_set_double(&v, 0x112233)), RET_OK); ASSERT_EQ(typed_array_get(a, 10, &v), RET_OK); ASSERT_EQ(value_double(&v), 0x112233); @@ -142,17 +142,17 @@ TEST(TypedArray, insert_double) { TEST(TypedArray, insert_uint32) { value_t v; - uint8_t i = 0; + uint8_t i = 0; typed_array_t* a = typed_array_create(VALUE_TYPE_UINT32, 0); ASSERT_EQ(a != NULL, true); ASSERT_EQ(a->element_size, sizeof(uint32_t)); - for(i = 0; i < 255; i++) { + for (i = 0; i < 255; i++) { ASSERT_EQ(a->size, i); ASSERT_EQ(typed_array_insert(a, 0, value_set_uint32(&v, i)), RET_OK); ASSERT_EQ(typed_array_get(a, 0, &v), RET_OK); ASSERT_EQ(value_uint32(&v), i); } - + ASSERT_EQ(typed_array_set(a, 10, value_set_uint32(&v, 0x11223344)), RET_OK); ASSERT_EQ(typed_array_get(a, 10, &v), RET_OK); ASSERT_EQ(value_uint32(&v), 0x11223344); @@ -164,21 +164,21 @@ TEST(TypedArray, insert_uint32) { TEST(TypedArray, object1) { value_t v; - uint8_t i = 0; + uint8_t i = 0; object_t* obj = object_typed_array_create(VALUE_TYPE_UINT32, 0); typed_array_t* a = OBJECT_TYPED_ARRAY(obj)->arr; ASSERT_EQ(a != NULL, true); ASSERT_EQ(a->element_size, sizeof(uint32_t)); - for(i = 0; i < 255; i++) { + for (i = 0; i < 255; i++) { ASSERT_EQ(a->size, i); ASSERT_EQ(typed_array_insert(a, 0, value_set_uint32(&v, i)), RET_OK); ASSERT_EQ(typed_array_get(a, 0, &v), RET_OK); ASSERT_EQ(value_uint32(&v), i); } - + ASSERT_EQ(object_get_prop_int(obj, "size", 0), i); - ASSERT_EQ(object_get_prop_int(obj, "byte_size", 0), i*sizeof(uint32_t)); + ASSERT_EQ(object_get_prop_int(obj, "byte_size", 0), i * sizeof(uint32_t)); ASSERT_EQ(object_get_prop_pointer(obj, "data"), (void*)a->data); typed_array_destroy(a);