diff --git a/src/primitives/array/array.h b/src/primitives/array/array.h index 46d8d85..6f6bb7e 100644 --- a/src/primitives/array/array.h +++ b/src/primitives/array/array.h @@ -70,7 +70,7 @@ BEGIN_C_LINKAGE #define wapp_array_item_size(TYPE, ARRAY_PTR) \ _array_item_size((u8 *)ARRAY_PTR, sizeof(TYPE)) #define wapp_array_get(TYPE, ARRAY_PTR, INDEX) \ - (*((TYPE *)_array_get((u8 *)ARRAY_PTR, INDEX, sizeof(TYPE)))) + ((TYPE *)_array_get((u8 *)ARRAY_PTR, INDEX, sizeof(TYPE))) #define wapp_array_set(TYPE, ARRAY_PTR, INDEX, VALUE_PTR) \ _array_set((u8 *)ARRAY_PTR, INDEX, (u8 *)VALUE_PTR, sizeof(TYPE)) #define wapp_array_append_capped(TYPE, ARRAY_PTR, VALUE_PTR) \ diff --git a/tests/array/test_i32_array.c b/tests/array/test_i32_array.c index 793017d..da01b7f 100644 --- a/tests/array/test_i32_array.c +++ b/tests/array/test_i32_array.c @@ -7,13 +7,13 @@ TestFuncResult test_i32_array(void) { i32 *array = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7); result = wapp_array_count(i32, array) == 7 && wapp_array_capacity(i32, array) == 16; - i32 item; + i32 *item; u64 count = wapp_array_count(i32, array); u64 index = 0; b8 running = true; while (running) { item = wapp_array_get(i32, array, index); - result = result && item && item == (i32)(index + 1); + result = result && item && *item == (i32)(index + 1); ++index; running = index < count; @@ -36,13 +36,13 @@ TestFuncResult test_i32_array_get(void) { i32 *array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8); - i32 item; + i32 *item; u64 count = wapp_array_count(i32, array); u64 index = 0; b8 running = true; while (running) { item = wapp_array_get(i32, array, index); - result = result && item == (i32)index; + result = result && item && *item == (i32)index; ++index; running = index < count; @@ -56,7 +56,7 @@ TestFuncResult test_i32_array_set(void) { i32 *array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8); - i32 item; + i32 *item; u64 count = wapp_array_count(i32, array); u64 index = 0; b8 running = true; @@ -64,7 +64,7 @@ TestFuncResult test_i32_array_set(void) { i32 num = (i32)(index * 2); wapp_array_set(i32, array, index, &num); item = wapp_array_get(i32, array, index); - result = result && item == (i32)(index * 2); + result = result && item && *item == (i32)(index * 2); ++index; running = index < count; @@ -79,9 +79,9 @@ TestFuncResult test_i32_array_append_capped(void) { i32 *array = wapp_array_with_capacity(i32, 64); wapp_array_append_capped(i32, array, &((i32){10})); - result = wapp_array_count(i32, array) == 1; - i32 item = wapp_array_get(i32, array, 0); - result = result && item == 10; + result = wapp_array_count(i32, array) == 1; + i32 *item = wapp_array_get(i32, array, 0); + result = result && item && *item == 10; array = wapp_array(i32, 1); wapp_array_append_capped(i32, array, &((i32){10})); @@ -120,7 +120,7 @@ TestFuncResult test_i32_array_copy_capped(void) { u64 index = 0; b8 running = true; while (running) { - result = result && wapp_array_get(i32, src, index) == wapp_array_get(i32, dst1, index); + result = result && *wapp_array_get(i32, src, index) == *wapp_array_get(i32, dst1, index); ++index; running = index < expected_count; @@ -133,7 +133,7 @@ TestFuncResult test_i32_array_copy_capped(void) { index = 0; running = true; while (running) { - result = result && wapp_array_get(i32, src, index) == wapp_array_get(i32, dst2, index); + result = result && *wapp_array_get(i32, src, index) == *wapp_array_get(i32, dst2, index); ++index; running = index < expected_count; @@ -218,7 +218,7 @@ TestFuncResult test_i32_array_copy_alloc(void) { u64 index = 0; b8 running = true; while (running) { - result = result && wapp_array_get(i32, src, index) == wapp_array_get(i32, array_ptr, index); + result = result && *wapp_array_get(i32, src, index) == *wapp_array_get(i32, array_ptr, index); ++index; running = index < expected_count; @@ -231,7 +231,7 @@ TestFuncResult test_i32_array_copy_alloc(void) { index = 0; running = true; while (running) { - result = result && wapp_array_get(i32, src, index) == wapp_array_get(i32, array_ptr, index); + result = result && *wapp_array_get(i32, src, index) == *wapp_array_get(i32, array_ptr, index); ++index; running = index < expected_count; diff --git a/tests/array/test_str8_array.c b/tests/array/test_str8_array.c index fa2eadc..64337ba 100644 --- a/tests/array/test_str8_array.c +++ b/tests/array/test_str8_array.c @@ -9,13 +9,13 @@ TestFuncResult test_str8_array(void) { Str8 *array = wapp_array(Str8, wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")); result = wapp_array_count(Str8, array) == 3 && wapp_array_capacity(Str8, array) == 8; - Str8 item; + Str8 *item; u64 count = wapp_array_count(Str8, array); u64 index = 0; b8 running = true; while (running) { item = wapp_array_get(Str8, array, index); - result = result && (wapp_str8_equal(&item, &expected[index])); + result = result && item && (wapp_str8_equal(item, &expected[index])); ++index; running = index < count;