Rename arena
This commit is contained in:
@@ -10,7 +10,7 @@ wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {0};
|
||||
wp_intern WpAllocator temp_allocator = {0};
|
||||
|
||||
WpTestFuncResult test_arena_allocator(void) {
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(4096);
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(4096);
|
||||
b8 result = allocator.obj != NULL && allocator.alloc != NULL &&
|
||||
allocator.alloc_aligned != NULL &&
|
||||
allocator.realloc != NULL && allocator.realloc_aligned != NULL &&
|
||||
@@ -18,7 +18,7 @@ WpTestFuncResult test_arena_allocator(void) {
|
||||
void *ptr = wpMemAllocatorAlloc(&allocator, 20);
|
||||
result = result && (ptr != NULL);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ WpTestFuncResult test_arena_allocator(void) {
|
||||
WpTestFuncResult test_arena_allocator_with_buffer(void) {
|
||||
u8 buffer[KiB(4)] = {0};
|
||||
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init_with_buffer(buffer, KiB(4));
|
||||
WpAllocator allocator = wpMemArenaAllocatorInitWithBuffer(buffer, KiB(4));
|
||||
b8 result = allocator.obj != NULL && allocator.alloc != NULL &&
|
||||
allocator.alloc_aligned != NULL &&
|
||||
allocator.realloc != NULL && allocator.realloc_aligned != NULL &&
|
||||
@@ -34,18 +34,18 @@ WpTestFuncResult test_arena_allocator_with_buffer(void) {
|
||||
void *ptr = wpMemAllocatorAlloc(&allocator, 20);
|
||||
result = result && (ptr != NULL);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_allocator_temp_begin(void) {
|
||||
temp_allocator = wapp_mem_arena_allocator_init_with_buffer(temp_buf, TEMP_BUF_SIZE);
|
||||
temp_allocator = wpMemArenaAllocatorInitWithBuffer(temp_buf, TEMP_BUF_SIZE);
|
||||
|
||||
i32 *num1 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
|
||||
b8 result = num1 != NULL;
|
||||
|
||||
wapp_mem_arena_allocator_temp_begin(&temp_allocator);
|
||||
wpMemArenaAllocatorTempBegin(&temp_allocator);
|
||||
i32 *num2 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
|
||||
result = result && num2 != NULL;
|
||||
i32 *num3 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
|
||||
@@ -55,13 +55,13 @@ WpTestFuncResult test_arena_allocator_temp_begin(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_allocator_temp_end(void) {
|
||||
wapp_mem_arena_allocator_temp_end(&temp_allocator);
|
||||
wpMemArenaAllocatorTempEnd(&temp_allocator);
|
||||
i32 *num1 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
|
||||
b8 result = num1 != NULL;
|
||||
i32 *num2 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
|
||||
result = result && num2 == NULL;
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&temp_allocator);
|
||||
wpMemArenaAllocatorDestroy(&temp_allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {};
|
||||
wp_intern WpAllocator temp_allocator = {};
|
||||
|
||||
WpTestFuncResult test_arena_allocator(void) {
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(4096);
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(4096);
|
||||
b8 result = allocator.obj != nullptr && allocator.alloc != nullptr &&
|
||||
allocator.alloc_aligned != nullptr &&
|
||||
allocator.realloc != nullptr && allocator.realloc_aligned != nullptr &&
|
||||
@@ -18,7 +18,7 @@ WpTestFuncResult test_arena_allocator(void) {
|
||||
void *ptr = wpMemAllocatorAlloc(&allocator, 20);
|
||||
result = result && (ptr != nullptr);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ WpTestFuncResult test_arena_allocator(void) {
|
||||
WpTestFuncResult test_arena_allocator_with_buffer(void) {
|
||||
u8 buffer[KiB(4)] = {0};
|
||||
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init_with_buffer(buffer, KiB(4));
|
||||
WpAllocator allocator = wpMemArenaAllocatorInitWithBuffer(buffer, KiB(4));
|
||||
b8 result = allocator.obj != NULL && allocator.alloc != NULL &&
|
||||
allocator.alloc_aligned != NULL &&
|
||||
allocator.realloc != NULL && allocator.realloc_aligned != NULL &&
|
||||
@@ -34,18 +34,18 @@ WpTestFuncResult test_arena_allocator_with_buffer(void) {
|
||||
void *ptr = wpMemAllocatorAlloc(&allocator, 20);
|
||||
result = result && (ptr != NULL);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_allocator_temp_begin(void) {
|
||||
temp_allocator = wapp_mem_arena_allocator_init_with_buffer(temp_buf, TEMP_BUF_SIZE);
|
||||
temp_allocator = wpMemArenaAllocatorInitWithBuffer(temp_buf, TEMP_BUF_SIZE);
|
||||
|
||||
i32 *num1 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
|
||||
b8 result = num1 != NULL;
|
||||
|
||||
wapp_mem_arena_allocator_temp_begin(&temp_allocator);
|
||||
wpMemArenaAllocatorTempBegin(&temp_allocator);
|
||||
i32 *num2 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
|
||||
result = result && num2 != NULL;
|
||||
i32 *num3 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
|
||||
@@ -55,13 +55,13 @@ WpTestFuncResult test_arena_allocator_temp_begin(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_allocator_temp_end(void) {
|
||||
wapp_mem_arena_allocator_temp_end(&temp_allocator);
|
||||
wpMemArenaAllocatorTempEnd(&temp_allocator);
|
||||
i32 *num1 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
|
||||
b8 result = num1 != NULL;
|
||||
i32 *num2 = (i32 *)wpMemAllocatorAlloc(&temp_allocator, sizeof(i32));
|
||||
result = result && num2 == NULL;
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&temp_allocator);
|
||||
wpMemArenaAllocatorDestroy(&temp_allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
+28
-28
@@ -4,42 +4,42 @@
|
||||
|
||||
#define ARENA_CAPACITY KiB(16)
|
||||
#define ARENA_BUF_SIZE KiB(4)
|
||||
// NOTE (Abdelrahman): Cannot query size of Arena here so it's hardcoded. Similarly, since arena
|
||||
// NOTE (Abdelrahman): Cannot query size of WpArena here so it's hardcoded. Similarly, since arena
|
||||
// allocation are aligned to power of 2 boundaries, the number of i32 values needed is hardcoded.
|
||||
#define TEMP_BUF_SIZE (40 + sizeof(i32) * 8)
|
||||
|
||||
wp_intern Arena *arena = NULL;
|
||||
wp_intern WpArena *arena = NULL;
|
||||
wp_intern i32 count = 20;
|
||||
wp_intern i32 *array = NULL;
|
||||
wp_intern Arena *buf_arena = NULL;
|
||||
wp_intern WpArena *buf_arena = NULL;
|
||||
wp_intern u8 buf[ARENA_BUF_SIZE] = {0};
|
||||
wp_intern Arena *temp_arena = NULL;
|
||||
wp_intern WpArena *temp_arena = NULL;
|
||||
wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {0};
|
||||
|
||||
WpTestFuncResult test_arena_init_buffer(void) {
|
||||
b8 result = wapp_mem_arena_init_buffer(&buf_arena, buf, ARENA_BUF_SIZE);
|
||||
b8 result = wpMemArenaInitBuffer(&buf_arena, buf, ARENA_BUF_SIZE);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_init_allocated(void) {
|
||||
b8 result = wapp_mem_arena_init_allocated(&arena, ARENA_CAPACITY);
|
||||
b8 result = wpMemArenaInitAllocated(&arena, ARENA_CAPACITY);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
||||
Arena *large_arena = NULL;
|
||||
WpArena *large_arena = NULL;
|
||||
u64 capacity = GiB(512);
|
||||
b8 result = wapp_mem_arena_init_allocated(&large_arena, capacity);
|
||||
b8 result = wpMemArenaInitAllocated(&large_arena, capacity);
|
||||
if (result) {
|
||||
wapp_mem_arena_destroy(&large_arena);
|
||||
wpMemArenaDestroy(&large_arena);
|
||||
}
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_alloc_with_buffer(void) {
|
||||
i32 *arr = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
i32 *arr = (i32 *)wpMemArenaAlloc(arena, count * sizeof(i32));
|
||||
b8 result = arr != NULL;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
@@ -50,7 +50,7 @@ WpTestFuncResult test_arena_alloc_with_buffer(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
array = wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
array = wpMemArenaAlloc(arena, count * sizeof(i32));
|
||||
b8 result = array != NULL;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
@@ -61,7 +61,7 @@ WpTestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
|
||||
u8 *bytes = wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2);
|
||||
u8 *bytes = wpMemArenaAlloc(arena, ARENA_CAPACITY * 2);
|
||||
b8 result = bytes == NULL;
|
||||
|
||||
return wpTesterResult(result);
|
||||
@@ -70,13 +70,13 @@ WpTestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
|
||||
WpTestFuncResult test_arena_realloc_bigger_size(void) {
|
||||
u64 old_count = 10;
|
||||
u64 new_count = 20;
|
||||
i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
|
||||
i32 *bytes = wpMemArenaAlloc(arena, old_count * sizeof(i32));
|
||||
|
||||
for (u64 i = 0; i < old_count; ++i) {
|
||||
bytes[i] = (i32)i;
|
||||
}
|
||||
|
||||
i32 *new_bytes = wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
i32 *new_bytes = wpMemArenaRealloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
if (!new_bytes) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -93,13 +93,13 @@ WpTestFuncResult test_arena_realloc_bigger_size(void) {
|
||||
WpTestFuncResult test_arena_realloc_smaller_size(void) {
|
||||
u64 old_count = 10;
|
||||
u64 new_count = 5;
|
||||
i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
|
||||
i32 *bytes = wpMemArenaAlloc(arena, old_count * sizeof(i32));
|
||||
|
||||
for (u64 i = 0; i < old_count; ++i) {
|
||||
bytes[i] = (i32)i;
|
||||
}
|
||||
|
||||
i32 *new_bytes = wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
i32 *new_bytes = wpMemArenaRealloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
if (!new_bytes) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -114,33 +114,33 @@ WpTestFuncResult test_arena_realloc_smaller_size(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_temp_begin(void) {
|
||||
b8 result = wapp_mem_arena_init_buffer(&temp_arena, temp_buf, TEMP_BUF_SIZE);
|
||||
i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
b8 result = wpMemArenaInitBuffer(&temp_arena, temp_buf, TEMP_BUF_SIZE);
|
||||
i32 *num1 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num1 != NULL;
|
||||
|
||||
wapp_mem_arena_temp_begin(temp_arena);
|
||||
i32 *num2 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
wpMemArenaTempBegin(temp_arena);
|
||||
i32 *num2 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num2 != NULL;
|
||||
i32 *num3 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
i32 *num3 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num3 == NULL;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_temp_end(void) {
|
||||
wapp_mem_arena_temp_end(temp_arena);
|
||||
i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
wpMemArenaTempEnd(temp_arena);
|
||||
i32 *num1 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
b8 result = num1 != NULL;
|
||||
i32 *num2 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
i32 *num2 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num2 == NULL;
|
||||
|
||||
wapp_mem_arena_destroy(&temp_arena);
|
||||
wpMemArenaDestroy(&temp_arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_clear(void) {
|
||||
wapp_mem_arena_clear(arena);
|
||||
wpMemArenaClear(arena);
|
||||
b8 result = true;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
@@ -154,14 +154,14 @@ WpTestFuncResult test_arena_clear(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_destroy_buffer(void) {
|
||||
wapp_mem_arena_destroy(&buf_arena);
|
||||
wpMemArenaDestroy(&buf_arena);
|
||||
b8 result = buf_arena == NULL;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_destroy_allocated(void) {
|
||||
wapp_mem_arena_destroy(&arena);
|
||||
wpMemArenaDestroy(&arena);
|
||||
b8 result = arena == NULL;
|
||||
|
||||
return wpTesterResult(result);
|
||||
|
||||
+28
-28
@@ -4,42 +4,42 @@
|
||||
|
||||
#define ARENA_CAPACITY KiB(16)
|
||||
#define ARENA_BUF_SIZE KiB(4)
|
||||
// NOTE (Abdelrahman): Cannot query size of Arena here so it's hardcoded. Similarly, since arena
|
||||
// NOTE (Abdelrahman): Cannot query size of WpArena here so it's hardcoded. Similarly, since arena
|
||||
// allocation are aligned to power of 2 boundaries, the number of i32 values needed is hardcoded.
|
||||
#define TEMP_BUF_SIZE (40 + sizeof(i32) * 8)
|
||||
|
||||
wp_intern Arena *arena = NULL;
|
||||
wp_intern WpArena *arena = NULL;
|
||||
wp_intern i32 count = 20;
|
||||
wp_intern i32 *array = NULL;
|
||||
wp_intern Arena *buf_arena = NULL;
|
||||
wp_intern WpArena *buf_arena = NULL;
|
||||
wp_intern u8 buf[ARENA_BUF_SIZE] = {};
|
||||
wp_intern Arena *temp_arena = NULL;
|
||||
wp_intern WpArena *temp_arena = NULL;
|
||||
wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {};
|
||||
|
||||
WpTestFuncResult test_arena_init_buffer(void) {
|
||||
b8 result = wapp_mem_arena_init_buffer(&buf_arena, buf, ARENA_BUF_SIZE);
|
||||
b8 result = wpMemArenaInitBuffer(&buf_arena, buf, ARENA_BUF_SIZE);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_init_allocated(void) {
|
||||
b8 result = wapp_mem_arena_init_allocated(&arena, ARENA_CAPACITY);
|
||||
b8 result = wpMemArenaInitAllocated(&arena, ARENA_CAPACITY);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
||||
Arena *large_arena = nullptr;
|
||||
WpArena *large_arena = nullptr;
|
||||
u64 capacity = GiB(512);
|
||||
b8 result = wapp_mem_arena_init_allocated(&large_arena, capacity);
|
||||
b8 result = wpMemArenaInitAllocated(&large_arena, capacity);
|
||||
if (result) {
|
||||
wapp_mem_arena_destroy(&large_arena);
|
||||
wpMemArenaDestroy(&large_arena);
|
||||
}
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_alloc_with_buffer(void) {
|
||||
i32 *arr = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
i32 *arr = (i32 *)wpMemArenaAlloc(arena, count * sizeof(i32));
|
||||
b8 result = arr != NULL;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
@@ -50,7 +50,7 @@ WpTestFuncResult test_arena_alloc_with_buffer(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
array = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
array = (i32 *)wpMemArenaAlloc(arena, count * sizeof(i32));
|
||||
b8 result = array != nullptr;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
@@ -61,7 +61,7 @@ WpTestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
|
||||
u8 *bytes = (u8 *)wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2);
|
||||
u8 *bytes = (u8 *)wpMemArenaAlloc(arena, ARENA_CAPACITY * 2);
|
||||
b8 result = bytes == nullptr;
|
||||
|
||||
return wpTesterResult(result);
|
||||
@@ -70,13 +70,13 @@ WpTestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
|
||||
WpTestFuncResult test_arena_realloc_bigger_size(void) {
|
||||
u64 old_count = 10;
|
||||
u64 new_count = 20;
|
||||
i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
|
||||
i32 *bytes = (i32 *)wpMemArenaAlloc(arena, old_count * sizeof(i32));
|
||||
|
||||
for (u64 i = 0; i < old_count; ++i) {
|
||||
bytes[i] = (i32)i;
|
||||
}
|
||||
|
||||
i32 *new_bytes = (i32 *)wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
i32 *new_bytes = (i32 *)wpMemArenaRealloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
if (!new_bytes) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -93,13 +93,13 @@ WpTestFuncResult test_arena_realloc_bigger_size(void) {
|
||||
WpTestFuncResult test_arena_realloc_smaller_size(void) {
|
||||
u64 old_count = 10;
|
||||
u64 new_count = 5;
|
||||
i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
|
||||
i32 *bytes = (i32 *)wpMemArenaAlloc(arena, old_count * sizeof(i32));
|
||||
|
||||
for (u64 i = 0; i < old_count; ++i) {
|
||||
bytes[i] = (i32)i;
|
||||
}
|
||||
|
||||
i32 *new_bytes = (i32 *)wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
i32 *new_bytes = (i32 *)wpMemArenaRealloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
|
||||
if (!new_bytes) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -114,33 +114,33 @@ WpTestFuncResult test_arena_realloc_smaller_size(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_temp_begin(void) {
|
||||
b8 result = wapp_mem_arena_init_buffer(&temp_arena, temp_buf, TEMP_BUF_SIZE);
|
||||
i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
b8 result = wpMemArenaInitBuffer(&temp_arena, temp_buf, TEMP_BUF_SIZE);
|
||||
i32 *num1 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num1 != NULL;
|
||||
|
||||
wapp_mem_arena_temp_begin(temp_arena);
|
||||
i32 *num2 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
wpMemArenaTempBegin(temp_arena);
|
||||
i32 *num2 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num2 != NULL;
|
||||
i32 *num3 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
i32 *num3 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num3 == NULL;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_temp_end(void) {
|
||||
wapp_mem_arena_temp_end(temp_arena);
|
||||
i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
wpMemArenaTempEnd(temp_arena);
|
||||
i32 *num1 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
b8 result = num1 != NULL;
|
||||
i32 *num2 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
|
||||
i32 *num2 = (i32 *)wpMemArenaAlloc(temp_arena, sizeof(i32));
|
||||
result = result && num2 == NULL;
|
||||
|
||||
wapp_mem_arena_destroy(&temp_arena);
|
||||
wpMemArenaDestroy(&temp_arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_clear(void) {
|
||||
wapp_mem_arena_clear(arena);
|
||||
wpMemArenaClear(arena);
|
||||
b8 result = true;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
@@ -154,14 +154,14 @@ WpTestFuncResult test_arena_clear(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_destroy_buffer(void) {
|
||||
wapp_mem_arena_destroy(&buf_arena);
|
||||
wpMemArenaDestroy(&buf_arena);
|
||||
b8 result = buf_arena == NULL;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_arena_destroy_allocated(void) {
|
||||
wapp_mem_arena_destroy(&arena);
|
||||
wpMemArenaDestroy(&arena);
|
||||
b8 result = arena == nullptr;
|
||||
|
||||
return wpTesterResult(result);
|
||||
|
||||
@@ -23,7 +23,7 @@ WpTestFuncResult test_queue_push(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_queue_push_alloc(void) {
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(MiB(64));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(MiB(64));
|
||||
WpI32Queue queue = wpQueue(i32, CAPACITY);
|
||||
|
||||
for (u64 i = 0; i < CAPACITY; ++i) {
|
||||
@@ -65,7 +65,7 @@ WpTestFuncResult test_queue_push_alloc(void) {
|
||||
result = result && arr[i] == (i32)(2 + i);
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ WpTestFuncResult test_queue_push(void) {
|
||||
}
|
||||
|
||||
WpTestFuncResult test_queue_push_alloc(void) {
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(MiB(64));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(MiB(64));
|
||||
WpI32Queue queue = wpQueue(i32, CAPACITY);
|
||||
|
||||
for (u64 i = 0; i < CAPACITY; ++i) {
|
||||
@@ -63,7 +63,7 @@ WpTestFuncResult test_queue_push_alloc(void) {
|
||||
result = result && arr[i] == (i32)(2 + i);
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
+28
-28
@@ -77,7 +77,7 @@ WpTestFuncResult test_str8_buf(void) {
|
||||
|
||||
WpTestFuncResult test_str8_alloc_buf(void) {
|
||||
b8 result;
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(KiB(100));
|
||||
if (wpMemAllocatorInvalid(&allocator)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -98,14 +98,14 @@ WpTestFuncResult test_str8_alloc_buf(void) {
|
||||
result = result && s->capacity == capacity && s->size == strlen(cstr) && memcmp(s->buf, cstr, s->size) == 0;
|
||||
|
||||
TEST_ALLOC_BUF_CLEANUP:
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_alloc_cstr(void) {
|
||||
b8 result;
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(KiB(100));
|
||||
if (wpMemAllocatorInvalid(&allocator)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -119,14 +119,14 @@ WpTestFuncResult test_str8_alloc_cstr(void) {
|
||||
|
||||
result = s->size == length && memcmp(s->buf, str, length) == 0;
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_alloc_str8(void) {
|
||||
b8 result;
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(KiB(100));
|
||||
if (wpMemAllocatorInvalid(&allocator)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -139,14 +139,14 @@ WpTestFuncResult test_str8_alloc_str8(void) {
|
||||
|
||||
result = wpStr8Equal(s, &str);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_alloc_substr(void) {
|
||||
b8 result;
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(KiB(100));
|
||||
if (wpMemAllocatorInvalid(&allocator)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ WpTestFuncResult test_str8_alloc_substr(void) {
|
||||
|
||||
result = s->size == 5 && memcmp(s->buf, "elrah", s->size) == 0;
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -289,7 +289,7 @@ WpTestFuncResult test_str8_slice(void) {
|
||||
|
||||
WpTestFuncResult test_str8_alloc_concat(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("Hello world");
|
||||
WpStr8 suffix1 = wpStr8Lit(" from me.");
|
||||
@@ -305,7 +305,7 @@ WpTestFuncResult test_str8_alloc_concat(void) {
|
||||
output = wpStr8AllocConcat(&arena, output, &suffix2);
|
||||
result = result && output->size == concat2.size && wpStr8Equal(output, &concat2);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -410,7 +410,7 @@ WpTestFuncResult test_str8_rfind(void) {
|
||||
|
||||
WpTestFuncResult test_str8_split(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("hello world from me");
|
||||
WpStr8 delim1 = wpStr8Lit(" ");
|
||||
@@ -443,7 +443,7 @@ WpTestFuncResult test_str8_split(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running1) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list1, index1);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list1, index1);
|
||||
result = result && wpStr8Equal(node, &(splits1[index1]));
|
||||
|
||||
++index1;
|
||||
@@ -453,21 +453,21 @@ WpTestFuncResult test_str8_split(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running2) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list2, index2);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list2, index2);
|
||||
result = result && wpStr8Equal(node, &(splits2[index2]));
|
||||
|
||||
++index2;
|
||||
running2 = index2 < count2;
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_split_with_max(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("hello world from me");
|
||||
WpStr8 delim = wpStr8Lit(" ");
|
||||
@@ -488,21 +488,21 @@ WpTestFuncResult test_str8_split_with_max(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list, index);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list, index);
|
||||
result = result && wpStr8Equal(node, &(splits[index]));
|
||||
|
||||
++index;
|
||||
running = index < count;
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_rsplit(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("hello world from me");
|
||||
WpStr8 delim1 = wpStr8Lit(" ");
|
||||
@@ -535,7 +535,7 @@ WpTestFuncResult test_str8_rsplit(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running1) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list1, index1);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list1, index1);
|
||||
result = result && wpStr8Equal(node, &(splits1[index1]));
|
||||
|
||||
++index1;
|
||||
@@ -545,21 +545,21 @@ WpTestFuncResult test_str8_rsplit(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running2) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list2, index2);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list2, index2);
|
||||
result = result && wpStr8Equal(node, &(splits2[index2]));
|
||||
|
||||
++index2;
|
||||
running2 = index2 < count2;
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_rsplit_with_max(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("hello world from me");
|
||||
WpStr8 delim = wpStr8Lit(" ");
|
||||
@@ -580,21 +580,21 @@ WpTestFuncResult test_str8_rsplit_with_max(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list, index);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list, index);
|
||||
result = result && wpStr8Equal(node, &(splits[index]));
|
||||
|
||||
++index;
|
||||
running = index < count;
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_join(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("hello world from me");
|
||||
WpStr8 delim1 = wpStr8Lit(" ");
|
||||
@@ -607,7 +607,7 @@ WpTestFuncResult test_str8_join(void) {
|
||||
result = join1->size == str.size && wpStr8Equal(join1, &str);
|
||||
result = result && join2->size == str.size && wpStr8Equal(join2, &str);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -616,10 +616,10 @@ WpTestFuncResult test_str8_from_bytes(void) {
|
||||
b8 result;
|
||||
|
||||
WpStr8 str = wpStr8Buf(1024);
|
||||
U8Array bytes = wapp_array(u8, 'W', 'A', 'P', 'P');
|
||||
WpU8Array bytes = wpArray(u8, 'W', 'A', 'P', 'P');
|
||||
wpStr8FromBytes(&str, bytes);
|
||||
|
||||
result = str.size == wapp_array_count(bytes) * wapp_array_item_size(bytes);
|
||||
result = str.size == wpArrayCount(bytes) * wpArrayItemSize(bytes);
|
||||
result = result && wpStr8Equal(&str, &wpStr8LitRo("WAPP"));
|
||||
|
||||
return wpTesterResult(result);
|
||||
|
||||
+29
-29
@@ -77,7 +77,7 @@ WpTestFuncResult test_str8_buf(void) {
|
||||
|
||||
WpTestFuncResult test_str8_alloc_buf(void) {
|
||||
b8 result;
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(KiB(100));
|
||||
if (wpMemAllocatorInvalid(&allocator)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ WpTestFuncResult test_str8_alloc_buf(void) {
|
||||
WpStr8 *s = wpStr8AllocBuf(&allocator, capacity);
|
||||
if (!s) {
|
||||
result = false;
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
@@ -98,14 +98,14 @@ WpTestFuncResult test_str8_alloc_buf(void) {
|
||||
|
||||
result = result && s->capacity == capacity && s->size == strlen(cstr) && memcmp(s->buf, cstr, s->size) == 0;
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_alloc_cstr(void) {
|
||||
b8 result;
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(KiB(100));
|
||||
if (wpMemAllocatorInvalid(&allocator)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -119,14 +119,14 @@ WpTestFuncResult test_str8_alloc_cstr(void) {
|
||||
|
||||
result = s->size == length && memcmp(s->buf, str, length) == 0;
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_alloc_str8(void) {
|
||||
b8 result;
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(KiB(100));
|
||||
if (wpMemAllocatorInvalid(&allocator)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -139,14 +139,14 @@ WpTestFuncResult test_str8_alloc_str8(void) {
|
||||
|
||||
result = wpStr8Equal(s, &str);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_alloc_substr(void) {
|
||||
b8 result;
|
||||
WpAllocator allocator = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator allocator = wpMemArenaAllocatorInit(KiB(100));
|
||||
if (wpMemAllocatorInvalid(&allocator)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ WpTestFuncResult test_str8_alloc_substr(void) {
|
||||
|
||||
result = s->size == 5 && memcmp(s->buf, "elrah", s->size) == 0;
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
wpMemArenaAllocatorDestroy(&allocator);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -289,7 +289,7 @@ WpTestFuncResult test_str8_slice(void) {
|
||||
|
||||
WpTestFuncResult test_str8_alloc_concat(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("Hello world");
|
||||
WpStr8 suffix1 = wpStr8Lit(" from me.");
|
||||
@@ -305,7 +305,7 @@ WpTestFuncResult test_str8_alloc_concat(void) {
|
||||
output = wpStr8AllocConcat(&arena, output, &suffix2);
|
||||
result = result && output->size == concat2.size && wpStr8Equal(output, &concat2);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -410,7 +410,7 @@ WpTestFuncResult test_str8_rfind(void) {
|
||||
|
||||
WpTestFuncResult test_str8_split(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("hello world from me");
|
||||
WpStr8 delim1 = wpStr8Lit(" ");
|
||||
@@ -443,7 +443,7 @@ WpTestFuncResult test_str8_split(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running1) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list1, index1);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list1, index1);
|
||||
result = result && wpStr8Equal(node, &(splits1[index1]));
|
||||
|
||||
++index1;
|
||||
@@ -453,21 +453,21 @@ WpTestFuncResult test_str8_split(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running2) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list2, index2);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list2, index2);
|
||||
result = result && wpStr8Equal(node, &(splits2[index2]));
|
||||
|
||||
++index2;
|
||||
running2 = index2 < count2;
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_split_with_max(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("hello world from me");
|
||||
WpStr8 delim = wpStr8Lit(" ");
|
||||
@@ -488,21 +488,21 @@ WpTestFuncResult test_str8_split_with_max(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list, index);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list, index);
|
||||
result = result && wpStr8Equal(node, &(splits[index]));
|
||||
|
||||
++index;
|
||||
running = index < count;
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_rsplit(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("hello world from me");
|
||||
WpStr8 delim1 = wpStr8Lit(" ");
|
||||
@@ -535,7 +535,7 @@ WpTestFuncResult test_str8_rsplit(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running1) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list1, index1);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list1, index1);
|
||||
result = result && wpStr8Equal(node, &(splits1[index1]));
|
||||
|
||||
++index1;
|
||||
@@ -545,21 +545,21 @@ WpTestFuncResult test_str8_rsplit(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running2) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list2, index2);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list2, index2);
|
||||
result = result && wpStr8Equal(node, &(splits2[index2]));
|
||||
|
||||
++index2;
|
||||
running2 = index2 < count2;
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_rsplit_with_max(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("hello world from me");
|
||||
WpStr8 delim = wpStr8Lit(" ");
|
||||
@@ -580,21 +580,21 @@ WpTestFuncResult test_str8_rsplit_with_max(void) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
while (running) {
|
||||
WpStr8 *node = wapp_dbl_list_get(WpStr8, list, index);
|
||||
WpStr8 *node = wpDblListGet(WpStr8, list, index);
|
||||
result = result && wpStr8Equal(node, &(splits[index]));
|
||||
|
||||
++index;
|
||||
running = index < count;
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_str8_join(void) {
|
||||
b8 result;
|
||||
WpAllocator arena = wapp_mem_arena_allocator_init(KiB(100));
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(KiB(100));
|
||||
|
||||
WpStr8 str = wpStr8Lit("hello world from me");
|
||||
WpStr8 delim1 = wpStr8Lit(" ");
|
||||
@@ -607,7 +607,7 @@ WpTestFuncResult test_str8_join(void) {
|
||||
result = join1->size == str.size && wpStr8Equal(join1, &str);
|
||||
result = result && join2->size == str.size && wpStr8Equal(join2, &str);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -617,10 +617,10 @@ WpTestFuncResult test_str8_from_bytes(void) {
|
||||
|
||||
WpStr8 str = wpStr8Buf(1024);
|
||||
WpStr8 expected = wpStr8LitRo("WAPP");
|
||||
U8Array bytes = wapp_array(u8, 'W', 'A', 'P', 'P');
|
||||
WpU8Array bytes = wpArray(u8, 'W', 'A', 'P', 'P');
|
||||
wpStr8FromBytes(&str, bytes);
|
||||
|
||||
result = str.size == wapp_array_count(bytes) * wapp_array_item_size(bytes);
|
||||
result = str.size == wpArrayCount(bytes) * wpArrayItemSize(bytes);
|
||||
result = result && wpStr8Equal(&str, &expected);
|
||||
|
||||
return wpTesterResult(result);
|
||||
|
||||
Reference in New Issue
Block a user