Rename array
This commit is contained in:
@@ -4,15 +4,15 @@
|
||||
WpTestFuncResult test_i32_array(void) {
|
||||
b8 result;
|
||||
|
||||
I32Array array = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7);
|
||||
result = wapp_array_count(array) == 7 && wapp_array_capacity(array) == 16;
|
||||
WpI32Array array = wpArray(i32, 1, 2, 3, 4, 5, 6, 7);
|
||||
result = wpArrayCount(array) == 7 && wpArrayCapacity(array) == 16;
|
||||
|
||||
i32 *item;
|
||||
u64 count = wapp_array_count(array);
|
||||
u64 count = wpArrayCount(array);
|
||||
u64 index = 0;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_array_get(i32, array, index);
|
||||
item = wpArrayGet(i32, array, index);
|
||||
result = result && item && (*item == (i32)(index + 1));
|
||||
|
||||
++index;
|
||||
@@ -25,11 +25,11 @@ WpTestFuncResult test_i32_array(void) {
|
||||
WpTestFuncResult test_i32_array_with_capacity(void) {
|
||||
b8 result;
|
||||
|
||||
I32Array array1 = wapp_array_with_capacity(i32, 64, ARRAY_INIT_NONE);
|
||||
result = wapp_array_count(array1) == 0 && wapp_array_capacity(array1) == 64;
|
||||
WpI32Array array1 = wpArrayWithCapacity(i32, 64, WP_ARRAY_INIT_NONE);
|
||||
result = wpArrayCount(array1) == 0 && wpArrayCapacity(array1) == 64;
|
||||
|
||||
I32Array array2 = wapp_array_with_capacity(i32, 64, ARRAY_INIT_FILLED);
|
||||
result = wapp_array_count(array2) == 64 && wapp_array_capacity(array2) == 64;
|
||||
WpI32Array array2 = wpArrayWithCapacity(i32, 64, WP_ARRAY_INIT_FILLED);
|
||||
result = wpArrayCount(array2) == 64 && wpArrayCapacity(array2) == 64;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -37,14 +37,14 @@ WpTestFuncResult test_i32_array_with_capacity(void) {
|
||||
WpTestFuncResult test_i32_array_get(void) {
|
||||
b8 result = true;
|
||||
|
||||
I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
WpI32Array array = wpArray(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
i32 *item;
|
||||
u64 count = wapp_array_count(array);
|
||||
u64 count = wpArrayCount(array);
|
||||
u64 index = 0;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_array_get(i32, array, index);
|
||||
item = wpArrayGet(i32, array, index);
|
||||
result = result && item && (*item == (i32)index);
|
||||
|
||||
++index;
|
||||
@@ -57,16 +57,16 @@ WpTestFuncResult test_i32_array_get(void) {
|
||||
WpTestFuncResult test_i32_array_set(void) {
|
||||
b8 result = true;
|
||||
|
||||
I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
WpI32Array array = wpArray(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
i32 *item;
|
||||
u64 count = wapp_array_count(array);
|
||||
u64 count = wpArrayCount(array);
|
||||
u64 index = 0;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
i32 num = (i32)(index * 2);
|
||||
wapp_array_set(i32, array, index, &num);
|
||||
item = wapp_array_get(i32, array, index);
|
||||
wpArraySet(i32, array, index, &num);
|
||||
item = wpArrayGet(i32, array, index);
|
||||
result = result && item && (*item == (i32)(index * 2));
|
||||
|
||||
++index;
|
||||
@@ -79,19 +79,19 @@ WpTestFuncResult test_i32_array_set(void) {
|
||||
WpTestFuncResult test_i32_array_append_capped(void) {
|
||||
b8 result;
|
||||
|
||||
I32Array array = wapp_array_with_capacity(i32, 64, ARRAY_INIT_NONE);
|
||||
WpI32Array array = wpArrayWithCapacity(i32, 64, WP_ARRAY_INIT_NONE);
|
||||
i32 item1 = 10;
|
||||
wapp_array_append_capped(i32, array, &item1);
|
||||
wpArrayAppendCapped(i32, array, &item1);
|
||||
|
||||
result = wapp_array_count(array) == 1;
|
||||
i32 *item = wapp_array_get(i32, array, 0);
|
||||
result = wpArrayCount(array) == 1;
|
||||
i32 *item = wpArrayGet(i32, array, 0);
|
||||
result = result && item && *item == 10;
|
||||
|
||||
array = wapp_array(i32, 1);
|
||||
array = wpArray(i32, 1);
|
||||
i32 item2 = 10;
|
||||
wapp_array_append_capped(i32, array, &item2);
|
||||
wpArrayAppendCapped(i32, array, &item2);
|
||||
|
||||
result = result && wapp_array_count(array) == 2;
|
||||
result = result && wpArrayCount(array) == 2;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -99,14 +99,14 @@ WpTestFuncResult test_i32_array_append_capped(void) {
|
||||
WpTestFuncResult test_i32_array_extend_capped(void) {
|
||||
b8 result;
|
||||
|
||||
I32Array array1 = wapp_array(i32, 1, 2, 3, 4);
|
||||
I32Array array2 = wapp_array(i32, 10, 20);
|
||||
WpI32Array array1 = wpArray(i32, 1, 2, 3, 4);
|
||||
WpI32Array array2 = wpArray(i32, 10, 20);
|
||||
|
||||
result = wapp_array_count(array1) == 4 && wapp_array_count(array2) == 2;
|
||||
result = wpArrayCount(array1) == 4 && wpArrayCount(array2) == 2;
|
||||
|
||||
wapp_array_extend_capped(i32, array1, array2);
|
||||
wpArrayExtendCapped(i32, array1, array2);
|
||||
|
||||
result = result && wapp_array_count(array1) == 6;
|
||||
result = result && wpArrayCount(array1) == 6;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -114,31 +114,31 @@ WpTestFuncResult test_i32_array_extend_capped(void) {
|
||||
WpTestFuncResult test_i32_array_copy_capped(void) {
|
||||
b8 result;
|
||||
|
||||
I32Array src = wapp_array(i32, 1, 2, 3, 4, 5);
|
||||
I32Array dst1 = wapp_array(i32, 1, 2, 3, 4, 5, 6);
|
||||
I32Array dst2 = wapp_array(i32, 1, 2);
|
||||
WpI32Array src = wpArray(i32, 1, 2, 3, 4, 5);
|
||||
WpI32Array dst1 = wpArray(i32, 1, 2, 3, 4, 5, 6);
|
||||
WpI32Array dst2 = wpArray(i32, 1, 2);
|
||||
|
||||
u64 expected_count = 5;
|
||||
wapp_array_copy_capped(i32, dst1, src);
|
||||
result = wapp_array_count(dst1) == expected_count;
|
||||
wpArrayCopyCapped(i32, dst1, src);
|
||||
result = wpArrayCount(dst1) == expected_count;
|
||||
|
||||
u64 index = 0;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_array_get(i32, src, index) == *wapp_array_get(i32, dst1, index));
|
||||
result = result && (*wpArrayGet(i32, src, index) == *wpArrayGet(i32, dst1, index));
|
||||
|
||||
++index;
|
||||
running = index < expected_count;
|
||||
}
|
||||
|
||||
expected_count = 4;
|
||||
wapp_array_copy_capped(i32, dst2, src);
|
||||
result = result && wapp_array_count(dst2) == expected_count;
|
||||
wpArrayCopyCapped(i32, dst2, src);
|
||||
result = result && wpArrayCount(dst2) == expected_count;
|
||||
|
||||
index = 0;
|
||||
running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_array_get(i32, src, index) == *wapp_array_get(i32, dst2, index));
|
||||
result = result && (*wpArrayGet(i32, src, index) == *wpArrayGet(i32, dst2, index));
|
||||
|
||||
++index;
|
||||
running = index < expected_count;
|
||||
@@ -150,13 +150,13 @@ WpTestFuncResult test_i32_array_copy_capped(void) {
|
||||
WpTestFuncResult test_i32_array_alloc_capacity(void) {
|
||||
b8 result;
|
||||
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(MiB(4));
|
||||
u64 capacity = 32;
|
||||
I32Array array = wapp_array_alloc_capacity(i32, &allocator, capacity, ARRAY_INIT_NONE);
|
||||
WpI32Array array = wpArrayAllocCapacity(i32, &allocator, capacity, WP_ARRAY_INIT_NONE);
|
||||
|
||||
result = array && wapp_array_capacity(array) == capacity;
|
||||
result = array && wpArrayCapacity(array) == capacity;
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -164,12 +164,12 @@ WpTestFuncResult test_i32_array_alloc_capacity(void) {
|
||||
WpTestFuncResult test_i32_array_append_alloc(void) {
|
||||
b8 result;
|
||||
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
|
||||
I32Array array1 = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
I32Array array2 = wapp_array(i32, 1, 2);
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(MiB(4));
|
||||
WpI32Array array1 = wpArray(i32, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
WpI32Array array2 = wpArray(i32, 1, 2);
|
||||
|
||||
i32 num = 10;
|
||||
I32Array arr_ptr = wapp_array_append_alloc(i32, &allocator, array1, &num, ARRAY_INIT_NONE);
|
||||
WpI32Array arr_ptr = wpArrayAppendAlloc(i32, &allocator, array1, &num, WP_ARRAY_INIT_NONE);
|
||||
result = arr_ptr == array1;
|
||||
|
||||
u64 count = 4;
|
||||
@@ -177,14 +177,14 @@ WpTestFuncResult test_i32_array_append_alloc(void) {
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
num = (i32)index;
|
||||
arr_ptr = wapp_array_append_alloc(i32, &allocator, array2, &num, ARRAY_INIT_NONE);
|
||||
arr_ptr = wpArrayAppendAlloc(i32, &allocator, array2, &num, WP_ARRAY_INIT_NONE);
|
||||
|
||||
++index;
|
||||
running = index < count;
|
||||
}
|
||||
result = result && arr_ptr != array2;
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -192,18 +192,18 @@ WpTestFuncResult test_i32_array_append_alloc(void) {
|
||||
WpTestFuncResult test_i32_array_extend_alloc(void) {
|
||||
b8 result;
|
||||
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
|
||||
I32Array array1 = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
I32Array array2 = wapp_array(i32, 1, 2);
|
||||
I32Array array3 = wapp_array(i32, 1, 2, 3, 4);
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(MiB(4));
|
||||
WpI32Array array1 = wpArray(i32, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
WpI32Array array2 = wpArray(i32, 1, 2);
|
||||
WpI32Array array3 = wpArray(i32, 1, 2, 3, 4);
|
||||
|
||||
I32Array array = wapp_array_extend_alloc(i32, &allocator, array1, array3, ARRAY_INIT_NONE);
|
||||
WpI32Array array = wpArrayExtendAlloc(i32, &allocator, array1, array3, WP_ARRAY_INIT_NONE);
|
||||
result = array == array1;
|
||||
|
||||
array = wapp_array_extend_alloc(i32, &allocator, array2, array3, ARRAY_INIT_NONE);
|
||||
array = wpArrayExtendAlloc(i32, &allocator, array2, array3, WP_ARRAY_INIT_NONE);
|
||||
result = result && array != array2;
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -211,39 +211,39 @@ WpTestFuncResult test_i32_array_extend_alloc(void) {
|
||||
WpTestFuncResult test_i32_array_copy_alloc(void) {
|
||||
b8 result;
|
||||
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(MiB(4));
|
||||
I32Array src = wapp_array(i32, 1, 2, 3, 4, 5);
|
||||
I32Array dst1 = wapp_array(i32, 1, 2, 3, 4, 5, 6);
|
||||
I32Array dst2 = wapp_array(i32, 1, 2);
|
||||
I32Array array = nullptr;
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(MiB(4));
|
||||
WpI32Array src = wpArray(i32, 1, 2, 3, 4, 5);
|
||||
WpI32Array dst1 = wpArray(i32, 1, 2, 3, 4, 5, 6);
|
||||
WpI32Array dst2 = wpArray(i32, 1, 2);
|
||||
WpI32Array array = nullptr;
|
||||
|
||||
u64 expected_count = 5;
|
||||
array = wapp_array_copy_alloc(i32, &allocator, dst1, src, ARRAY_INIT_NONE);
|
||||
result = wapp_array_count(array) == expected_count && array == dst1;
|
||||
array = wpArrayCopyAlloc(i32, &allocator, dst1, src, WP_ARRAY_INIT_NONE);
|
||||
result = wpArrayCount(array) == expected_count && array == dst1;
|
||||
|
||||
u64 index = 0;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_array_get(i32, src, index) == *wapp_array_get(i32, array, index));
|
||||
result = result && (*wpArrayGet(i32, src, index) == *wpArrayGet(i32, array, index));
|
||||
|
||||
++index;
|
||||
running = index < expected_count;
|
||||
}
|
||||
|
||||
expected_count = 5;
|
||||
array = wapp_array_copy_alloc(i32, &allocator, dst2, src, ARRAY_INIT_NONE);
|
||||
result = result && wapp_array_count(array) == expected_count && array != dst2;
|
||||
array = wpArrayCopyAlloc(i32, &allocator, dst2, src, WP_ARRAY_INIT_NONE);
|
||||
result = result && wpArrayCount(array) == expected_count && array != dst2;
|
||||
|
||||
index = 0;
|
||||
running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_array_get(i32, src, index) == *wapp_array_get(i32, array, index));
|
||||
result = result && (*wpArrayGet(i32, src, index) == *wpArrayGet(i32, array, index));
|
||||
|
||||
++index;
|
||||
running = index < expected_count;
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -251,12 +251,12 @@ WpTestFuncResult test_i32_array_copy_alloc(void) {
|
||||
WpTestFuncResult test_i32_array_clear(void) {
|
||||
b8 result;
|
||||
|
||||
I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
result = wapp_array_count(array) == 9;
|
||||
WpI32Array array = wpArray(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
result = wpArrayCount(array) == 9;
|
||||
|
||||
wapp_array_clear(i32, array);
|
||||
wpArrayClear(i32, array);
|
||||
|
||||
result = result && wapp_array_count(array) == 0;
|
||||
result = result && wpArrayCount(array) == 0;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -264,11 +264,11 @@ WpTestFuncResult test_i32_array_clear(void) {
|
||||
WpTestFuncResult test_i32_array_pop(void) {
|
||||
b8 result;
|
||||
|
||||
I32Array array1 = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
I32Array array2 = wapp_array_with_capacity(i32, 32, ARRAY_INIT_NONE);
|
||||
WpI32Array array1 = wpArray(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
WpI32Array array2 = wpArrayWithCapacity(i32, 32, WP_ARRAY_INIT_NONE);
|
||||
|
||||
i32 item1 = wapp_array_pop(i32, array1);
|
||||
i32 item2 = wapp_array_pop(i32, array2);
|
||||
i32 item1 = wpArrayPop(i32, array1);
|
||||
i32 item2 = wpArrayPop(i32, array2);
|
||||
|
||||
result = item1 == 8 && item2 == 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user