Reformat tests

This commit is contained in:
2025-12-29 22:39:52 +00:00
parent b2419475aa
commit 3efeef13c6
18 changed files with 2144 additions and 2144 deletions

View File

@@ -3,15 +3,15 @@
#include <stdlib.h> #include <stdlib.h>
TestFuncResult test_arena_allocator(void) { TestFuncResult test_arena_allocator(void) {
Allocator allocator = wapp_mem_arena_allocator_init(4096); Allocator allocator = wapp_mem_arena_allocator_init(4096);
b8 result = allocator.obj != NULL && allocator.alloc != NULL && b8 result = allocator.obj != NULL && allocator.alloc != NULL &&
allocator.alloc_aligned != NULL && allocator.alloc_aligned != NULL &&
allocator.realloc != NULL && allocator.realloc_aligned != NULL && allocator.realloc != NULL && allocator.realloc_aligned != NULL &&
allocator.free == NULL; allocator.free == NULL;
void *ptr = wapp_mem_allocator_alloc(&allocator, 20); void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
result = result && (ptr != NULL); result = result && (ptr != NULL);
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -3,15 +3,15 @@
#include <stdlib.h> #include <stdlib.h>
TestFuncResult test_arena_allocator(void) { TestFuncResult test_arena_allocator(void) {
Allocator allocator = wapp_mem_arena_allocator_init(4096); Allocator allocator = wapp_mem_arena_allocator_init(4096);
b8 result = allocator.obj != nullptr && allocator.alloc != nullptr && b8 result = allocator.obj != nullptr && allocator.alloc != nullptr &&
allocator.alloc_aligned != nullptr && allocator.alloc_aligned != nullptr &&
allocator.realloc != nullptr && allocator.realloc_aligned != nullptr && allocator.realloc != nullptr && allocator.realloc_aligned != nullptr &&
allocator.free == nullptr; allocator.free == nullptr;
void *ptr = wapp_mem_allocator_alloc(&allocator, 20); void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
result = result && (ptr != nullptr); result = result && (ptr != nullptr);
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -4,108 +4,108 @@
#define ARENA_CAPACITY KiB(16) #define ARENA_CAPACITY KiB(16)
wapp_intern Arena *arena = NULL; wapp_intern Arena *arena = NULL;
wapp_intern i32 count = 20; wapp_intern i32 count = 20;
wapp_intern i32 *array = NULL; wapp_intern i32 *array = NULL;
TestFuncResult test_arena_init(void) { TestFuncResult test_arena_init(void) {
b8 result = wapp_mem_arena_init(&arena, ARENA_CAPACITY); b8 result = wapp_mem_arena_init(&arena, ARENA_CAPACITY);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) { TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
Arena *large_arena = NULL; Arena *large_arena = NULL;
u64 capacity = GiB(512); u64 capacity = GiB(512);
b8 result = wapp_mem_arena_init(&large_arena, capacity); b8 result = wapp_mem_arena_init(&large_arena, capacity);
if (result) { if (result) {
wapp_mem_arena_destroy(&large_arena); wapp_mem_arena_destroy(&large_arena);
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) { TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
array = wapp_mem_arena_alloc(arena, count * sizeof(i32)); array = wapp_mem_arena_alloc(arena, count * sizeof(i32));
b8 result = array != NULL; b8 result = array != NULL;
for (i32 i = 0; i < count; ++i) { for (i32 i = 0; i < count; ++i) {
array[i] = i * 10; array[i] = i * 10;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_arena_alloc_fails_when_over_capacity(void) { TestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
u8 *bytes = wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2); u8 *bytes = wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2);
b8 result = bytes == NULL; b8 result = bytes == NULL;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_arena_realloc_bigger_size(void) { TestFuncResult test_arena_realloc_bigger_size(void) {
u64 old_count = 10; u64 old_count = 10;
u64 new_count = 20; u64 new_count = 20;
i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
for (u64 i = 0; i < old_count; ++i) { for (u64 i = 0; i < old_count; ++i) {
bytes[i] = (i32)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 = wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
if (!new_bytes) { if (!new_bytes) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
for (u64 i = 0; i < new_count; ++i) { for (u64 i = 0; i < new_count; ++i) {
if (i < old_count && new_bytes[i] != bytes[i]) { if (i < old_count && new_bytes[i] != bytes[i]) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
} }
return wapp_tester_result(true); return wapp_tester_result(true);
} }
TestFuncResult test_arena_realloc_smaller_size(void) { TestFuncResult test_arena_realloc_smaller_size(void) {
u64 old_count = 10; u64 old_count = 10;
u64 new_count = 5; u64 new_count = 5;
i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
for (u64 i = 0; i < old_count; ++i) { for (u64 i = 0; i < old_count; ++i) {
bytes[i] = (i32)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 = wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
if (!new_bytes) { if (!new_bytes) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
for (u64 i = 0; i < new_count; ++i) { for (u64 i = 0; i < new_count; ++i) {
if (i < new_count && new_bytes[i] != bytes[i]) { if (i < new_count && new_bytes[i] != bytes[i]) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
} }
return wapp_tester_result(true); return wapp_tester_result(true);
} }
TestFuncResult test_arena_clear(void) { TestFuncResult test_arena_clear(void) {
wapp_mem_arena_clear(arena); wapp_mem_arena_clear(arena);
b8 result = true; b8 result = true;
for (i32 i = 0; i < count; ++i) { for (i32 i = 0; i < count; ++i) {
if (array[i] != 0) { if (array[i] != 0) {
result = false; result = false;
break; break;
} }
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_arena_destroy(void) { TestFuncResult test_arena_destroy(void) {
wapp_mem_arena_destroy(&arena); wapp_mem_arena_destroy(&arena);
b8 result = arena == NULL; b8 result = arena == NULL;
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -4,108 +4,108 @@
#define ARENA_CAPACITY KiB(16) #define ARENA_CAPACITY KiB(16)
wapp_intern Arena *arena = nullptr; wapp_intern Arena *arena = nullptr;
wapp_intern i32 count = 20; wapp_intern i32 count = 20;
wapp_intern i32 *array = nullptr; wapp_intern i32 *array = nullptr;
TestFuncResult test_arena_init(void) { TestFuncResult test_arena_init(void) {
b8 result = wapp_mem_arena_init(&arena, ARENA_CAPACITY); b8 result = wapp_mem_arena_init(&arena, ARENA_CAPACITY);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) { TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
Arena *large_arena = nullptr; Arena *large_arena = nullptr;
u64 capacity = GiB(512); u64 capacity = GiB(512);
b8 result = wapp_mem_arena_init(&large_arena, capacity); b8 result = wapp_mem_arena_init(&large_arena, capacity);
if (result) { if (result) {
wapp_mem_arena_destroy(&large_arena); wapp_mem_arena_destroy(&large_arena);
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) { TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
array = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32)); array = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32));
b8 result = array != nullptr; b8 result = array != nullptr;
for (i32 i = 0; i < count; ++i) { for (i32 i = 0; i < count; ++i) {
array[i] = i * 10; array[i] = i * 10;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_arena_alloc_fails_when_over_capacity(void) { TestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
u8 *bytes = (u8 *)wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2); u8 *bytes = (u8 *)wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2);
b8 result = bytes == nullptr; b8 result = bytes == nullptr;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_arena_realloc_bigger_size(void) { TestFuncResult test_arena_realloc_bigger_size(void) {
u64 old_count = 10; u64 old_count = 10;
u64 new_count = 20; u64 new_count = 20;
i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
for (u64 i = 0; i < old_count; ++i) { for (u64 i = 0; i < old_count; ++i) {
bytes[i] = (i32)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 *)wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
if (!new_bytes) { if (!new_bytes) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
for (u64 i = 0; i < new_count; ++i) { for (u64 i = 0; i < new_count; ++i) {
if (i < old_count && new_bytes[i] != bytes[i]) { if (i < old_count && new_bytes[i] != bytes[i]) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
} }
return wapp_tester_result(true); return wapp_tester_result(true);
} }
TestFuncResult test_arena_realloc_smaller_size(void) { TestFuncResult test_arena_realloc_smaller_size(void) {
u64 old_count = 10; u64 old_count = 10;
u64 new_count = 5; u64 new_count = 5;
i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
for (u64 i = 0; i < old_count; ++i) { for (u64 i = 0; i < old_count; ++i) {
bytes[i] = (i32)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 *)wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
if (!new_bytes) { if (!new_bytes) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
for (u64 i = 0; i < new_count; ++i) { for (u64 i = 0; i < new_count; ++i) {
if (i < new_count && new_bytes[i] != bytes[i]) { if (i < new_count && new_bytes[i] != bytes[i]) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
} }
return wapp_tester_result(true); return wapp_tester_result(true);
} }
TestFuncResult test_arena_clear(void) { TestFuncResult test_arena_clear(void) {
wapp_mem_arena_clear(arena); wapp_mem_arena_clear(arena);
b8 result = true; b8 result = true;
for (i32 i = 0; i < count; ++i) { for (i32 i = 0; i < count; ++i) {
if (array[i] != 0) { if (array[i] != 0) {
result = false; result = false;
break; break;
} }
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_arena_destroy(void) { TestFuncResult test_arena_destroy(void) {
wapp_mem_arena_destroy(&arena); wapp_mem_arena_destroy(&arena);
b8 result = arena == nullptr; b8 result = arena == nullptr;
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -2,272 +2,272 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_i32_array(void) { TestFuncResult test_i32_array(void) {
b8 result; b8 result;
I32Array array = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7); I32Array array = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7);
result = array.count == 7 && array.capacity == 16; result = array.count == 7 && array.capacity == 16;
i32 *item; i32 *item;
u64 count = array.count; u64 count = array.count;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { while (running) {
item = wapp_array_get(i32, &array, index); item = wapp_array_get(i32, &array, index);
result = result && item && *item == (i32)(index + 1); result = result && item && *item == (i32)(index + 1);
++index; ++index;
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_with_capacity(void) { TestFuncResult test_i32_array_with_capacity(void) {
b8 result; b8 result;
I32Array array1 = wapp_array_with_capacity(i32, I32Array, 64, false); I32Array array1 = wapp_array_with_capacity(i32, I32Array, 64, false);
result = array1.count == 0 && array1.capacity == 64; result = array1.count == 0 && array1.capacity == 64;
I32Array array2 = wapp_array_with_capacity(i32, I32Array, 64, true); I32Array array2 = wapp_array_with_capacity(i32, I32Array, 64, true);
result = array2.count == 64 && array2.capacity == 64; result = array2.count == 64 && array2.capacity == 64;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_get(void) { TestFuncResult test_i32_array_get(void) {
b8 result = true; b8 result = true;
I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8);
i32 *item; i32 *item;
u64 count = array.count; u64 count = array.count;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { while (running) {
item = wapp_array_get(i32, &array, index); item = wapp_array_get(i32, &array, index);
result = result && item && *item == (i32)index; result = result && item && *item == (i32)index;
++index; ++index;
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_set(void) { TestFuncResult test_i32_array_set(void) {
b8 result = true; b8 result = true;
I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8);
i32 *item; i32 *item;
u64 count = array.count; u64 count = array.count;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { while (running) {
i32 num = (i32)(index * 2); i32 num = (i32)(index * 2);
wapp_array_set(i32, &array, index, &num); wapp_array_set(i32, &array, index, &num);
item = wapp_array_get(i32, &array, index); item = wapp_array_get(i32, &array, index);
result = result && item && *item == (i32)(index * 2); result = result && item && *item == (i32)(index * 2);
++index; ++index;
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_append_capped(void) { TestFuncResult test_i32_array_append_capped(void) {
b8 result; b8 result;
I32Array array = wapp_array_with_capacity(i32, I32Array, 64, false); I32Array array = wapp_array_with_capacity(i32, I32Array, 64, false);
wapp_array_append_capped(i32, &array, &((i32){10})); wapp_array_append_capped(i32, &array, &((i32){10}));
result = array.count == 1; result = array.count == 1;
i32 *item = wapp_array_get(i32, &array, 0); i32 *item = wapp_array_get(i32, &array, 0);
result = result && item && *item == 10; result = result && item && *item == 10;
array = wapp_array(i32, I32Array, 1); array = wapp_array(i32, I32Array, 1);
wapp_array_append_capped(i32, &array, &((i32){10})); wapp_array_append_capped(i32, &array, &((i32){10}));
result = result && array.count == 2; result = result && array.count == 2;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_extend_capped(void) { TestFuncResult test_i32_array_extend_capped(void) {
b8 result; b8 result;
I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4); I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4);
I32Array array2 = wapp_array(i32, I32Array, 10, 20); I32Array array2 = wapp_array(i32, I32Array, 10, 20);
result = array1.count == 4 && array2.count == 2; result = array1.count == 4 && array2.count == 2;
wapp_array_extend_capped(i32, &array1, &array2); wapp_array_extend_capped(i32, &array1, &array2);
result = result && array1.count == 6; result = result && array1.count == 6;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_copy_capped(void) { TestFuncResult test_i32_array_copy_capped(void) {
b8 result; b8 result;
I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5);
I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6);
I32Array dst2 = wapp_array(i32, I32Array, 1, 2); I32Array dst2 = wapp_array(i32, I32Array, 1, 2);
u64 expected_count = 5; u64 expected_count = 5;
wapp_array_copy_capped(i32, &dst1, &src); wapp_array_copy_capped(i32, &dst1, &src);
result = dst1.count == expected_count; result = dst1.count == expected_count;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { 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; ++index;
running = index < expected_count; running = index < expected_count;
} }
expected_count = 4; expected_count = 4;
wapp_array_copy_capped(i32, &dst2, &src); wapp_array_copy_capped(i32, &dst2, &src);
result = result && dst2.count == expected_count; result = result && dst2.count == expected_count;
index = 0; index = 0;
running = true; running = true;
while (running) { 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; ++index;
running = index < expected_count; running = index < expected_count;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_alloc_capacity(void) { TestFuncResult test_i32_array_alloc_capacity(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
u64 capacity = 32; u64 capacity = 32;
I32Array *array = wapp_array_alloc_capacity(i32, I32Array, &allocator, capacity, false); I32Array *array = wapp_array_alloc_capacity(i32, I32Array, &allocator, capacity, false);
result = array && array->capacity == capacity; result = array && array->capacity == capacity;
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_append_alloc(void) { TestFuncResult test_i32_array_append_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8);
I32Array array2 = wapp_array(i32, I32Array, 1, 2); I32Array array2 = wapp_array(i32, I32Array, 1, 2);
I32Array *arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array1, &((i32){10})); I32Array *arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array1, &((i32){10}));
result = arr_ptr == &array1; result = arr_ptr == &array1;
u64 count = 4; u64 count = 4;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { while (running) {
i32 num = (i32)index; i32 num = (i32)index;
arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array2, &num); arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array2, &num);
++index; ++index;
running = index < count; running = index < count;
} }
result = result && arr_ptr != &array2; result = result && arr_ptr != &array2;
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_extend_alloc(void) { TestFuncResult test_i32_array_extend_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8);
I32Array array2 = wapp_array(i32, I32Array, 1, 2); I32Array array2 = wapp_array(i32, I32Array, 1, 2);
I32Array array3 = wapp_array(i32, I32Array, 1, 2, 3, 4); I32Array array3 = wapp_array(i32, I32Array, 1, 2, 3, 4);
I32Array *arr_ptr = wapp_array_extend_alloc(i32, I32Array, &allocator, &array1, &array3); I32Array *arr_ptr = wapp_array_extend_alloc(i32, I32Array, &allocator, &array1, &array3);
result = arr_ptr == &array1; result = arr_ptr == &array1;
arr_ptr = wapp_array_extend_alloc(i32, I32Array, &allocator, &array2, &array3); arr_ptr = wapp_array_extend_alloc(i32, I32Array, &allocator, &array2, &array3);
result = result && arr_ptr != &array2; result = result && arr_ptr != &array2;
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_copy_alloc(void) { TestFuncResult test_i32_array_copy_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5);
I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6);
I32Array dst2 = wapp_array(i32, I32Array, 1, 2); I32Array dst2 = wapp_array(i32, I32Array, 1, 2);
I32Array *array_ptr = NULL; I32Array *array_ptr = NULL;
u64 expected_count = 5; u64 expected_count = 5;
array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst1, &src); array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst1, &src);
result = array_ptr->count == expected_count && array_ptr == &dst1; result = array_ptr->count == expected_count && array_ptr == &dst1;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { 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; ++index;
running = index < expected_count; running = index < expected_count;
} }
expected_count = 5; expected_count = 5;
array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst2, &src); array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst2, &src);
result = result && array_ptr->count == expected_count && array_ptr != &dst2; result = result && array_ptr->count == expected_count && array_ptr != &dst2;
index = 0; index = 0;
running = true; running = true;
while (running) { 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; ++index;
running = index < expected_count; running = index < expected_count;
} }
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_pop(void) { TestFuncResult test_i32_array_pop(void) {
b8 result; b8 result;
I32Array array1 = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array1 = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8);
I32Array array2 = wapp_array_with_capacity(i32, I32Array, 32, false); I32Array array2 = wapp_array_with_capacity(i32, I32Array, 32, false);
i32 item1 = wapp_array_pop(i32, &array1); i32 item1 = wapp_array_pop(i32, &array1);
i32 item2 = wapp_array_pop(i32, &array2); i32 item2 = wapp_array_pop(i32, &array2);
result = item1 == 8 && item2 == 0; result = item1 == 8 && item2 == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_clear(void) { TestFuncResult test_i32_array_clear(void) {
b8 result; b8 result;
I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8);
result = array.count == 9; result = array.count == 9;
wapp_array_clear(i32, &array); wapp_array_clear(i32, &array);
result = result && array.count == 0; result = result && array.count == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -2,275 +2,275 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_i32_array(void) { TestFuncResult test_i32_array(void) {
b8 result; b8 result;
I32Array array = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7); I32Array array = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7);
result = array.count == 7 && array.capacity == 16; result = array.count == 7 && array.capacity == 16;
i32 *item; i32 *item;
u64 count = array.count; u64 count = array.count;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { while (running) {
item = wapp_array_get(i32, &array, index); item = wapp_array_get(i32, &array, index);
result = result && item && (*item == (i32)(index + 1)); result = result && item && (*item == (i32)(index + 1));
++index; ++index;
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_with_capacity(void) { TestFuncResult test_i32_array_with_capacity(void) {
b8 result; b8 result;
I32Array array1 = wapp_array_with_capacity(i32, I32Array, 64, false); I32Array array1 = wapp_array_with_capacity(i32, I32Array, 64, false);
result = array1.count == 0 && array1.capacity == 64; result = array1.count == 0 && array1.capacity == 64;
I32Array array2 = wapp_array_with_capacity(i32, I32Array, 64, true); I32Array array2 = wapp_array_with_capacity(i32, I32Array, 64, true);
result = array2.count == 64 && array2.capacity == 64; result = array2.count == 64 && array2.capacity == 64;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_get(void) { TestFuncResult test_i32_array_get(void) {
b8 result = true; b8 result = true;
I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8);
i32 *item; i32 *item;
u64 count = array.count; u64 count = array.count;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { while (running) {
item = wapp_array_get(i32, &array, index); item = wapp_array_get(i32, &array, index);
result = result && item && (*item == (i32)index); result = result && item && (*item == (i32)index);
++index; ++index;
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_set(void) { TestFuncResult test_i32_array_set(void) {
b8 result = true; b8 result = true;
I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8);
i32 *item; i32 *item;
u64 count = array.count; u64 count = array.count;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { while (running) {
i32 num = (i32)(index * 2); i32 num = (i32)(index * 2);
wapp_array_set(i32, &array, index, &num); wapp_array_set(i32, &array, index, &num);
item = wapp_array_get(i32, &array, index); item = wapp_array_get(i32, &array, index);
result = result && item && (*item == (i32)(index * 2)); result = result && item && (*item == (i32)(index * 2));
++index; ++index;
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_append_capped(void) { TestFuncResult test_i32_array_append_capped(void) {
b8 result; b8 result;
I32Array array = wapp_array_with_capacity(i32, I32Array, 64, false); I32Array array = wapp_array_with_capacity(i32, I32Array, 64, false);
i32 item1 = 10; i32 item1 = 10;
wapp_array_append_capped(i32, &array, &item1); wapp_array_append_capped(i32, &array, &item1);
result = array.count == 1; result = array.count == 1;
i32 *item = wapp_array_get(i32, &array, 0); i32 *item = wapp_array_get(i32, &array, 0);
result = result && item && *item == 10; result = result && item && *item == 10;
array = wapp_array(i32, I32Array, 1); array = wapp_array(i32, I32Array, 1);
i32 item2 = 10; i32 item2 = 10;
wapp_array_append_capped(i32, &array, &item2); wapp_array_append_capped(i32, &array, &item2);
result = result && array.count == 2; result = result && array.count == 2;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_extend_capped(void) { TestFuncResult test_i32_array_extend_capped(void) {
b8 result; b8 result;
I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4); I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4);
I32Array array2 = wapp_array(i32, I32Array, 10, 20); I32Array array2 = wapp_array(i32, I32Array, 10, 20);
result = array1.count == 4 && array2.count == 2; result = array1.count == 4 && array2.count == 2;
wapp_array_extend_capped(i32, &array1, &array2); wapp_array_extend_capped(i32, &array1, &array2);
result = result && array1.count == 6; result = result && array1.count == 6;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_copy_capped(void) { TestFuncResult test_i32_array_copy_capped(void) {
b8 result; b8 result;
I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5);
I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6);
I32Array dst2 = wapp_array(i32, I32Array, 1, 2); I32Array dst2 = wapp_array(i32, I32Array, 1, 2);
u64 expected_count = 5; u64 expected_count = 5;
wapp_array_copy_capped(i32, &dst1, &src); wapp_array_copy_capped(i32, &dst1, &src);
result = dst1.count == expected_count; result = dst1.count == expected_count;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { 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; ++index;
running = index < expected_count; running = index < expected_count;
} }
expected_count = 4; expected_count = 4;
wapp_array_copy_capped(i32, &dst2, &src); wapp_array_copy_capped(i32, &dst2, &src);
result = result && dst2.count == expected_count; result = result && dst2.count == expected_count;
index = 0; index = 0;
running = true; running = true;
while (running) { 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; ++index;
running = index < expected_count; running = index < expected_count;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_alloc_capacity(void) { TestFuncResult test_i32_array_alloc_capacity(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
u64 capacity = 32; u64 capacity = 32;
I32Array *array = wapp_array_alloc_capacity(i32, I32Array, &allocator, capacity, false); I32Array *array = wapp_array_alloc_capacity(i32, I32Array, &allocator, capacity, false);
result = array && array->capacity == capacity; result = array && array->capacity == capacity;
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_append_alloc(void) { TestFuncResult test_i32_array_append_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8);
I32Array array2 = wapp_array(i32, I32Array, 1, 2); I32Array array2 = wapp_array(i32, I32Array, 1, 2);
i32 num = 10; i32 num = 10;
I32Array *arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array1, &num); I32Array *arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array1, &num);
result = arr_ptr == &array1; result = arr_ptr == &array1;
u64 count = 4; u64 count = 4;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { while (running) {
num = (i32)index; num = (i32)index;
arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array2, &num); arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array2, &num);
++index; ++index;
running = index < count; running = index < count;
} }
result = result && arr_ptr != &array2; result = result && arr_ptr != &array2;
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_extend_alloc(void) { TestFuncResult test_i32_array_extend_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8);
I32Array array2 = wapp_array(i32, I32Array, 1, 2); I32Array array2 = wapp_array(i32, I32Array, 1, 2);
I32Array array3 = wapp_array(i32, I32Array, 1, 2, 3, 4); I32Array array3 = wapp_array(i32, I32Array, 1, 2, 3, 4);
I32Array *arr_ptr = wapp_array_extend_alloc(i32, I32Array, &allocator, &array1, &array3); I32Array *arr_ptr = wapp_array_extend_alloc(i32, I32Array, &allocator, &array1, &array3);
result = arr_ptr == &array1; result = arr_ptr == &array1;
arr_ptr = wapp_array_extend_alloc(i32, I32Array, &allocator, &array2, &array3); arr_ptr = wapp_array_extend_alloc(i32, I32Array, &allocator, &array2, &array3);
result = result && arr_ptr != &array2; result = result && arr_ptr != &array2;
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_copy_alloc(void) { TestFuncResult test_i32_array_copy_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5);
I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6);
I32Array dst2 = wapp_array(i32, I32Array, 1, 2); I32Array dst2 = wapp_array(i32, I32Array, 1, 2);
I32Array *array_ptr = nullptr; I32Array *array_ptr = nullptr;
u64 expected_count = 5; u64 expected_count = 5;
array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst1, &src); array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst1, &src);
result = array_ptr->count == expected_count && array_ptr == &dst1; result = array_ptr->count == expected_count && array_ptr == &dst1;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { 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; ++index;
running = index < expected_count; running = index < expected_count;
} }
expected_count = 5; expected_count = 5;
array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst2, &src); array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst2, &src);
result = result && array_ptr->count == expected_count && array_ptr != &dst2; result = result && array_ptr->count == expected_count && array_ptr != &dst2;
index = 0; index = 0;
running = true; running = true;
while (running) { 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; ++index;
running = index < expected_count; running = index < expected_count;
} }
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_clear(void) { TestFuncResult test_i32_array_clear(void) {
b8 result; b8 result;
I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8);
result = array.count == 9; result = array.count == 9;
wapp_array_clear(i32, &array); wapp_array_clear(i32, &array);
result = result && array.count == 0; result = result && array.count == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_i32_array_pop(void) { TestFuncResult test_i32_array_pop(void) {
b8 result; b8 result;
I32Array array1 = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array1 = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8);
I32Array array2 = wapp_array_with_capacity(i32, I32Array, 32, false); I32Array array2 = wapp_array_with_capacity(i32, I32Array, 32, false);
i32 item1 = wapp_array_pop(i32, &array1); i32 item1 = wapp_array_pop(i32, &array1);
i32 item2 = wapp_array_pop(i32, &array2); i32 item2 = wapp_array_pop(i32, &array2);
result = item1 == 8 && item2 == 0; result = item1 == 8 && item2 == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -3,23 +3,23 @@
#include "test_str8_array.h" #include "test_str8_array.h"
TestFuncResult test_str8_array(void) { TestFuncResult test_str8_array(void) {
b8 result; b8 result;
Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")}; Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")};
Str8Array array = wapp_array(Str8, Str8Array, wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")); Str8Array array = wapp_array(Str8, Str8Array, wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye"));
result = array.count == 3 && array.capacity == 8; result = array.count == 3 && array.capacity == 8;
Str8 *item; Str8 *item;
u64 count = array.count; u64 count = array.count;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { while (running) {
item = wapp_array_get(Str8, &array, index); item = wapp_array_get(Str8, &array, index);
result = result && item && (wapp_str8_equal(item, &expected[index])); result = result && item && (wapp_str8_equal(item, &expected[index]));
++index; ++index;
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -3,28 +3,28 @@
#include "test_str8_array.h" #include "test_str8_array.h"
TestFuncResult test_str8_array(void) { TestFuncResult test_str8_array(void) {
b8 result; b8 result;
Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")}; Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")};
Str8 str1 = wapp_str8_lit("Hello"); Str8 str1 = wapp_str8_lit("Hello");
Str8 str2 = wapp_str8_lit("Hi"); Str8 str2 = wapp_str8_lit("Hi");
Str8 str3 = wapp_str8_lit("Bye"); Str8 str3 = wapp_str8_lit("Bye");
Str8Array array = wapp_array(Str8, Str8Array, str1, str2, str3); Str8Array array = wapp_array(Str8, Str8Array, str1, str2, str3);
result = array.count == 3 && array.capacity == 8; result = array.count == 3 && array.capacity == 8;
Str8 *item; Str8 *item;
u64 count = array.count; u64 count = array.count;
u64 index = 0; u64 index = 0;
b8 running = true; b8 running = true;
while (running) { while (running) {
item = wapp_array_get(Str8, &array, index); item = wapp_array_get(Str8, &array, index);
result = result && item && (wapp_str8_equal(item, &expected[index])); result = result && item && (wapp_str8_equal(item, &expected[index]));
++index; ++index;
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -3,179 +3,179 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#define MAIN_BUF_SIZE 4096 #define MAIN_BUF_SIZE 4096
#define TMP_BUF_SIZE 1024 #define TMP_BUF_SIZE 1024
TestFuncResult test_cpath_join_path(void) { TestFuncResult test_cpath_join_path(void) {
b8 result; b8 result;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 out = wapp_str8_buf(MAIN_BUF_SIZE); Str8 out = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP); wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
Str8List parts = wapp_dbl_list(Str8, Str8List); Str8List parts = wapp_dbl_list(Str8, Str8List);
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_str8(tmp)); wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_str8(tmp));
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr("home")); wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr("home"));
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr("abdelrahman")); wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr("abdelrahman"));
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr("Documents")); wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr("Documents"));
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = wapp_str8_equal(&out, &expected); result = wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_front(Str8, Str8Node, &parts); wapp_dbl_list_pop_front(Str8, Str8Node, &parts);
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
wapp_str8_concat_capped(&tmp, &wapp_str8_lit_ro("home")); wapp_str8_concat_capped(&tmp, &wapp_str8_lit_ro("home"));
wapp_dbl_list_pop_front(Str8, Str8Node, &parts); wapp_dbl_list_pop_front(Str8, Str8Node, &parts);
wapp_dbl_list_push_front(Str8, &parts, &wapp_str8_node_from_str8(tmp)); wapp_dbl_list_push_front(Str8, &parts, &wapp_str8_node_from_str8(tmp));
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
wapp_str8_format(&tmp, "home%c", WAPP_PATH_SEP); wapp_str8_format(&tmp, "home%c", WAPP_PATH_SEP);
wapp_dbl_list_pop_front(Str8, Str8Node, &parts); wapp_dbl_list_pop_front(Str8, Str8Node, &parts);
wapp_dbl_list_push_front(Str8, &parts, &wapp_str8_node_from_cstr("home")); wapp_dbl_list_push_front(Str8, &parts, &wapp_str8_node_from_cstr("home"));
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_empty(Str8, &parts); wapp_dbl_list_empty(Str8, &parts);
wapp_str8_format(&tmp, "%chome", WAPP_PATH_SEP); wapp_str8_format(&tmp, "%chome", WAPP_PATH_SEP);
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_str8(tmp)); wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_str8(tmp));
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr("")); wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr(""));
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_front(Str8, Str8Node, &parts); wapp_dbl_list_pop_front(Str8, Str8Node, &parts);
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr("")); wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr(""));
wapp_str8_format(&expected, "%s", ""); wapp_str8_format(&expected, "%s", "");
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_back(Str8, Str8Node, &parts); wapp_dbl_list_pop_back(Str8, Str8Node, &parts);
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr("home")); wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_node_from_cstr("home"));
wapp_str8_copy_cstr_capped(&expected, "home"); wapp_str8_copy_cstr_capped(&expected, "home");
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_cpath_dirname(void) { TestFuncResult test_cpath_dirname(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8)); Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) { if (wapp_mem_allocator_invalid(&arena)) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
b8 result; b8 result;
Str8 *output = NULL; Str8 *output = NULL;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
// CASE 1 // CASE 1
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP); wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP); wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
output = wapp_cpath_dirname(&arena, &tmp); output = wapp_cpath_dirname(&arena, &tmp);
result = output != NULL && wapp_str8_equal(output, &expected); result = output != NULL && wapp_str8_equal(output, &expected);
// CASE 2 // CASE 2
wapp_str8_format(&expected, "%s", "."); wapp_str8_format(&expected, "%s", ".");
output = wapp_cpath_dirname(&arena, &wapp_str8_lit("home")); output = wapp_cpath_dirname(&arena, &wapp_str8_lit("home"));
result = result && output != NULL && wapp_str8_equal(output, &expected); result = result && output != NULL && wapp_str8_equal(output, &expected);
// CASE 3 // CASE 3
output = wapp_cpath_dirname(&arena, &wapp_str8_lit("")); output = wapp_cpath_dirname(&arena, &wapp_str8_lit(""));
result = result && output != NULL && wapp_str8_equal(output, &expected); result = result && output != NULL && wapp_str8_equal(output, &expected);
// CASE 4 // CASE 4
wapp_str8_format(&tmp, "%chome%ctest", WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "%chome%ctest", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
output = wapp_cpath_dirname(&arena, &tmp); output = wapp_cpath_dirname(&arena, &tmp);
result = result && output != NULL && wapp_str8_equal(output, &expected); result = result && output != NULL && wapp_str8_equal(output, &expected);
// CASE 5 // CASE 5
wapp_str8_format(&tmp, "%chome%ctest%c", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "%chome%ctest%c", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
output = wapp_cpath_dirname(&arena, &tmp); output = wapp_cpath_dirname(&arena, &tmp);
result = result && output != NULL && wapp_str8_equal(output, &expected); result = result && output != NULL && wapp_str8_equal(output, &expected);
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_cpath_dirup(void) { TestFuncResult test_cpath_dirup(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8)); Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) { if (wapp_mem_allocator_invalid(&arena)) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
b8 result; b8 result;
Str8 *output = NULL; Str8 *output = NULL;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
// CASE 1 // CASE 1
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP); wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP); wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
output = wapp_cpath_dirup(&arena, &tmp, 3); output = wapp_cpath_dirup(&arena, &tmp, 3);
result = output != NULL && wapp_str8_equal(output, &expected); result = output != NULL && wapp_str8_equal(output, &expected);
// CASE 2 // CASE 2
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP); wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
output = wapp_cpath_dirup(&arena, &tmp, 3); output = wapp_cpath_dirup(&arena, &tmp, 3);
result = result && output != NULL && wapp_str8_equal(output, &expected); result = result && output != NULL && wapp_str8_equal(output, &expected);
// CASE 3 // CASE 3
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_copy_cstr_capped(&expected, "."); wapp_str8_copy_cstr_capped(&expected, ".");
output = wapp_cpath_dirup(&arena, &tmp, 3); output = wapp_cpath_dirup(&arena, &tmp, 3);
result = result && output != NULL && wapp_str8_equal(output, &expected); result = result && output != NULL && wapp_str8_equal(output, &expected);
// CASE 4 // CASE 4
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
output = wapp_cpath_dirup(&arena, &tmp, 2); output = wapp_cpath_dirup(&arena, &tmp, 2);
result = result && output != NULL && wapp_str8_equal(output, &expected); result = result && output != NULL && wapp_str8_equal(output, &expected);
// CASE 5 // CASE 5
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_copy_cstr_capped(&expected, "home"); wapp_str8_copy_cstr_capped(&expected, "home");
output = wapp_cpath_dirup(&arena, &tmp, 2); output = wapp_cpath_dirup(&arena, &tmp, 2);
result = result && output != NULL && wapp_str8_equal(output, &expected); result = result && output != NULL && wapp_str8_equal(output, &expected);
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -3,202 +3,202 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#define MAIN_BUF_SIZE 4096 #define MAIN_BUF_SIZE 4096
#define TMP_BUF_SIZE 1024 #define TMP_BUF_SIZE 1024
TestFuncResult test_cpath_join_path(void) { TestFuncResult test_cpath_join_path(void) {
b8 result; b8 result;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 out = wapp_str8_buf(MAIN_BUF_SIZE); Str8 out = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP); wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
Str8List parts = wapp_dbl_list(Str8, Str8List); Str8List parts = wapp_dbl_list(Str8, Str8List);
Str8Node tmp_node = wapp_str8_node_from_str8(tmp); Str8Node tmp_node = wapp_str8_node_from_str8(tmp);
wapp_dbl_list_push_back(Str8, &parts, &tmp_node); wapp_dbl_list_push_back(Str8, &parts, &tmp_node);
Str8Node home_node = wapp_str8_node_from_cstr("home"); Str8Node home_node = wapp_str8_node_from_cstr("home");
wapp_dbl_list_push_back(Str8, &parts, &home_node); wapp_dbl_list_push_back(Str8, &parts, &home_node);
Str8Node user_node = wapp_str8_node_from_cstr("abdelrahman"); Str8Node user_node = wapp_str8_node_from_cstr("abdelrahman");
wapp_dbl_list_push_back(Str8, &parts, &user_node); wapp_dbl_list_push_back(Str8, &parts, &user_node);
Str8Node docs_node = wapp_str8_node_from_cstr("Documents"); Str8Node docs_node = wapp_str8_node_from_cstr("Documents");
wapp_dbl_list_push_back(Str8, &parts, &docs_node); wapp_dbl_list_push_back(Str8, &parts, &docs_node);
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = wapp_str8_equal(&out, &expected); result = wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_front(Str8, Str8Node, &parts); wapp_dbl_list_pop_front(Str8, Str8Node, &parts);
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
Str8RO str = wapp_str8_lit_ro("home"); Str8RO str = wapp_str8_lit_ro("home");
wapp_str8_concat_capped(&tmp, &str); wapp_str8_concat_capped(&tmp, &str);
wapp_dbl_list_pop_front(Str8, Str8Node, &parts); wapp_dbl_list_pop_front(Str8, Str8Node, &parts);
Str8Node tmp_node_2 = wapp_str8_node_from_str8(tmp); Str8Node tmp_node_2 = wapp_str8_node_from_str8(tmp);
wapp_dbl_list_push_front(Str8, &parts, &tmp_node_2); wapp_dbl_list_push_front(Str8, &parts, &tmp_node_2);
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
wapp_str8_format(&tmp, "home%c", WAPP_PATH_SEP); wapp_str8_format(&tmp, "home%c", WAPP_PATH_SEP);
wapp_dbl_list_pop_front(Str8, Str8Node, &parts); wapp_dbl_list_pop_front(Str8, Str8Node, &parts);
Str8Node home_node_2 = wapp_str8_node_from_cstr("home"); Str8Node home_node_2 = wapp_str8_node_from_cstr("home");
wapp_dbl_list_push_front(Str8, &parts, &home_node_2); wapp_dbl_list_push_front(Str8, &parts, &home_node_2);
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_empty(Str8, &parts); wapp_dbl_list_empty(Str8, &parts);
wapp_str8_format(&tmp, "%chome", WAPP_PATH_SEP); wapp_str8_format(&tmp, "%chome", WAPP_PATH_SEP);
Str8Node tmp_node_3 = wapp_str8_node_from_str8(tmp); Str8Node tmp_node_3 = wapp_str8_node_from_str8(tmp);
wapp_dbl_list_push_back(Str8, &parts, &tmp_node_3); wapp_dbl_list_push_back(Str8, &parts, &tmp_node_3);
Str8Node empty_node = wapp_str8_node_from_cstr(""); Str8Node empty_node = wapp_str8_node_from_cstr("");
wapp_dbl_list_push_back(Str8, &parts, &empty_node); wapp_dbl_list_push_back(Str8, &parts, &empty_node);
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_front(Str8, Str8Node, &parts); wapp_dbl_list_pop_front(Str8, Str8Node, &parts);
Str8Node empty_node_2 = wapp_str8_node_from_cstr(""); Str8Node empty_node_2 = wapp_str8_node_from_cstr("");
wapp_dbl_list_push_back(Str8, &parts, &empty_node_2); wapp_dbl_list_push_back(Str8, &parts, &empty_node_2);
wapp_str8_format(&expected, "%s", ""); wapp_str8_format(&expected, "%s", "");
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_back(Str8, Str8Node, &parts); wapp_dbl_list_pop_back(Str8, Str8Node, &parts);
Str8Node home_node_3 = wapp_str8_node_from_cstr("home"); Str8Node home_node_3 = wapp_str8_node_from_cstr("home");
wapp_dbl_list_push_back(Str8, &parts, &home_node_3); wapp_dbl_list_push_back(Str8, &parts, &home_node_3);
wapp_str8_copy_cstr_capped(&expected, "home"); wapp_str8_copy_cstr_capped(&expected, "home");
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_cpath_dirname(void) { TestFuncResult test_cpath_dirname(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8)); Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) { if (wapp_mem_allocator_invalid(&arena)) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
b8 result; b8 result;
Str8 *output = nullptr; Str8 *output = nullptr;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
// CASE 1 // CASE 1
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP); wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP); wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
output = wapp_cpath_dirname(&arena, &tmp); output = wapp_cpath_dirname(&arena, &tmp);
result = output != nullptr && wapp_str8_equal(output, &expected); result = output != nullptr && wapp_str8_equal(output, &expected);
// CASE 2 // CASE 2
wapp_str8_format(&expected, "%s", "."); wapp_str8_format(&expected, "%s", ".");
Str8 path = wapp_str8_lit("home"); Str8 path = wapp_str8_lit("home");
output = wapp_cpath_dirname(&arena, &path); output = wapp_cpath_dirname(&arena, &path);
result = result && output != nullptr && wapp_str8_equal(output, &expected); result = result && output != nullptr && wapp_str8_equal(output, &expected);
// CASE 3 // CASE 3
path = wapp_str8_lit(""); path = wapp_str8_lit("");
output = wapp_cpath_dirname(&arena, &path); output = wapp_cpath_dirname(&arena, &path);
result = result && output != nullptr && wapp_str8_equal(output, &expected); result = result && output != nullptr && wapp_str8_equal(output, &expected);
// CASE 4 // CASE 4
wapp_str8_format(&tmp, "%chome%ctest", WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "%chome%ctest", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
output = wapp_cpath_dirname(&arena, &tmp); output = wapp_cpath_dirname(&arena, &tmp);
result = result && output != nullptr && wapp_str8_equal(output, &expected); result = result && output != nullptr && wapp_str8_equal(output, &expected);
// CASE 5 // CASE 5
wapp_str8_format(&tmp, "%chome%ctest%c", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "%chome%ctest%c", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
output = wapp_cpath_dirname(&arena, &tmp); output = wapp_cpath_dirname(&arena, &tmp);
result = result && output != nullptr && wapp_str8_equal(output, &expected); result = result && output != nullptr && wapp_str8_equal(output, &expected);
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_cpath_dirup(void) { TestFuncResult test_cpath_dirup(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8)); Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) { if (wapp_mem_allocator_invalid(&arena)) {
return wapp_tester_result(false); return wapp_tester_result(false);
} }
b8 result; b8 result;
Str8 *output = nullptr; Str8 *output = nullptr;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
// CASE 1 // CASE 1
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP); wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP); wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
output = wapp_cpath_dirup(&arena, &tmp, 3); output = wapp_cpath_dirup(&arena, &tmp, 3);
result = output != nullptr && wapp_str8_equal(output, &expected); result = output != nullptr && wapp_str8_equal(output, &expected);
// CASE 2 // CASE 2
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP); wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
output = wapp_cpath_dirup(&arena, &tmp, 3); output = wapp_cpath_dirup(&arena, &tmp, 3);
result = result && output != nullptr && wapp_str8_equal(output, &expected); result = result && output != nullptr && wapp_str8_equal(output, &expected);
// CASE 3 // CASE 3
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_copy_cstr_capped(&expected, "."); wapp_str8_copy_cstr_capped(&expected, ".");
output = wapp_cpath_dirup(&arena, &tmp, 3); output = wapp_cpath_dirup(&arena, &tmp, 3);
result = result && output != nullptr && wapp_str8_equal(output, &expected); result = result && output != nullptr && wapp_str8_equal(output, &expected);
// CASE 4 // CASE 4
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP); wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
output = wapp_cpath_dirup(&arena, &tmp, 2); output = wapp_cpath_dirup(&arena, &tmp, 2);
result = result && output != nullptr && wapp_str8_equal(output, &expected); result = result && output != nullptr && wapp_str8_equal(output, &expected);
// CASE 5 // CASE 5
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_copy_cstr_capped(&expected, "home"); wapp_str8_copy_cstr_capped(&expected, "home");
output = wapp_cpath_dirup(&arena, &tmp, 2); output = wapp_cpath_dirup(&arena, &tmp, 2);
result = result && output != nullptr && wapp_str8_equal(output, &expected); result = result && output != nullptr && wapp_str8_equal(output, &expected);
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -5,58 +5,58 @@
#include <string.h> #include <string.h>
TestFuncResult test_commander_cmd_success(void) { TestFuncResult test_commander_cmd_success(void) {
Str8List cmd = wapp_dbl_list(Str8, Str8List); Str8List cmd = wapp_dbl_list(Str8, Str8List);
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr("echo")); wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr("echo"));
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr("hello world")); wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr("hello world"));
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd); CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd);
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR; result.error == SHELL_ERR_NO_ERROR;
return wapp_tester_result(succeeded); return wapp_tester_result(succeeded);
} }
TestFuncResult test_commander_cmd_failure(void) { TestFuncResult test_commander_cmd_failure(void) {
Str8List cmd = wapp_dbl_list(Str8, Str8List); Str8List cmd = wapp_dbl_list(Str8, Str8List);
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr("grep")); wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr("grep"));
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd); CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd);
b8 failed = result.exited && result.exit_code != EXIT_SUCCESS && b8 failed = result.exited && result.exit_code != EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR; result.error == SHELL_ERR_NO_ERROR;
return wapp_tester_result(failed); return wapp_tester_result(failed);
} }
TestFuncResult test_commander_cmd_out_buf_success(void) { TestFuncResult test_commander_cmd_out_buf_success(void) {
Str8 buf = wapp_str8_buf(64); Str8 buf = wapp_str8_buf(64);
Str8 expected = wapp_str8_buf(64); Str8 expected = wapp_str8_buf(64);
char msg[] = "hello world"; char msg[] = "hello world";
wapp_str8_copy_cstr_capped(&expected, msg); wapp_str8_copy_cstr_capped(&expected, msg);
Str8List cmd = wapp_dbl_list(Str8, Str8List); Str8List cmd = wapp_dbl_list(Str8, Str8List);
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr("echo")); wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr("echo"));
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr(msg)); wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr(msg));
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg)); result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg));
return wapp_tester_result(succeeded); return wapp_tester_result(succeeded);
} }
TestFuncResult test_commander_cmd_out_buf_failure(void) { TestFuncResult test_commander_cmd_out_buf_failure(void) {
Str8 buf = wapp_str8_buf(4); Str8 buf = wapp_str8_buf(4);
Str8 expected = wapp_str8_buf(64); Str8 expected = wapp_str8_buf(64);
char msg[] = "hello world"; char msg[] = "hello world";
wapp_str8_copy_cstr_capped(&expected, msg); wapp_str8_copy_cstr_capped(&expected, msg);
Str8List cmd = wapp_dbl_list(Str8, Str8List); Str8List cmd = wapp_dbl_list(Str8, Str8List);
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr("echo")); wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr("echo"));
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr(msg)); wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr(msg));
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS && b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected); result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected);
return wapp_tester_result(failed); return wapp_tester_result(failed);
} }

View File

@@ -5,65 +5,65 @@
#include <string.h> #include <string.h>
TestFuncResult test_commander_cmd_success(void) { TestFuncResult test_commander_cmd_success(void) {
Str8List cmd = wapp_dbl_list(Str8, Str8List); Str8List cmd = wapp_dbl_list(Str8, Str8List);
Str8Node echo = wapp_str8_node_from_cstr("echo"); Str8Node echo = wapp_str8_node_from_cstr("echo");
Str8Node msg = wapp_str8_node_from_cstr("hello world"); Str8Node msg = wapp_str8_node_from_cstr("hello world");
wapp_dbl_list_push_back(Str8, &cmd, &echo); wapp_dbl_list_push_back(Str8, &cmd, &echo);
wapp_dbl_list_push_back(Str8, &cmd, &msg); wapp_dbl_list_push_back(Str8, &cmd, &msg);
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd); CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd);
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR; result.error == SHELL_ERR_NO_ERROR;
return wapp_tester_result(succeeded); return wapp_tester_result(succeeded);
} }
TestFuncResult test_commander_cmd_failure(void) { TestFuncResult test_commander_cmd_failure(void) {
Str8List cmd = wapp_dbl_list(Str8, Str8List); Str8List cmd = wapp_dbl_list(Str8, Str8List);
Str8Node grep = wapp_str8_node_from_cstr("grep"); Str8Node grep = wapp_str8_node_from_cstr("grep");
wapp_dbl_list_push_back(Str8, &cmd, &grep); wapp_dbl_list_push_back(Str8, &cmd, &grep);
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd); CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd);
b8 failed = result.exited && result.exit_code != EXIT_SUCCESS && b8 failed = result.exited && result.exit_code != EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR; result.error == SHELL_ERR_NO_ERROR;
return wapp_tester_result(failed); return wapp_tester_result(failed);
} }
TestFuncResult test_commander_cmd_out_buf_success(void) { TestFuncResult test_commander_cmd_out_buf_success(void) {
Str8 buf = wapp_str8_buf(64); Str8 buf = wapp_str8_buf(64);
Str8 expected = wapp_str8_buf(64); Str8 expected = wapp_str8_buf(64);
char msg[] = "hello world"; char msg[] = "hello world";
wapp_str8_copy_cstr_capped(&expected, msg); wapp_str8_copy_cstr_capped(&expected, msg);
Str8List cmd = wapp_dbl_list(Str8, Str8List); Str8List cmd = wapp_dbl_list(Str8, Str8List);
Str8Node echo = wapp_str8_node_from_cstr("echo"); Str8Node echo = wapp_str8_node_from_cstr("echo");
Str8Node arg = wapp_str8_node_from_cstr(msg); Str8Node arg = wapp_str8_node_from_cstr(msg);
wapp_dbl_list_push_back(Str8, &cmd, &echo); wapp_dbl_list_push_back(Str8, &cmd, &echo);
wapp_dbl_list_push_back(Str8, &cmd, &arg); wapp_dbl_list_push_back(Str8, &cmd, &arg);
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg)); result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg));
return wapp_tester_result(succeeded); return wapp_tester_result(succeeded);
} }
TestFuncResult test_commander_cmd_out_buf_failure(void) { TestFuncResult test_commander_cmd_out_buf_failure(void) {
Str8 buf = wapp_str8_buf(4); Str8 buf = wapp_str8_buf(4);
Str8 expected = wapp_str8_buf(64); Str8 expected = wapp_str8_buf(64);
char msg[] = "hello world"; char msg[] = "hello world";
wapp_str8_copy_cstr_capped(&expected, msg); wapp_str8_copy_cstr_capped(&expected, msg);
Str8List cmd = wapp_dbl_list(Str8, Str8List); Str8List cmd = wapp_dbl_list(Str8, Str8List);
Str8Node echo = wapp_str8_node_from_cstr("echo"); Str8Node echo = wapp_str8_node_from_cstr("echo");
Str8Node arg = wapp_str8_node_from_cstr(msg); Str8Node arg = wapp_str8_node_from_cstr(msg);
wapp_dbl_list_push_back(Str8, &cmd, &echo); wapp_dbl_list_push_back(Str8, &cmd, &echo);
wapp_dbl_list_push_back(Str8, &cmd, &arg); wapp_dbl_list_push_back(Str8, &cmd, &arg);
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS && b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected); result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected);
return wapp_tester_result(failed); return wapp_tester_result(failed);
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,262 +2,262 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_str8_list_get(void) { TestFuncResult test_str8_list_get(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4"); Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5"); Str8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
Str8Node n4 = wapp_str8_node_from_str8(s4); Str8Node n4 = wapp_str8_node_from_str8(s4);
Str8Node n5 = wapp_str8_node_from_str8(s5); Str8Node n5 = wapp_str8_node_from_str8(s5);
wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n1);
wapp_dbl_list_push_back(Str8, &list, &n2); wapp_dbl_list_push_back(Str8, &list, &n2);
wapp_dbl_list_push_back(Str8, &list, &n3); wapp_dbl_list_push_back(Str8, &list, &n3);
wapp_dbl_list_push_back(Str8, &list, &n4); wapp_dbl_list_push_back(Str8, &list, &n4);
wapp_dbl_list_push_back(Str8, &list, &n5); wapp_dbl_list_push_back(Str8, &list, &n5);
Str8Node *node = wapp_dbl_list_get(Str8, Str8Node, &list, 0); Str8Node *node = wapp_dbl_list_get(Str8, Str8Node, &list, 0);
result = node->item == &s1 && wapp_str8_equal(node->item, &s1); result = node->item == &s1 && wapp_str8_equal(node->item, &s1);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 1); node = wapp_dbl_list_get(Str8, Str8Node, &list, 1);
result = result && node->item == &s2 && wapp_str8_equal(node->item, &s2); result = result && node->item == &s2 && wapp_str8_equal(node->item, &s2);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 2); node = wapp_dbl_list_get(Str8, Str8Node, &list, 2);
result = result && node->item == &s3 && wapp_str8_equal(node->item, &s3); result = result && node->item == &s3 && wapp_str8_equal(node->item, &s3);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 3); node = wapp_dbl_list_get(Str8, Str8Node, &list, 3);
result = result && node->item == &s4 && wapp_str8_equal(node->item, &s4); result = result && node->item == &s4 && wapp_str8_equal(node->item, &s4);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 4); node = wapp_dbl_list_get(Str8, Str8Node, &list, 4);
result = result && node->item == &s5 && wapp_str8_equal(node->item, &s5); result = result && node->item == &s5 && wapp_str8_equal(node->item, &s5);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_push_front(void) { TestFuncResult test_str8_list_push_front(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
wapp_dbl_list_push_front(Str8, &list, &n1); wapp_dbl_list_push_front(Str8, &list, &n1);
result = list.first == list.last && list.first == &n1 && list.first->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1; result = list.first == list.last && list.first == &n1 && list.first->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
wapp_dbl_list_push_front(Str8, &list, &n2); wapp_dbl_list_push_front(Str8, &list, &n2);
result = result && list.first == &n2 && list.first->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2; result = result && list.first == &n2 && list.first->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
wapp_dbl_list_push_front(Str8, &list, &n3); wapp_dbl_list_push_front(Str8, &list, &n3);
result = result && list.first == &n3 && list.first->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && list.first == &n3 && list.first->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_push_back(void) { TestFuncResult test_str8_list_push_back(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n1);
result = list.first == list.last && list.last == &n1 && list.last->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1; result = list.first == list.last && list.last == &n1 && list.last->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
wapp_dbl_list_push_back(Str8, &list, &n2); wapp_dbl_list_push_back(Str8, &list, &n2);
result = result && list.last == &n2 && list.last->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2; result = result && list.last == &n2 && list.last->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
wapp_dbl_list_push_back(Str8, &list, &n3); wapp_dbl_list_push_back(Str8, &list, &n3);
result = result && list.last == &n3 && list.last->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && list.last == &n3 && list.last->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_insert(void) { TestFuncResult test_str8_list_insert(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4"); Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5"); Str8 s5 = wapp_str8_lit("5");
Str8 s6 = wapp_str8_lit("6"); Str8 s6 = wapp_str8_lit("6");
Str8 s7 = wapp_str8_lit("7"); Str8 s7 = wapp_str8_lit("7");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
Str8Node n4 = wapp_str8_node_from_str8(s4); Str8Node n4 = wapp_str8_node_from_str8(s4);
Str8Node n5 = wapp_str8_node_from_str8(s5); Str8Node n5 = wapp_str8_node_from_str8(s5);
Str8Node n6 = wapp_str8_node_from_str8(s6); Str8Node n6 = wapp_str8_node_from_str8(s6);
Str8Node n7 = wapp_str8_node_from_str8(s7); Str8Node n7 = wapp_str8_node_from_str8(s7);
wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n1);
wapp_dbl_list_push_back(Str8, &list, &n2); wapp_dbl_list_push_back(Str8, &list, &n2);
wapp_dbl_list_push_back(Str8, &list, &n3); wapp_dbl_list_push_back(Str8, &list, &n3);
wapp_dbl_list_push_back(Str8, &list, &n4); wapp_dbl_list_push_back(Str8, &list, &n4);
wapp_dbl_list_push_back(Str8, &list, &n5); wapp_dbl_list_push_back(Str8, &list, &n5);
Str8Node *node; Str8Node *node;
wapp_dbl_list_insert(Str8, &list, &n6, 2); wapp_dbl_list_insert(Str8, &list, &n6, 2);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 2); node = wapp_dbl_list_get(Str8, Str8Node, &list, 2);
result = node != NULL && node->item == &s6 && wapp_str8_list_total_size(&list) == 6 && list.node_count == 6; result = node != NULL && node->item == &s6 && wapp_str8_list_total_size(&list) == 6 && list.node_count == 6;
wapp_dbl_list_insert(Str8, &list, &n7, 5); wapp_dbl_list_insert(Str8, &list, &n7, 5);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 5); node = wapp_dbl_list_get(Str8, Str8Node, &list, 5);
result = result && node != NULL && node->item == &s7 && wapp_str8_list_total_size(&list) == 7 && list.node_count == 7; result = result && node != NULL && node->item == &s7 && wapp_str8_list_total_size(&list) == 7 && list.node_count == 7;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_pop_front(void) { TestFuncResult test_str8_list_pop_front(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4"); Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5"); Str8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
Str8Node n4 = wapp_str8_node_from_str8(s4); Str8Node n4 = wapp_str8_node_from_str8(s4);
Str8Node n5 = wapp_str8_node_from_str8(s5); Str8Node n5 = wapp_str8_node_from_str8(s5);
wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n1);
wapp_dbl_list_push_back(Str8, &list, &n2); wapp_dbl_list_push_back(Str8, &list, &n2);
wapp_dbl_list_push_back(Str8, &list, &n3); wapp_dbl_list_push_back(Str8, &list, &n3);
wapp_dbl_list_push_back(Str8, &list, &n4); wapp_dbl_list_push_back(Str8, &list, &n4);
wapp_dbl_list_push_back(Str8, &list, &n5); wapp_dbl_list_push_back(Str8, &list, &n5);
Str8Node *node = wapp_dbl_list_pop_front(Str8, Str8Node, &list); Str8Node *node = wapp_dbl_list_pop_front(Str8, Str8Node, &list);
result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4; result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_pop_front(Str8, Str8Node, &list); node = wapp_dbl_list_pop_front(Str8, Str8Node, &list);
result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_pop_front(Str8, Str8Node, &list); node = wapp_dbl_list_pop_front(Str8, Str8Node, &list);
result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2; result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_pop_front(Str8, Str8Node, &list); node = wapp_dbl_list_pop_front(Str8, Str8Node, &list);
result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1; result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_pop_front(Str8, Str8Node, &list); node = wapp_dbl_list_pop_front(Str8, Str8Node, &list);
result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_pop_back(void) { TestFuncResult test_str8_list_pop_back(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4"); Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5"); Str8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
Str8Node n4 = wapp_str8_node_from_str8(s4); Str8Node n4 = wapp_str8_node_from_str8(s4);
Str8Node n5 = wapp_str8_node_from_str8(s5); Str8Node n5 = wapp_str8_node_from_str8(s5);
wapp_dbl_list_push_front(Str8, &list, &n1); wapp_dbl_list_push_front(Str8, &list, &n1);
wapp_dbl_list_push_front(Str8, &list, &n2); wapp_dbl_list_push_front(Str8, &list, &n2);
wapp_dbl_list_push_front(Str8, &list, &n3); wapp_dbl_list_push_front(Str8, &list, &n3);
wapp_dbl_list_push_front(Str8, &list, &n4); wapp_dbl_list_push_front(Str8, &list, &n4);
wapp_dbl_list_push_front(Str8, &list, &n5); wapp_dbl_list_push_front(Str8, &list, &n5);
Str8Node *node = wapp_dbl_list_pop_back(Str8, Str8Node, &list); Str8Node *node = wapp_dbl_list_pop_back(Str8, Str8Node, &list);
result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4; result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_pop_back(Str8, Str8Node, &list); node = wapp_dbl_list_pop_back(Str8, Str8Node, &list);
result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_pop_back(Str8, Str8Node, &list); node = wapp_dbl_list_pop_back(Str8, Str8Node, &list);
result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2; result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_pop_back(Str8, Str8Node, &list); node = wapp_dbl_list_pop_back(Str8, Str8Node, &list);
result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1; result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_pop_back(Str8, Str8Node, &list); node = wapp_dbl_list_pop_back(Str8, Str8Node, &list);
result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_remove(void) { TestFuncResult test_str8_list_remove(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4"); Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5"); Str8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
Str8Node n4 = wapp_str8_node_from_str8(s4); Str8Node n4 = wapp_str8_node_from_str8(s4);
Str8Node n5 = wapp_str8_node_from_str8(s5); Str8Node n5 = wapp_str8_node_from_str8(s5);
wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n1);
wapp_dbl_list_push_back(Str8, &list, &n2); wapp_dbl_list_push_back(Str8, &list, &n2);
wapp_dbl_list_push_back(Str8, &list, &n3); wapp_dbl_list_push_back(Str8, &list, &n3);
wapp_dbl_list_push_back(Str8, &list, &n4); wapp_dbl_list_push_back(Str8, &list, &n4);
wapp_dbl_list_push_back(Str8, &list, &n5); wapp_dbl_list_push_back(Str8, &list, &n5);
Str8Node *node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0); Str8Node *node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0);
result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4; result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0); node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0);
result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0); node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0);
result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2; result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0); node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0);
result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1; result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0); node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0);
result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_empty(void) { TestFuncResult test_str8_list_empty(void) {
b8 result; b8 result;
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
wapp_dbl_list_push_back(Str8, &list, &wapp_str8_node_from_cstr("Hello")); wapp_dbl_list_push_back(Str8, &list, &wapp_str8_node_from_cstr("Hello"));
wapp_dbl_list_push_back(Str8, &list, &wapp_str8_node_from_cstr("from")); wapp_dbl_list_push_back(Str8, &list, &wapp_str8_node_from_cstr("from"));
wapp_dbl_list_push_back(Str8, &list, &wapp_str8_node_from_cstr("wizapp")); wapp_dbl_list_push_back(Str8, &list, &wapp_str8_node_from_cstr("wizapp"));
wapp_dbl_list_push_back(Str8, &list, &wapp_str8_node_from_cstr("stdlib")); wapp_dbl_list_push_back(Str8, &list, &wapp_str8_node_from_cstr("stdlib"));
wapp_dbl_list_empty(Str8, &list); wapp_dbl_list_empty(Str8, &list);
result = list.first == NULL && list.last == NULL && list.node_count == 0 && wapp_str8_list_total_size(&list) == 0; result = list.first == NULL && list.last == NULL && list.node_count == 0 && wapp_str8_list_total_size(&list) == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -2,270 +2,270 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_str8_list_get(void) { TestFuncResult test_str8_list_get(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4"); Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5"); Str8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
Str8Node n4 = wapp_str8_node_from_str8(s4); Str8Node n4 = wapp_str8_node_from_str8(s4);
Str8Node n5 = wapp_str8_node_from_str8(s5); Str8Node n5 = wapp_str8_node_from_str8(s5);
wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n1);
wapp_dbl_list_push_back(Str8, &list, &n2); wapp_dbl_list_push_back(Str8, &list, &n2);
wapp_dbl_list_push_back(Str8, &list, &n3); wapp_dbl_list_push_back(Str8, &list, &n3);
wapp_dbl_list_push_back(Str8, &list, &n4); wapp_dbl_list_push_back(Str8, &list, &n4);
wapp_dbl_list_push_back(Str8, &list, &n5); wapp_dbl_list_push_back(Str8, &list, &n5);
Str8Node *node = wapp_dbl_list_get(Str8, Str8Node, &list, 0); Str8Node *node = wapp_dbl_list_get(Str8, Str8Node, &list, 0);
result = node->item == &s1 && wapp_str8_equal(node->item, &s1); result = node->item == &s1 && wapp_str8_equal(node->item, &s1);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 1); node = wapp_dbl_list_get(Str8, Str8Node, &list, 1);
result = result && node->item == &s2 && wapp_str8_equal(node->item, &s2); result = result && node->item == &s2 && wapp_str8_equal(node->item, &s2);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 2); node = wapp_dbl_list_get(Str8, Str8Node, &list, 2);
result = result && node->item == &s3 && wapp_str8_equal(node->item, &s3); result = result && node->item == &s3 && wapp_str8_equal(node->item, &s3);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 3); node = wapp_dbl_list_get(Str8, Str8Node, &list, 3);
result = result && node->item == &s4 && wapp_str8_equal(node->item, &s4); result = result && node->item == &s4 && wapp_str8_equal(node->item, &s4);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 4); node = wapp_dbl_list_get(Str8, Str8Node, &list, 4);
result = result && node->item == &s5 && wapp_str8_equal(node->item, &s5); result = result && node->item == &s5 && wapp_str8_equal(node->item, &s5);
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_push_front(void) { TestFuncResult test_str8_list_push_front(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
wapp_dbl_list_push_front(Str8, &list, &n1); wapp_dbl_list_push_front(Str8, &list, &n1);
result = list.first == list.last && list.first == &n1 && list.first->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1; result = list.first == list.last && list.first == &n1 && list.first->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
wapp_dbl_list_push_front(Str8, &list, &n2); wapp_dbl_list_push_front(Str8, &list, &n2);
result = result && list.first == &n2 && list.first->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2; result = result && list.first == &n2 && list.first->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
wapp_dbl_list_push_front(Str8, &list, &n3); wapp_dbl_list_push_front(Str8, &list, &n3);
result = result && list.first == &n3 && list.first->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && list.first == &n3 && list.first->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_push_back(void) { TestFuncResult test_str8_list_push_back(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n1);
result = list.first == list.last && list.last == &n1 && list.last->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1; result = list.first == list.last && list.last == &n1 && list.last->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
wapp_dbl_list_push_back(Str8, &list, &n2); wapp_dbl_list_push_back(Str8, &list, &n2);
result = result && list.last == &n2 && list.last->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2; result = result && list.last == &n2 && list.last->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
wapp_dbl_list_push_back(Str8, &list, &n3); wapp_dbl_list_push_back(Str8, &list, &n3);
result = result && list.last == &n3 && list.last->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && list.last == &n3 && list.last->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_insert(void) { TestFuncResult test_str8_list_insert(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4"); Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5"); Str8 s5 = wapp_str8_lit("5");
Str8 s6 = wapp_str8_lit("6"); Str8 s6 = wapp_str8_lit("6");
Str8 s7 = wapp_str8_lit("7"); Str8 s7 = wapp_str8_lit("7");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
Str8Node n4 = wapp_str8_node_from_str8(s4); Str8Node n4 = wapp_str8_node_from_str8(s4);
Str8Node n5 = wapp_str8_node_from_str8(s5); Str8Node n5 = wapp_str8_node_from_str8(s5);
Str8Node n6 = wapp_str8_node_from_str8(s6); Str8Node n6 = wapp_str8_node_from_str8(s6);
Str8Node n7 = wapp_str8_node_from_str8(s7); Str8Node n7 = wapp_str8_node_from_str8(s7);
wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n1);
wapp_dbl_list_push_back(Str8, &list, &n2); wapp_dbl_list_push_back(Str8, &list, &n2);
wapp_dbl_list_push_back(Str8, &list, &n3); wapp_dbl_list_push_back(Str8, &list, &n3);
wapp_dbl_list_push_back(Str8, &list, &n4); wapp_dbl_list_push_back(Str8, &list, &n4);
wapp_dbl_list_push_back(Str8, &list, &n5); wapp_dbl_list_push_back(Str8, &list, &n5);
Str8Node *node; Str8Node *node;
wapp_dbl_list_insert(Str8, &list, &n6, 2); wapp_dbl_list_insert(Str8, &list, &n6, 2);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 2); node = wapp_dbl_list_get(Str8, Str8Node, &list, 2);
result = node != NULL && node->item == &s6 && wapp_str8_list_total_size(&list) == 6 && list.node_count == 6; result = node != NULL && node->item == &s6 && wapp_str8_list_total_size(&list) == 6 && list.node_count == 6;
wapp_dbl_list_insert(Str8, &list, &n7, 5); wapp_dbl_list_insert(Str8, &list, &n7, 5);
node = wapp_dbl_list_get(Str8, Str8Node, &list, 5); node = wapp_dbl_list_get(Str8, Str8Node, &list, 5);
result = result && node != NULL && node->item == &s7 && wapp_str8_list_total_size(&list) == 7 && list.node_count == 7; result = result && node != NULL && node->item == &s7 && wapp_str8_list_total_size(&list) == 7 && list.node_count == 7;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_pop_front(void) { TestFuncResult test_str8_list_pop_front(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4"); Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5"); Str8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
Str8Node n4 = wapp_str8_node_from_str8(s4); Str8Node n4 = wapp_str8_node_from_str8(s4);
Str8Node n5 = wapp_str8_node_from_str8(s5); Str8Node n5 = wapp_str8_node_from_str8(s5);
wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n1);
wapp_dbl_list_push_back(Str8, &list, &n2); wapp_dbl_list_push_back(Str8, &list, &n2);
wapp_dbl_list_push_back(Str8, &list, &n3); wapp_dbl_list_push_back(Str8, &list, &n3);
wapp_dbl_list_push_back(Str8, &list, &n4); wapp_dbl_list_push_back(Str8, &list, &n4);
wapp_dbl_list_push_back(Str8, &list, &n5); wapp_dbl_list_push_back(Str8, &list, &n5);
Str8Node *node = wapp_dbl_list_pop_front(Str8, Str8Node, &list); Str8Node *node = wapp_dbl_list_pop_front(Str8, Str8Node, &list);
result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4; result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_pop_front(Str8, Str8Node, &list); node = wapp_dbl_list_pop_front(Str8, Str8Node, &list);
result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_pop_front(Str8, Str8Node, &list); node = wapp_dbl_list_pop_front(Str8, Str8Node, &list);
result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2; result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_pop_front(Str8, Str8Node, &list); node = wapp_dbl_list_pop_front(Str8, Str8Node, &list);
result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1; result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_pop_front(Str8, Str8Node, &list); node = wapp_dbl_list_pop_front(Str8, Str8Node, &list);
result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_pop_back(void) { TestFuncResult test_str8_list_pop_back(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4"); Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5"); Str8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
Str8Node n4 = wapp_str8_node_from_str8(s4); Str8Node n4 = wapp_str8_node_from_str8(s4);
Str8Node n5 = wapp_str8_node_from_str8(s5); Str8Node n5 = wapp_str8_node_from_str8(s5);
wapp_dbl_list_push_front(Str8, &list, &n1); wapp_dbl_list_push_front(Str8, &list, &n1);
wapp_dbl_list_push_front(Str8, &list, &n2); wapp_dbl_list_push_front(Str8, &list, &n2);
wapp_dbl_list_push_front(Str8, &list, &n3); wapp_dbl_list_push_front(Str8, &list, &n3);
wapp_dbl_list_push_front(Str8, &list, &n4); wapp_dbl_list_push_front(Str8, &list, &n4);
wapp_dbl_list_push_front(Str8, &list, &n5); wapp_dbl_list_push_front(Str8, &list, &n5);
Str8Node *node = wapp_dbl_list_pop_back(Str8, Str8Node, &list); Str8Node *node = wapp_dbl_list_pop_back(Str8, Str8Node, &list);
result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4; result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_pop_back(Str8, Str8Node, &list); node = wapp_dbl_list_pop_back(Str8, Str8Node, &list);
result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_pop_back(Str8, Str8Node, &list); node = wapp_dbl_list_pop_back(Str8, Str8Node, &list);
result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2; result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_pop_back(Str8, Str8Node, &list); node = wapp_dbl_list_pop_back(Str8, Str8Node, &list);
result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1; result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_pop_back(Str8, Str8Node, &list); node = wapp_dbl_list_pop_back(Str8, Str8Node, &list);
result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_remove(void) { TestFuncResult test_str8_list_remove(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2"); Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3"); Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4"); Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5"); Str8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node n1 = wapp_str8_node_from_str8(s1); Str8Node n1 = wapp_str8_node_from_str8(s1);
Str8Node n2 = wapp_str8_node_from_str8(s2); Str8Node n2 = wapp_str8_node_from_str8(s2);
Str8Node n3 = wapp_str8_node_from_str8(s3); Str8Node n3 = wapp_str8_node_from_str8(s3);
Str8Node n4 = wapp_str8_node_from_str8(s4); Str8Node n4 = wapp_str8_node_from_str8(s4);
Str8Node n5 = wapp_str8_node_from_str8(s5); Str8Node n5 = wapp_str8_node_from_str8(s5);
wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n1);
wapp_dbl_list_push_back(Str8, &list, &n2); wapp_dbl_list_push_back(Str8, &list, &n2);
wapp_dbl_list_push_back(Str8, &list, &n3); wapp_dbl_list_push_back(Str8, &list, &n3);
wapp_dbl_list_push_back(Str8, &list, &n4); wapp_dbl_list_push_back(Str8, &list, &n4);
wapp_dbl_list_push_back(Str8, &list, &n5); wapp_dbl_list_push_back(Str8, &list, &n5);
Str8Node *node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0); Str8Node *node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0);
result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4; result = node == &n1 && node->item == &s1 && wapp_str8_equal(node->item, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0); node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0);
result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && node == &n2 && node->item == &s2 && wapp_str8_equal(node->item, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0); node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0);
result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2; result = result && node == &n3 && node->item == &s3 && wapp_str8_equal(node->item, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0); node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0);
result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1; result = result && node == &n4 && node->item == &s4 && wapp_str8_equal(node->item, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0); node = wapp_dbl_list_remove(Str8, Str8Node, &list, 0);
result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &n5 && node->item == &s5 && wapp_str8_equal(node->item, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }
TestFuncResult test_str8_list_empty(void) { TestFuncResult test_str8_list_empty(void) {
b8 result; b8 result;
Str8List list = wapp_dbl_list(Str8, Str8List); Str8List list = wapp_dbl_list(Str8, Str8List);
Str8Node hello = wapp_str8_node_from_cstr("Hello"); Str8Node hello = wapp_str8_node_from_cstr("Hello");
wapp_dbl_list_push_back(Str8, &list, &hello); wapp_dbl_list_push_back(Str8, &list, &hello);
Str8Node from = wapp_str8_node_from_cstr("from"); Str8Node from = wapp_str8_node_from_cstr("from");
wapp_dbl_list_push_back(Str8, &list, &from); wapp_dbl_list_push_back(Str8, &list, &from);
Str8Node wizapp = wapp_str8_node_from_cstr("wizapp"); Str8Node wizapp = wapp_str8_node_from_cstr("wizapp");
wapp_dbl_list_push_back(Str8, &list, &wizapp); wapp_dbl_list_push_back(Str8, &list, &wizapp);
Str8Node stdlib = wapp_str8_node_from_cstr("stdlib"); Str8Node stdlib = wapp_str8_node_from_cstr("stdlib");
wapp_dbl_list_push_back(Str8, &list, &stdlib); wapp_dbl_list_push_back(Str8, &list, &stdlib);
wapp_dbl_list_empty(Str8, &list); wapp_dbl_list_empty(Str8, &list);
result = list.first == NULL && list.last == NULL && list.node_count == 0 && wapp_str8_list_total_size(&list) == 0; result = list.first == NULL && list.last == NULL && list.node_count == 0 && wapp_str8_list_total_size(&list) == 0;
return wapp_tester_result(result); return wapp_tester_result(result);
} }

View File

@@ -10,71 +10,71 @@
#include <stdlib.h> #include <stdlib.h>
int main(void) { int main(void) {
wapp_tester_run_tests( wapp_tester_run_tests(
test_arena_allocator, test_arena_allocator,
test_arena_init, test_arena_init,
test_arena_init_succeeds_when_reserving_very_large_size, test_arena_init_succeeds_when_reserving_very_large_size,
test_arena_alloc_succeeds_when_within_capacity, test_arena_alloc_succeeds_when_within_capacity,
test_arena_alloc_fails_when_over_capacity, test_arena_alloc_fails_when_over_capacity,
test_arena_realloc_bigger_size, test_arena_realloc_bigger_size,
test_arena_realloc_smaller_size, test_arena_realloc_smaller_size,
test_arena_clear, test_arena_clear,
test_arena_destroy, test_arena_destroy,
test_str8_array, test_str8_array,
test_i32_array, test_i32_array,
test_i32_array_with_capacity, test_i32_array_with_capacity,
test_i32_array_get, test_i32_array_get,
test_i32_array_set, test_i32_array_set,
test_i32_array_append_capped, test_i32_array_append_capped,
test_i32_array_extend_capped, test_i32_array_extend_capped,
test_i32_array_copy_capped, test_i32_array_copy_capped,
test_i32_array_alloc_capacity, test_i32_array_alloc_capacity,
test_i32_array_append_alloc, test_i32_array_append_alloc,
test_i32_array_extend_alloc, test_i32_array_extend_alloc,
test_i32_array_copy_alloc, test_i32_array_copy_alloc,
test_i32_array_pop, test_i32_array_pop,
test_i32_array_clear, test_i32_array_clear,
test_str8_lit, test_str8_lit,
test_str8_lit_ro, test_str8_lit_ro,
test_str8_buf, test_str8_buf,
test_str8_alloc_buf, test_str8_alloc_buf,
test_str8_alloc_cstr, test_str8_alloc_cstr,
test_str8_alloc_str8, test_str8_alloc_str8,
test_str8_alloc_substr, test_str8_alloc_substr,
test_str8_alloc_concat, test_str8_alloc_concat,
test_str8_get_index_within_bounds, test_str8_get_index_within_bounds,
test_str8_get_index_out_of_bounds, test_str8_get_index_out_of_bounds,
test_str8_set, test_str8_set,
test_str8_equal, test_str8_equal,
test_str8_slice, test_str8_slice,
test_str8_concat_capped, test_str8_concat_capped,
test_str8_copy_cstr_capped, test_str8_copy_cstr_capped,
test_str8_copy_str8_capped, test_str8_copy_str8_capped,
test_str8_format, test_str8_format,
test_str8_find, test_str8_find,
test_str8_rfind, test_str8_rfind,
test_str8_split, test_str8_split,
test_str8_split_with_max, test_str8_split_with_max,
test_str8_rsplit, test_str8_rsplit,
test_str8_rsplit_with_max, test_str8_rsplit_with_max,
test_str8_join, test_str8_join,
test_str8_from_bytes, test_str8_from_bytes,
test_str8_list_get, test_str8_list_get,
test_str8_list_push_front, test_str8_list_push_front,
test_str8_list_push_back, test_str8_list_push_back,
test_str8_list_insert, test_str8_list_insert,
test_str8_list_pop_front, test_str8_list_pop_front,
test_str8_list_pop_back, test_str8_list_pop_back,
test_str8_list_remove, test_str8_list_remove,
test_str8_list_empty, test_str8_list_empty,
test_cpath_join_path, test_cpath_join_path,
test_cpath_dirname, test_cpath_dirname,
test_cpath_dirup, test_cpath_dirup,
test_commander_cmd_success, test_commander_cmd_success,
test_commander_cmd_failure, test_commander_cmd_failure,
test_commander_cmd_out_buf_success, test_commander_cmd_out_buf_success,
test_commander_cmd_out_buf_failure test_commander_cmd_out_buf_failure
); );
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@@ -10,71 +10,71 @@
#include <stdlib.h> #include <stdlib.h>
int main(void) { int main(void) {
wapp_tester_run_tests( wapp_tester_run_tests(
test_arena_allocator, test_arena_allocator,
test_arena_init, test_arena_init,
test_arena_init_succeeds_when_reserving_very_large_size, test_arena_init_succeeds_when_reserving_very_large_size,
test_arena_alloc_succeeds_when_within_capacity, test_arena_alloc_succeeds_when_within_capacity,
test_arena_alloc_fails_when_over_capacity, test_arena_alloc_fails_when_over_capacity,
test_arena_realloc_bigger_size, test_arena_realloc_bigger_size,
test_arena_realloc_smaller_size, test_arena_realloc_smaller_size,
test_arena_clear, test_arena_clear,
test_arena_destroy, test_arena_destroy,
test_str8_array, test_str8_array,
test_i32_array, test_i32_array,
test_i32_array_with_capacity, test_i32_array_with_capacity,
test_i32_array_get, test_i32_array_get,
test_i32_array_set, test_i32_array_set,
test_i32_array_append_capped, test_i32_array_append_capped,
test_i32_array_extend_capped, test_i32_array_extend_capped,
test_i32_array_clear, test_i32_array_clear,
test_i32_array_pop, test_i32_array_pop,
test_i32_array_copy_capped, test_i32_array_copy_capped,
test_i32_array_alloc_capacity, test_i32_array_alloc_capacity,
test_i32_array_append_alloc, test_i32_array_append_alloc,
test_i32_array_extend_alloc, test_i32_array_extend_alloc,
test_i32_array_copy_alloc, test_i32_array_copy_alloc,
test_str8_lit, test_str8_lit,
test_str8_lit_ro, test_str8_lit_ro,
test_str8_buf, test_str8_buf,
test_str8_alloc_buf, test_str8_alloc_buf,
test_str8_alloc_cstr, test_str8_alloc_cstr,
test_str8_alloc_str8, test_str8_alloc_str8,
test_str8_alloc_substr, test_str8_alloc_substr,
test_str8_alloc_concat, test_str8_alloc_concat,
test_str8_get_index_within_bounds, test_str8_get_index_within_bounds,
test_str8_get_index_out_of_bounds, test_str8_get_index_out_of_bounds,
test_str8_set, test_str8_set,
test_str8_equal, test_str8_equal,
test_str8_slice, test_str8_slice,
test_str8_concat_capped, test_str8_concat_capped,
test_str8_copy_cstr_capped, test_str8_copy_cstr_capped,
test_str8_copy_str8_capped, test_str8_copy_str8_capped,
test_str8_format, test_str8_format,
test_str8_find, test_str8_find,
test_str8_rfind, test_str8_rfind,
test_str8_split, test_str8_split,
test_str8_split_with_max, test_str8_split_with_max,
test_str8_rsplit, test_str8_rsplit,
test_str8_rsplit_with_max, test_str8_rsplit_with_max,
test_str8_join, test_str8_join,
test_str8_from_bytes, test_str8_from_bytes,
test_str8_list_get, test_str8_list_get,
test_str8_list_push_front, test_str8_list_push_front,
test_str8_list_push_back, test_str8_list_push_back,
test_str8_list_insert, test_str8_list_insert,
test_str8_list_pop_front, test_str8_list_pop_front,
test_str8_list_pop_back, test_str8_list_pop_back,
test_str8_list_remove, test_str8_list_remove,
test_str8_list_empty, test_str8_list_empty,
test_cpath_join_path, test_cpath_join_path,
test_cpath_dirname, test_cpath_dirname,
test_cpath_dirup, test_cpath_dirup,
test_commander_cmd_success, test_commander_cmd_success,
test_commander_cmd_failure, test_commander_cmd_failure,
test_commander_cmd_out_buf_success, test_commander_cmd_out_buf_success,
test_commander_cmd_out_buf_failure test_commander_cmd_out_buf_failure
); );
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }