From 7be1b4210718e5764ab407abf48aa34961d8abf2 Mon Sep 17 00:00:00 2001 From: Abdelrahman Said Date: Fri, 2 Jan 2026 01:12:01 +0000 Subject: [PATCH] Reformat tests --- tests/allocator/test_allocator.c | 14 +- tests/allocator/test_allocator.cc | 14 +- tests/arena/test_arena.c | 28 +- tests/arena/test_arena.cc | 28 +- tests/array/test_i32_array.c | 98 +++--- tests/array/test_i32_array.cc | 86 +++--- tests/array/test_str8_array.c | 10 +- tests/array/test_str8_array.cc | 18 +- tests/cpath/test_cpath.c | 18 +- tests/cpath/test_cpath.cc | 30 +- tests/shell_commander/test_shell_commander.c | 36 +-- tests/shell_commander/test_shell_commander.cc | 50 ++-- tests/str8/test_str8.c | 276 ++++++++--------- tests/str8/test_str8.cc | 282 +++++++++--------- tests/str8/test_str8_list.c | 152 +++++----- tests/str8/test_str8_list.cc | 152 +++++----- tests/wapptest.cc | 4 +- 17 files changed, 648 insertions(+), 648 deletions(-) diff --git a/tests/allocator/test_allocator.c b/tests/allocator/test_allocator.c index b70f6bc..e9eb1be 100644 --- a/tests/allocator/test_allocator.c +++ b/tests/allocator/test_allocator.c @@ -3,13 +3,13 @@ #include TestFuncResult test_arena_allocator(void) { - Allocator allocator = wapp_mem_arena_allocator_init(4096); - b8 result = allocator.obj != NULL && allocator.alloc != NULL && - allocator.alloc_aligned != NULL && - allocator.realloc != NULL && allocator.realloc_aligned != NULL && - allocator.free == NULL; - void *ptr = wapp_mem_allocator_alloc(&allocator, 20); - result = result && (ptr != NULL); + Allocator allocator = wapp_mem_arena_allocator_init(4096); + b8 result = allocator.obj != NULL && allocator.alloc != NULL && + allocator.alloc_aligned != NULL && + allocator.realloc != NULL && allocator.realloc_aligned != NULL && + allocator.free == NULL; + void *ptr = wapp_mem_allocator_alloc(&allocator, 20); + result = result && (ptr != NULL); wapp_mem_arena_allocator_destroy(&allocator); diff --git a/tests/allocator/test_allocator.cc b/tests/allocator/test_allocator.cc index 2045eb7..38bcfd9 100644 --- a/tests/allocator/test_allocator.cc +++ b/tests/allocator/test_allocator.cc @@ -3,13 +3,13 @@ #include TestFuncResult test_arena_allocator(void) { - Allocator allocator = wapp_mem_arena_allocator_init(4096); - b8 result = allocator.obj != nullptr && allocator.alloc != nullptr && - allocator.alloc_aligned != nullptr && - allocator.realloc != nullptr && allocator.realloc_aligned != nullptr && - allocator.free == nullptr; - void *ptr = wapp_mem_allocator_alloc(&allocator, 20); - result = result && (ptr != nullptr); + Allocator allocator = wapp_mem_arena_allocator_init(4096); + b8 result = allocator.obj != nullptr && allocator.alloc != nullptr && + allocator.alloc_aligned != nullptr && + allocator.realloc != nullptr && allocator.realloc_aligned != nullptr && + allocator.free == nullptr; + void *ptr = wapp_mem_allocator_alloc(&allocator, 20); + result = result && (ptr != nullptr); wapp_mem_arena_allocator_destroy(&allocator); diff --git a/tests/arena/test_arena.c b/tests/arena/test_arena.c index 22fe14c..889c9bc 100644 --- a/tests/arena/test_arena.c +++ b/tests/arena/test_arena.c @@ -4,9 +4,9 @@ #define ARENA_CAPACITY KiB(16) -wapp_intern Arena *arena = NULL; -wapp_intern i32 count = 20; -wapp_intern i32 *array = NULL; +wapp_intern Arena *arena = NULL; +wapp_intern i32 count = 20; +wapp_intern i32 *array = NULL; TestFuncResult test_arena_init(void) { b8 result = wapp_mem_arena_init(&arena, ARENA_CAPACITY); @@ -15,9 +15,9 @@ TestFuncResult test_arena_init(void) { } TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) { - Arena *large_arena = NULL; - u64 capacity = GiB(512); - b8 result = wapp_mem_arena_init(&large_arena, capacity); + Arena *large_arena = NULL; + u64 capacity = GiB(512); + b8 result = wapp_mem_arena_init(&large_arena, capacity); if (result) { wapp_mem_arena_destroy(&large_arena); } @@ -26,8 +26,8 @@ TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) { } TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) { - array = wapp_mem_arena_alloc(arena, count * sizeof(i32)); - b8 result = array != NULL; + array = wapp_mem_arena_alloc(arena, count * sizeof(i32)); + b8 result = array != NULL; for (i32 i = 0; i < count; ++i) { array[i] = i * 10; @@ -44,9 +44,9 @@ TestFuncResult test_arena_alloc_fails_when_over_capacity(void) { } TestFuncResult test_arena_realloc_bigger_size(void) { - u64 old_count = 10; - u64 new_count = 20; - i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); + u64 old_count = 10; + u64 new_count = 20; + i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); for (u64 i = 0; i < old_count; ++i) { bytes[i] = (i32)i; @@ -67,9 +67,9 @@ TestFuncResult test_arena_realloc_bigger_size(void) { } TestFuncResult test_arena_realloc_smaller_size(void) { - u64 old_count = 10; - u64 new_count = 5; - i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); + u64 old_count = 10; + u64 new_count = 5; + i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); for (u64 i = 0; i < old_count; ++i) { bytes[i] = (i32)i; diff --git a/tests/arena/test_arena.cc b/tests/arena/test_arena.cc index 1a1c0e4..7ff38f2 100644 --- a/tests/arena/test_arena.cc +++ b/tests/arena/test_arena.cc @@ -4,9 +4,9 @@ #define ARENA_CAPACITY KiB(16) -wapp_intern Arena *arena = nullptr; -wapp_intern i32 count = 20; -wapp_intern i32 *array = nullptr; +wapp_intern Arena *arena = nullptr; +wapp_intern i32 count = 20; +wapp_intern i32 *array = nullptr; TestFuncResult test_arena_init(void) { b8 result = wapp_mem_arena_init(&arena, ARENA_CAPACITY); @@ -15,9 +15,9 @@ TestFuncResult test_arena_init(void) { } TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) { - Arena *large_arena = nullptr; - u64 capacity = GiB(512); - b8 result = wapp_mem_arena_init(&large_arena, capacity); + Arena *large_arena = nullptr; + u64 capacity = GiB(512); + b8 result = wapp_mem_arena_init(&large_arena, capacity); if (result) { wapp_mem_arena_destroy(&large_arena); } @@ -26,8 +26,8 @@ TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) { } TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) { - array = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32)); - b8 result = array != nullptr; + array = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32)); + b8 result = array != nullptr; for (i32 i = 0; i < count; ++i) { array[i] = i * 10; @@ -44,9 +44,9 @@ TestFuncResult test_arena_alloc_fails_when_over_capacity(void) { } TestFuncResult test_arena_realloc_bigger_size(void) { - u64 old_count = 10; - u64 new_count = 20; - i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); + u64 old_count = 10; + u64 new_count = 20; + i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); for (u64 i = 0; i < old_count; ++i) { bytes[i] = (i32)i; @@ -67,9 +67,9 @@ TestFuncResult test_arena_realloc_bigger_size(void) { } TestFuncResult test_arena_realloc_smaller_size(void) { - u64 old_count = 10; - u64 new_count = 5; - i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); + u64 old_count = 10; + u64 new_count = 5; + i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); for (u64 i = 0; i < old_count; ++i) { bytes[i] = (i32)i; diff --git a/tests/array/test_i32_array.c b/tests/array/test_i32_array.c index 46ee525..4df162e 100644 --- a/tests/array/test_i32_array.c +++ b/tests/array/test_i32_array.c @@ -8,12 +8,12 @@ TestFuncResult test_i32_array(void) { result = array.count == 7 && array.capacity == 16; i32 *item; - u64 count = array.count; - u64 index = 0; - b8 running = true; + u64 count = array.count; + u64 index = 0; + b8 running = true; while (running) { - item = wapp_array_get(i32, &array, index); - result = result && item && *item == (i32)(index + 1); + item = wapp_array_get(i32, &array, index); + result = result && item && *item == (i32)(index + 1); ++index; running = index < count; @@ -40,12 +40,12 @@ TestFuncResult test_i32_array_get(void) { I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); i32 *item; - u64 count = array.count; - u64 index = 0; - b8 running = true; + u64 count = array.count; + u64 index = 0; + b8 running = true; while (running) { - item = wapp_array_get(i32, &array, index); - result = result && item && *item == (i32)index; + item = wapp_array_get(i32, &array, index); + result = result && item && *item == (i32)index; ++index; running = index < count; @@ -60,14 +60,14 @@ TestFuncResult test_i32_array_set(void) { I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); i32 *item; - u64 count = array.count; - u64 index = 0; - b8 running = true; + u64 count = array.count; + u64 index = 0; + b8 running = true; while (running) { i32 num = (i32)(index * 2); wapp_array_set(i32, &array, index, &num); - item = wapp_array_get(i32, &array, index); - result = result && item && *item == (i32)(index * 2); + item = wapp_array_get(i32, &array, index); + result = result && item && *item == (i32)(index * 2); ++index; running = index < count; @@ -82,8 +82,8 @@ TestFuncResult test_i32_array_append_capped(void) { I32Array array = wapp_array_with_capacity(i32, I32Array, 64, false); wapp_array_append_capped(i32, &array, &((i32){10})); - result = array.count == 1; - i32 *item = wapp_array_get(i32, &array, 0); + result = array.count == 1; + i32 *item = wapp_array_get(i32, &array, 0); result = result && item && *item == 10; array = wapp_array(i32, I32Array, 1); @@ -112,16 +112,16 @@ TestFuncResult test_i32_array_extend_capped(void) { TestFuncResult test_i32_array_copy_capped(void) { b8 result; - I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); - I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); - I32Array dst2 = wapp_array(i32, I32Array, 1, 2); + I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); + I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); + I32Array dst2 = wapp_array(i32, I32Array, 1, 2); u64 expected_count = 5; wapp_array_copy_capped(i32, &dst1, &src); result = dst1.count == expected_count; - u64 index = 0; - b8 running = true; + u64 index = 0; + b8 running = true; while (running) { result = result && *wapp_array_get(i32, &src, index) == *wapp_array_get(i32, &dst1, index); @@ -133,8 +133,8 @@ TestFuncResult test_i32_array_copy_capped(void) { wapp_array_copy_capped(i32, &dst2, &src); result = result && dst2.count == expected_count; - index = 0; - running = true; + index = 0; + running = true; while (running) { result = result && *wapp_array_get(i32, &src, index) == *wapp_array_get(i32, &dst2, index); @@ -148,9 +148,9 @@ TestFuncResult test_i32_array_copy_capped(void) { TestFuncResult test_i32_array_alloc_capacity(void) { b8 result; - Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); - u64 capacity = 32; - I32Array *array = wapp_array_alloc_capacity(i32, I32Array, &allocator, capacity, false); + Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); + u64 capacity = 32; + I32Array *array = wapp_array_alloc_capacity(i32, I32Array, &allocator, capacity, false); result = array && array->capacity == capacity; @@ -162,16 +162,16 @@ TestFuncResult test_i32_array_alloc_capacity(void) { TestFuncResult test_i32_array_append_alloc(void) { b8 result; - Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); - I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8); - I32Array array2 = wapp_array(i32, I32Array, 1, 2); + Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); + I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8); + I32Array array2 = wapp_array(i32, I32Array, 1, 2); I32Array *arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array1, &((i32){10})); result = arr_ptr == &array1; - u64 count = 4; - u64 index = 0; - b8 running = true; + u64 count = 4; + u64 index = 0; + b8 running = true; while (running) { i32 num = (i32)index; arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array2, &num); @@ -189,16 +189,16 @@ TestFuncResult test_i32_array_append_alloc(void) { TestFuncResult test_i32_array_extend_alloc(void) { b8 result; - Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); - I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8); - I32Array array2 = wapp_array(i32, I32Array, 1, 2); - I32Array array3 = wapp_array(i32, I32Array, 1, 2, 3, 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 array2 = wapp_array(i32, I32Array, 1, 2); + I32Array array3 = wapp_array(i32, I32Array, 1, 2, 3, 4); I32Array *arr_ptr = wapp_array_extend_alloc(i32, I32Array, &allocator, &array1, &array3); result = arr_ptr == &array1; 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); @@ -208,18 +208,18 @@ TestFuncResult test_i32_array_extend_alloc(void) { TestFuncResult test_i32_array_copy_alloc(void) { b8 result; - Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); - I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); - I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); - I32Array dst2 = wapp_array(i32, I32Array, 1, 2); - I32Array *array_ptr = NULL; + Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); + I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); + I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); + I32Array dst2 = wapp_array(i32, I32Array, 1, 2); + I32Array *array_ptr = NULL; u64 expected_count = 5; array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst1, &src); result = array_ptr->count == expected_count && array_ptr == &dst1; - u64 index = 0; - b8 running = true; + u64 index = 0; + b8 running = true; while (running) { result = result && *wapp_array_get(i32, &src, index) == *wapp_array_get(i32, array_ptr, index); @@ -228,11 +228,11 @@ TestFuncResult test_i32_array_copy_alloc(void) { } expected_count = 5; - array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst2, &src); - result = result && array_ptr->count == expected_count && array_ptr != &dst2; + array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst2, &src); + result = result && array_ptr->count == expected_count && array_ptr != &dst2; - index = 0; - running = true; + index = 0; + running = true; while (running) { result = result && *wapp_array_get(i32, &src, index) == *wapp_array_get(i32, array_ptr, index); diff --git a/tests/array/test_i32_array.cc b/tests/array/test_i32_array.cc index 2b4466c..214f3fc 100644 --- a/tests/array/test_i32_array.cc +++ b/tests/array/test_i32_array.cc @@ -8,12 +8,12 @@ TestFuncResult test_i32_array(void) { result = array.count == 7 && array.capacity == 16; i32 *item; - u64 count = array.count; - u64 index = 0; - b8 running = true; + u64 count = array.count; + u64 index = 0; + b8 running = true; while (running) { - item = wapp_array_get(i32, &array, index); - result = result && item && (*item == (i32)(index + 1)); + item = wapp_array_get(i32, &array, index); + result = result && item && (*item == (i32)(index + 1)); ++index; running = index < count; @@ -40,12 +40,12 @@ TestFuncResult test_i32_array_get(void) { I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); i32 *item; - u64 count = array.count; - u64 index = 0; - b8 running = true; + u64 count = array.count; + u64 index = 0; + b8 running = true; while (running) { - item = wapp_array_get(i32, &array, index); - result = result && item && (*item == (i32)index); + item = wapp_array_get(i32, &array, index); + result = result && item && (*item == (i32)index); ++index; running = index < count; @@ -60,14 +60,14 @@ TestFuncResult test_i32_array_set(void) { I32Array array = wapp_array(i32, I32Array, 0, 1, 2, 3, 4, 5, 6, 7, 8); i32 *item; - u64 count = array.count; - u64 index = 0; - b8 running = true; + u64 count = array.count; + u64 index = 0; + b8 running = true; while (running) { i32 num = (i32)(index * 2); wapp_array_set(i32, &array, index, &num); - item = wapp_array_get(i32, &array, index); - result = result && item && (*item == (i32)(index * 2)); + item = wapp_array_get(i32, &array, index); + result = result && item && (*item == (i32)(index * 2)); ++index; running = index < count; @@ -114,16 +114,16 @@ TestFuncResult test_i32_array_extend_capped(void) { TestFuncResult test_i32_array_copy_capped(void) { b8 result; - I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); - I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); - I32Array dst2 = wapp_array(i32, I32Array, 1, 2); + I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); + I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); + I32Array dst2 = wapp_array(i32, I32Array, 1, 2); u64 expected_count = 5; wapp_array_copy_capped(i32, &dst1, &src); result = dst1.count == expected_count; - u64 index = 0; - b8 running = true; + u64 index = 0; + b8 running = true; while (running) { result = result && (*wapp_array_get(i32, &src, index) == *wapp_array_get(i32, &dst1, index)); @@ -135,8 +135,8 @@ TestFuncResult test_i32_array_copy_capped(void) { wapp_array_copy_capped(i32, &dst2, &src); result = result && dst2.count == expected_count; - index = 0; - running = true; + index = 0; + running = true; while (running) { result = result && (*wapp_array_get(i32, &src, index) == *wapp_array_get(i32, &dst2, index)); @@ -150,9 +150,9 @@ TestFuncResult test_i32_array_copy_capped(void) { TestFuncResult test_i32_array_alloc_capacity(void) { b8 result; - Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); - u64 capacity = 32; - I32Array *array = wapp_array_alloc_capacity(i32, I32Array, &allocator, capacity, false); + Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); + u64 capacity = 32; + I32Array *array = wapp_array_alloc_capacity(i32, I32Array, &allocator, capacity, false); result = array && array->capacity == capacity; @@ -164,17 +164,17 @@ TestFuncResult test_i32_array_alloc_capacity(void) { TestFuncResult test_i32_array_append_alloc(void) { b8 result; - Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); - I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8); - I32Array array2 = wapp_array(i32, I32Array, 1, 2); + Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); + I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8); + I32Array array2 = wapp_array(i32, I32Array, 1, 2); i32 num = 10; I32Array *arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array1, &num); result = arr_ptr == &array1; - u64 count = 4; - u64 index = 0; - b8 running = true; + u64 count = 4; + u64 index = 0; + b8 running = true; while (running) { num = (i32)index; arr_ptr = wapp_array_append_alloc(i32, I32Array, &allocator, &array2, &num); @@ -192,16 +192,16 @@ TestFuncResult test_i32_array_append_alloc(void) { TestFuncResult test_i32_array_extend_alloc(void) { b8 result; - Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); - I32Array array1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6, 7, 8); - I32Array array2 = wapp_array(i32, I32Array, 1, 2); - I32Array array3 = wapp_array(i32, I32Array, 1, 2, 3, 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 array2 = wapp_array(i32, I32Array, 1, 2); + I32Array array3 = wapp_array(i32, I32Array, 1, 2, 3, 4); I32Array *arr_ptr = wapp_array_extend_alloc(i32, I32Array, &allocator, &array1, &array3); result = arr_ptr == &array1; 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); @@ -211,18 +211,18 @@ TestFuncResult test_i32_array_extend_alloc(void) { TestFuncResult test_i32_array_copy_alloc(void) { b8 result; - Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); - I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); - I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); - I32Array dst2 = wapp_array(i32, I32Array, 1, 2); + Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); + I32Array src = wapp_array(i32, I32Array, 1, 2, 3, 4, 5); + I32Array dst1 = wapp_array(i32, I32Array, 1, 2, 3, 4, 5, 6); + I32Array dst2 = wapp_array(i32, I32Array, 1, 2); I32Array *array_ptr = nullptr; u64 expected_count = 5; array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst1, &src); result = array_ptr->count == expected_count && array_ptr == &dst1; - u64 index = 0; - b8 running = true; + u64 index = 0; + b8 running = true; while (running) { result = result && (*wapp_array_get(i32, &src, index) == *wapp_array_get(i32, array_ptr, index)); @@ -234,7 +234,7 @@ TestFuncResult test_i32_array_copy_alloc(void) { array_ptr = wapp_array_copy_alloc(i32, I32Array, &allocator, &dst2, &src); result = result && array_ptr->count == expected_count && array_ptr != &dst2; - index = 0; + index = 0; running = true; while (running) { result = result && (*wapp_array_get(i32, &src, index) == *wapp_array_get(i32, array_ptr, index)); diff --git a/tests/array/test_str8_array.c b/tests/array/test_str8_array.c index b37a810..49b2b98 100644 --- a/tests/array/test_str8_array.c +++ b/tests/array/test_str8_array.c @@ -10,12 +10,12 @@ TestFuncResult test_str8_array(void) { result = array.count == 3 && array.capacity == 8; Str8 *item; - u64 count = array.count; - u64 index = 0; - b8 running = true; + u64 count = array.count; + u64 index = 0; + b8 running = true; while (running) { - item = wapp_array_get(Str8, &array, index); - result = result && item && (wapp_str8_equal(item, &expected[index])); + item = wapp_array_get(Str8, &array, index); + result = result && item && (wapp_str8_equal(item, &expected[index])); ++index; running = index < count; diff --git a/tests/array/test_str8_array.cc b/tests/array/test_str8_array.cc index e099f03..ee9cdd8 100644 --- a/tests/array/test_str8_array.cc +++ b/tests/array/test_str8_array.cc @@ -7,20 +7,20 @@ TestFuncResult test_str8_array(void) { Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")}; - Str8 str1 = wapp_str8_lit("Hello"); - Str8 str2 = wapp_str8_lit("Hi"); - Str8 str3 = wapp_str8_lit("Bye"); - Str8Array array = wapp_array(Str8, Str8Array, str1, str2, str3); + Str8 str1 = wapp_str8_lit("Hello"); + Str8 str2 = wapp_str8_lit("Hi"); + Str8 str3 = wapp_str8_lit("Bye"); + Str8Array array = wapp_array(Str8, Str8Array, str1, str2, str3); result = array.count == 3 && array.capacity == 8; Str8 *item; - u64 count = array.count; - u64 index = 0; - b8 running = true; + u64 count = array.count; + u64 index = 0; + b8 running = true; while (running) { - item = wapp_array_get(Str8, &array, index); - result = result && item && (wapp_str8_equal(item, &expected[index])); + item = wapp_array_get(Str8, &array, index); + result = result && item && (wapp_str8_equal(item, &expected[index])); ++index; running = index < count; diff --git a/tests/cpath/test_cpath.c b/tests/cpath/test_cpath.c index 8d70a0b..47eb404 100644 --- a/tests/cpath/test_cpath.c +++ b/tests/cpath/test_cpath.c @@ -3,15 +3,15 @@ #include #include -#define MAIN_BUF_SIZE 4096 -#define TMP_BUF_SIZE 1024 +#define MAIN_BUF_SIZE 4096 +#define TMP_BUF_SIZE 1024 TestFuncResult test_cpath_join_path(void) { b8 result; - Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); - Str8 out = wapp_str8_buf(MAIN_BUF_SIZE); - Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); + Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); + Str8 out = wapp_str8_buf(MAIN_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(&tmp, "%c", WAPP_PATH_SEP); @@ -89,8 +89,8 @@ TestFuncResult test_cpath_dirname(void) { b8 result; Str8 *output = NULL; - Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); - Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); + Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); + Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); // CASE 1 wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP); @@ -137,8 +137,8 @@ TestFuncResult test_cpath_dirup(void) { b8 result; Str8 *output = NULL; - Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); - Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); + Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); + Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); // CASE 1 wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP); diff --git a/tests/cpath/test_cpath.cc b/tests/cpath/test_cpath.cc index d28bcca..8ec3e9a 100644 --- a/tests/cpath/test_cpath.cc +++ b/tests/cpath/test_cpath.cc @@ -3,15 +3,15 @@ #include #include -#define MAIN_BUF_SIZE 4096 -#define TMP_BUF_SIZE 1024 +#define MAIN_BUF_SIZE 4096 +#define TMP_BUF_SIZE 1024 TestFuncResult test_cpath_join_path(void) { b8 result; - Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); - Str8 out = wapp_str8_buf(MAIN_BUF_SIZE); - Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); + Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); + Str8 out = wapp_str8_buf(MAIN_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(&tmp, "%c", WAPP_PATH_SEP); @@ -110,8 +110,8 @@ TestFuncResult test_cpath_dirname(void) { b8 result; Str8 *output = nullptr; - Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); - Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); + Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); + Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); // CASE 1 wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP); @@ -123,14 +123,14 @@ TestFuncResult test_cpath_dirname(void) { // CASE 2 wapp_str8_format(&expected, "%s", "."); - Str8 path = wapp_str8_lit("home"); - output = wapp_cpath_dirname(&arena, &path); - result = result && output != nullptr && wapp_str8_equal(output, &expected); + Str8 path = wapp_str8_lit("home"); + output = wapp_cpath_dirname(&arena, &path); + result = result && output != nullptr && wapp_str8_equal(output, &expected); // CASE 3 - path = wapp_str8_lit(""); - output = wapp_cpath_dirname(&arena, &path); - result = result && output != nullptr && wapp_str8_equal(output, &expected); + path = wapp_str8_lit(""); + output = wapp_cpath_dirname(&arena, &path); + result = result && output != nullptr && wapp_str8_equal(output, &expected); // CASE 4 wapp_str8_format(&tmp, "%chome%ctest", WAPP_PATH_SEP, WAPP_PATH_SEP); @@ -160,8 +160,8 @@ TestFuncResult test_cpath_dirup(void) { b8 result; Str8 *output = nullptr; - Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); - Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); + Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); + Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE); // CASE 1 wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP); diff --git a/tests/shell_commander/test_shell_commander.c b/tests/shell_commander/test_shell_commander.c index 2d5f3f7..8371893 100644 --- a/tests/shell_commander/test_shell_commander.c +++ b/tests/shell_commander/test_shell_commander.c @@ -9,9 +9,9 @@ TestFuncResult test_commander_cmd_success(void) { 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")); - CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd); - b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && - result.error == SHELL_ERR_NO_ERROR; + CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd); + b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && + result.error == SHELL_ERR_NO_ERROR; return wapp_tester_result(succeeded); } @@ -20,43 +20,43 @@ TestFuncResult test_commander_cmd_failure(void) { Str8List cmd = wapp_dbl_list(Str8, Str8List); wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_node_from_cstr("grep")); - CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd); - b8 failed = result.exited && result.exit_code != EXIT_SUCCESS && - result.error == SHELL_ERR_NO_ERROR; + CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd); + b8 failed = result.exited && result.exit_code != EXIT_SUCCESS && + result.error == SHELL_ERR_NO_ERROR; return wapp_tester_result(failed); } TestFuncResult test_commander_cmd_out_buf_success(void) { - Str8 buf = wapp_str8_buf(64); - Str8 expected = wapp_str8_buf(64); - char msg[] = "hello world"; + Str8 buf = wapp_str8_buf(64); + Str8 expected = wapp_str8_buf(64); + char msg[] = "hello world"; wapp_str8_copy_cstr_capped(&expected, msg); 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(msg)); - CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); - b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && - result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg)); + CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); + b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && + result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg)); return wapp_tester_result(succeeded); } TestFuncResult test_commander_cmd_out_buf_failure(void) { - Str8 buf = wapp_str8_buf(4); - Str8 expected = wapp_str8_buf(64); - char msg[] = "hello world"; + Str8 buf = wapp_str8_buf(4); + Str8 expected = wapp_str8_buf(64); + char msg[] = "hello world"; wapp_str8_copy_cstr_capped(&expected, msg); 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(msg)); - CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); - b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS && - result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected); + CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); + b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS && + result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected); return wapp_tester_result(failed); } diff --git a/tests/shell_commander/test_shell_commander.cc b/tests/shell_commander/test_shell_commander.cc index 0125108..7b16262 100644 --- a/tests/shell_commander/test_shell_commander.cc +++ b/tests/shell_commander/test_shell_commander.cc @@ -5,64 +5,64 @@ #include TestFuncResult test_commander_cmd_success(void) { - Str8List cmd = wapp_dbl_list(Str8, Str8List); - Str8Node echo = wapp_str8_node_from_cstr("echo"); - Str8Node msg = wapp_str8_node_from_cstr("hello world"); + Str8List cmd = wapp_dbl_list(Str8, Str8List); + Str8Node echo = wapp_str8_node_from_cstr("echo"); + Str8Node msg = wapp_str8_node_from_cstr("hello world"); wapp_dbl_list_push_back(Str8, &cmd, &echo); wapp_dbl_list_push_back(Str8, &cmd, &msg); - CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd); - b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && + CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd); + b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && result.error == SHELL_ERR_NO_ERROR; return wapp_tester_result(succeeded); } TestFuncResult test_commander_cmd_failure(void) { - Str8List cmd = wapp_dbl_list(Str8, Str8List); - Str8Node grep = wapp_str8_node_from_cstr("grep"); + Str8List cmd = wapp_dbl_list(Str8, Str8List); + Str8Node grep = wapp_str8_node_from_cstr("grep"); wapp_dbl_list_push_back(Str8, &cmd, &grep); - CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd); - b8 failed = result.exited && result.exit_code != EXIT_SUCCESS && + CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd); + b8 failed = result.exited && result.exit_code != EXIT_SUCCESS && result.error == SHELL_ERR_NO_ERROR; return wapp_tester_result(failed); } TestFuncResult test_commander_cmd_out_buf_success(void) { - Str8 buf = wapp_str8_buf(64); - Str8 expected = wapp_str8_buf(64); - char msg[] = "hello world"; + Str8 buf = wapp_str8_buf(64); + Str8 expected = wapp_str8_buf(64); + char msg[] = "hello world"; wapp_str8_copy_cstr_capped(&expected, msg); - Str8List cmd = wapp_dbl_list(Str8, Str8List); - Str8Node echo = wapp_str8_node_from_cstr("echo"); - Str8Node arg = wapp_str8_node_from_cstr(msg); + Str8List cmd = wapp_dbl_list(Str8, Str8List); + Str8Node echo = wapp_str8_node_from_cstr("echo"); + Str8Node arg = wapp_str8_node_from_cstr(msg); wapp_dbl_list_push_back(Str8, &cmd, &echo); wapp_dbl_list_push_back(Str8, &cmd, &arg); - CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); - b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && + CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); + b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg)); return wapp_tester_result(succeeded); } TestFuncResult test_commander_cmd_out_buf_failure(void) { - Str8 buf = wapp_str8_buf(4); - Str8 expected = wapp_str8_buf(64); - char msg[] = "hello world"; + Str8 buf = wapp_str8_buf(4); + Str8 expected = wapp_str8_buf(64); + char msg[] = "hello world"; wapp_str8_copy_cstr_capped(&expected, msg); - Str8List cmd = wapp_dbl_list(Str8, Str8List); - Str8Node echo = wapp_str8_node_from_cstr("echo"); - Str8Node arg = wapp_str8_node_from_cstr(msg); + Str8List cmd = wapp_dbl_list(Str8, Str8List); + Str8Node echo = wapp_str8_node_from_cstr("echo"); + Str8Node arg = wapp_str8_node_from_cstr(msg); wapp_dbl_list_push_back(Str8, &cmd, &echo); wapp_dbl_list_push_back(Str8, &cmd, &arg); - CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); - b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS && + CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd); + b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS && result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected); return wapp_tester_result(failed); diff --git a/tests/str8/test_str8.c b/tests/str8/test_str8.c index ce36499..8ef328f 100644 --- a/tests/str8/test_str8.c +++ b/tests/str8/test_str8.c @@ -6,26 +6,26 @@ TestFuncResult test_str8_lit(void) { b8 result; - Str8 s1 = wapp_str8_lit("Hello world"); - result = s1.capacity == 22 && s1.capacity != s1.size; + Str8 s1 = wapp_str8_lit("Hello world"); + result = s1.capacity == 22 && s1.capacity != s1.size; - Str8 s2 = wapp_str8_lit("Different strokes for different folks"); - result = result && s2.capacity == 74 && s2.capacity != s2.size; + Str8 s2 = wapp_str8_lit("Different strokes for different folks"); + result = result && s2.capacity == 74 && s2.capacity != s2.size; - Str8 s3 = wapp_str8_lit("Discretion is the better part of valour"); - result = result && s3.capacity == 78 && s3.capacity != s3.size; + Str8 s3 = wapp_str8_lit("Discretion is the better part of valour"); + result = result && s3.capacity == 78 && s3.capacity != s3.size; - Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view"); - result = result && s4.capacity == 76 && s4.capacity != s4.size; + Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view"); + result = result && s4.capacity == 76 && s4.capacity != s4.size; - Str8 s5 = wapp_str8_lit("Do as I say, not as I do"); - result = result && s5.capacity == 48 && s5.capacity != s5.size; + Str8 s5 = wapp_str8_lit("Do as I say, not as I do"); + result = result && s5.capacity == 48 && s5.capacity != s5.size; - Str8 s6 = wapp_str8_lit("Do as you would be done by"); - result = result && s6.capacity == 52 && s6.capacity != s6.size; + Str8 s6 = wapp_str8_lit("Do as you would be done by"); + result = result && s6.capacity == 52 && s6.capacity != s6.size; - Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you"); - result = result && s7.capacity == 94 && s7.capacity != s7.size; + Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you"); + result = result && s7.capacity == 94 && s7.capacity != s7.size; return wapp_tester_result(result); } @@ -33,26 +33,26 @@ TestFuncResult test_str8_lit(void) { TestFuncResult test_str8_lit_ro(void) { b8 result; - Str8RO s1 = wapp_str8_lit_ro("Hello world"); - result = s1.capacity == 11 && s1.capacity == s1.size; + Str8RO s1 = wapp_str8_lit_ro("Hello world"); + result = s1.capacity == 11 && s1.capacity == s1.size; - Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks"); - result = result && s2.capacity == 37 && s2.capacity == s2.size; + Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks"); + result = result && s2.capacity == 37 && s2.capacity == s2.size; - Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour"); - result = result && s3.capacity == 39 && s3.capacity == s3.size; + Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour"); + result = result && s3.capacity == 39 && s3.capacity == s3.size; - Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view"); - result = result && s4.capacity == 38 && s4.capacity == s4.size; + Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view"); + result = result && s4.capacity == 38 && s4.capacity == s4.size; - Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do"); - result = result && s5.capacity == 24 && s5.capacity == s5.size; + Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do"); + result = result && s5.capacity == 24 && s5.capacity == s5.size; - Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by"); - result = result && s6.capacity == 26 && s6.capacity == s6.size; + Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by"); + result = result && s6.capacity == 26 && s6.capacity == s6.size; - Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); - result = result && s7.capacity == 47 && s7.capacity == s7.size; + Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); + result = result && s7.capacity == 47 && s7.capacity == s7.size; return wapp_tester_result(result); } @@ -60,17 +60,17 @@ TestFuncResult test_str8_lit_ro(void) { TestFuncResult test_str8_buf(void) { b8 result; - Str8 s1 = wapp_str8_buf(1024); - result = s1.capacity == 1024 && s1.size == 0; + Str8 s1 = wapp_str8_buf(1024); + result = s1.capacity == 1024 && s1.size == 0; - Str8 s2 = wapp_str8_buf(2048); - result = result && s2.capacity == 2048 && s2.size == 0; + Str8 s2 = wapp_str8_buf(2048); + result = result && s2.capacity == 2048 && s2.size == 0; - Str8 s3 = wapp_str8_buf(4096); - result = result && s3.capacity == 4096 && s3.size == 0; + Str8 s3 = wapp_str8_buf(4096); + result = result && s3.capacity == 4096 && s3.size == 0; - Str8 s4 = wapp_str8_buf(8192); - result = result && s4.capacity == 8192 && s4.size == 0; + Str8 s4 = wapp_str8_buf(8192); + result = result && s4.capacity == 8192 && s4.size == 0; return wapp_tester_result(result); } @@ -110,9 +110,9 @@ TestFuncResult test_str8_alloc_cstr(void) { return wapp_tester_result(false); } - char *str = "Abdelrahman"; - u64 length = strlen(str); - Str8 *s = wapp_str8_alloc_cstr(&allocator, str); + char *str = "Abdelrahman"; + u64 length = strlen(str); + Str8 *s = wapp_str8_alloc_cstr(&allocator, str); if (!s) { return wapp_tester_result(false); } @@ -131,8 +131,8 @@ TestFuncResult test_str8_alloc_str8(void) { return wapp_tester_result(false); } - Str8 str = wapp_str8_lit("Abdelrahman"); - Str8 *s = wapp_str8_alloc_str8(&allocator, &str); + Str8 str = wapp_str8_lit("Abdelrahman"); + Str8 *s = wapp_str8_alloc_str8(&allocator, &str); if (!s) { return wapp_tester_result(false); } @@ -151,8 +151,8 @@ TestFuncResult test_str8_alloc_substr(void) { return wapp_tester_result(false); } - Str8 str = wapp_str8_lit("Abdelrahman"); - Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8); + Str8 str = wapp_str8_lit("Abdelrahman"); + Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8); if (!s) { return wapp_tester_result(false); } @@ -167,66 +167,66 @@ TestFuncResult test_str8_alloc_substr(void) { TestFuncResult test_str8_get_index_within_bounds(void) { b8 result; - Str8RO s1 = wapp_str8_lit_ro("Hello world"); - result = wapp_str8_get(&s1, 4) == 'o'; + Str8RO s1 = wapp_str8_lit_ro("Hello world"); + result = wapp_str8_get(&s1, 4) == 'o'; - Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks"); - result = result && wapp_str8_get(&s2, 0) == 'D'; + Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks"); + result = result && wapp_str8_get(&s2, 0) == 'D'; - Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour"); - result = result && wapp_str8_get(&s3, 13) == ' '; + Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour"); + result = result && wapp_str8_get(&s3, 13) == ' '; - Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view"); - result = result && wapp_str8_get(&s4, 20) == 'n'; + Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view"); + result = result && wapp_str8_get(&s4, 20) == 'n'; - Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do"); - result = result && wapp_str8_get(&s5, 11) == ','; + Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do"); + result = result && wapp_str8_get(&s5, 11) == ','; - Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by"); - result = result && wapp_str8_get(&s6, 25) == 'y'; + Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by"); + result = result && wapp_str8_get(&s6, 25) == 'y'; - Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); - result = result && wapp_str8_get(&s7, 16) == 's'; + Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); + result = result && wapp_str8_get(&s7, 16) == 's'; return wapp_tester_result(result); } TestFuncResult test_str8_get_index_out_of_bounds(void) { - Str8 s1 = wapp_str8_lit("Hello world"); - b8 result = wapp_str8_get(&s1, 20) == '\0'; + Str8 s1 = wapp_str8_lit("Hello world"); + b8 result = wapp_str8_get(&s1, 20) == '\0'; return wapp_tester_result(result); } TestFuncResult test_str8_set(void) { b8 result; - Str8 s1 = wapp_str8_lit("Hello world"); + Str8 s1 = wapp_str8_lit("Hello world"); wapp_str8_set(&s1, 4, 'f'); - result = wapp_str8_get(&s1, 4) == 'f'; + result = wapp_str8_get(&s1, 4) == 'f'; - Str8 s2 = wapp_str8_lit("Different strokes for different folks"); + Str8 s2 = wapp_str8_lit("Different strokes for different folks"); wapp_str8_set(&s2, 0, 'A'); - result = result && wapp_str8_get(&s2, 0) == 'A'; + result = result && wapp_str8_get(&s2, 0) == 'A'; - Str8 s3 = wapp_str8_lit("Discretion is the better part of valour"); + Str8 s3 = wapp_str8_lit("Discretion is the better part of valour"); wapp_str8_set(&s3, 13, 'u'); - result = result && wapp_str8_get(&s3, 13) == 'u'; + result = result && wapp_str8_get(&s3, 13) == 'u'; - Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view"); + Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view"); wapp_str8_set(&s4, 20, 'R'); - result = result && wapp_str8_get(&s4, 20) == 'R'; + result = result && wapp_str8_get(&s4, 20) == 'R'; - Str8 s5 = wapp_str8_lit("Do as I say, not as I do"); + Str8 s5 = wapp_str8_lit("Do as I say, not as I do"); wapp_str8_set(&s5, 11, '.'); - result = result && wapp_str8_get(&s5, 11) == '.'; + result = result && wapp_str8_get(&s5, 11) == '.'; - Str8 s6 = wapp_str8_lit("Do as you would be done by"); + Str8 s6 = wapp_str8_lit("Do as you would be done by"); wapp_str8_set(&s6, 25, 'w'); - result = result && wapp_str8_get(&s6, 25) == 'w'; + result = result && wapp_str8_get(&s6, 25) == 'w'; - Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you"); + Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you"); wapp_str8_set(&s7, 16, 'i'); - result = result && wapp_str8_get(&s7, 16) == 'i'; + result = result && wapp_str8_get(&s7, 16) == 'i'; return wapp_tester_result(result); } @@ -234,8 +234,8 @@ TestFuncResult test_str8_set(void) { TestFuncResult test_str8_push_back(void) { b8 result; - Str8 expected = wapp_str8_lit("Abdelrahman"); - Str8 buf = wapp_str8_buf(64); + Str8 expected = wapp_str8_lit("Abdelrahman"); + Str8 buf = wapp_str8_buf(64); wapp_str8_push_back(&buf, 'A'); wapp_str8_push_back(&buf, 'b'); wapp_str8_push_back(&buf, 'd'); @@ -291,11 +291,11 @@ TestFuncResult test_str8_alloc_concat(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("Hello world"); - Str8 suffix1 = wapp_str8_lit(" from me."); - Str8 suffix2 = wapp_str8_lit(" This is my code."); - Str8 concat1 = wapp_str8_lit("Hello world from me."); - Str8 concat2 = wapp_str8_lit("Hello world from me. This is my code."); + Str8 str = wapp_str8_lit("Hello world"); + Str8 suffix1 = wapp_str8_lit(" from me."); + Str8 suffix2 = wapp_str8_lit(" This is my code."); + Str8 concat1 = wapp_str8_lit("Hello world from me."); + Str8 concat2 = wapp_str8_lit("Hello world from me. This is my code."); Str8 *output; @@ -313,11 +313,11 @@ TestFuncResult test_str8_alloc_concat(void) { TestFuncResult test_str8_concat_capped(void) { b8 result; - Str8 str = wapp_str8_lit("Hello world"); - Str8 suffix1 = wapp_str8_lit(" from me."); - Str8 suffix2 = wapp_str8_lit(" This is my code."); - Str8 concat1 = wapp_str8_lit("Hello world from me."); - Str8 concat2 = wapp_str8_lit("Hello world from me. T"); + Str8 str = wapp_str8_lit("Hello world"); + Str8 suffix1 = wapp_str8_lit(" from me."); + Str8 suffix2 = wapp_str8_lit(" This is my code."); + Str8 concat1 = wapp_str8_lit("Hello world from me."); + Str8 concat2 = wapp_str8_lit("Hello world from me. T"); wapp_str8_concat_capped(&str, &suffix1); result = str.size == concat1.size && wapp_str8_equal(&str, &concat1); @@ -331,11 +331,11 @@ TestFuncResult test_str8_concat_capped(void) { TestFuncResult test_str8_copy_cstr_capped(void) { b8 result; - Str8 buf = wapp_str8_buf(32); - const char *src1 = "Hello world"; - const char *src2 = "Hello world from the Wizard Apprentice standard library"; - Str8RO src1_cp = wapp_str8_lit_ro("Hello world"); - Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr"); + Str8 buf = wapp_str8_buf(32); + const char *src1 = "Hello world"; + const char *src2 = "Hello world from the Wizard Apprentice standard library"; + Str8RO src1_cp = wapp_str8_lit_ro("Hello world"); + Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr"); wapp_str8_copy_cstr_capped(&buf, src1); result = buf.size == src1_cp.size && wapp_str8_equal(&buf, &src1_cp); @@ -349,10 +349,10 @@ TestFuncResult test_str8_copy_cstr_capped(void) { TestFuncResult test_str8_copy_str8_capped(void) { b8 result; - Str8 buf = wapp_str8_buf(32); - Str8RO src1 = wapp_str8_lit_ro("Hello world"); - Str8RO src2 = wapp_str8_lit_ro("Hello world from the Wizard Apprentice standard library"); - Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr"); + Str8 buf = wapp_str8_buf(32); + Str8RO src1 = wapp_str8_lit_ro("Hello world"); + Str8RO src2 = wapp_str8_lit_ro("Hello world from the Wizard Apprentice standard library"); + Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr"); wapp_str8_copy_str8_capped(&buf, &src1); result = buf.size == src1.size && wapp_str8_equal(&buf, &src1); @@ -366,8 +366,8 @@ TestFuncResult test_str8_copy_str8_capped(void) { TestFuncResult test_str8_format(void) { b8 result; - Str8 buf = wapp_str8_buf(128); - Str8 expected = wapp_str8_lit("My name is Abdelrahman and I am 35 years old"); + Str8 buf = wapp_str8_buf(128); + Str8 expected = wapp_str8_lit("My name is Abdelrahman and I am 35 years old"); wapp_str8_format(&buf, "My name is %s and I am %u years old", "Abdelrahman", 35); @@ -412,11 +412,11 @@ TestFuncResult test_str8_split(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("hello world from me"); - Str8 delim1 = wapp_str8_lit(" "); - Str8 delim2 = wapp_str8_lit("from"); - Str8List *list1 = wapp_str8_split(&arena, &str, &delim1); - Str8List *list2 = wapp_str8_split(&arena, &str, &delim2); + Str8 str = wapp_str8_lit("hello world from me"); + Str8 delim1 = wapp_str8_lit(" "); + Str8 delim2 = wapp_str8_lit("from"); + Str8List *list1 = wapp_str8_split(&arena, &str, &delim1); + Str8List *list2 = wapp_str8_split(&arena, &str, &delim2); Str8RO splits1[] = { wapp_str8_slice(&str, 0, 5), @@ -429,13 +429,13 @@ TestFuncResult test_str8_split(void) { wapp_str8_slice(&str, 16, 19), }; - u64 index1 = 0; - u64 count1 = ARRLEN(splits1); - b8 running1 = true; + u64 index1 = 0; + u64 count1 = ARRLEN(splits1); + b8 running1 = true; - u64 index2 = 0; - u64 count2 = ARRLEN(splits2); - b8 running2 = true; + u64 index2 = 0; + u64 count2 = ARRLEN(splits2); + b8 running2 = true; result = list1->node_count == count1 && wapp_str8_list_total_size(list1) == str.size - 3; result = result && list2->node_count == count2 && wapp_str8_list_total_size(list2) == str.size - 4; @@ -469,9 +469,9 @@ TestFuncResult test_str8_split_with_max(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("hello world from me"); - Str8 delim = wapp_str8_lit(" "); - Str8List *list = wapp_str8_split_with_max(&arena, &str, &delim, 2); + Str8 str = wapp_str8_lit("hello world from me"); + Str8 delim = wapp_str8_lit(" "); + Str8List *list = wapp_str8_split_with_max(&arena, &str, &delim, 2); Str8RO splits[] = { wapp_str8_slice(&str, 0, 5), @@ -479,9 +479,9 @@ TestFuncResult test_str8_split_with_max(void) { wapp_str8_slice(&str, 12, 19), }; - u64 index = 0; - u64 count = ARRLEN(splits); - b8 running = true; + u64 index = 0; + u64 count = ARRLEN(splits); + b8 running = true; result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2; @@ -504,11 +504,11 @@ TestFuncResult test_str8_rsplit(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("hello world from me"); - Str8 delim1 = wapp_str8_lit(" "); - Str8 delim2 = wapp_str8_lit("from"); - Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1); - Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2); + Str8 str = wapp_str8_lit("hello world from me"); + Str8 delim1 = wapp_str8_lit(" "); + Str8 delim2 = wapp_str8_lit("from"); + Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1); + Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2); Str8RO splits1[] = { wapp_str8_slice(&str, 0, 5), @@ -521,13 +521,13 @@ TestFuncResult test_str8_rsplit(void) { wapp_str8_slice(&str, 16, 19), }; - u64 index1 = 0; - u64 count1 = ARRLEN(splits1); - b8 running1 = true; + u64 index1 = 0; + u64 count1 = ARRLEN(splits1); + b8 running1 = true; - u64 index2 = 0; - u64 count2 = ARRLEN(splits2); - b8 running2 = true; + u64 index2 = 0; + u64 count2 = ARRLEN(splits2); + b8 running2 = true; result = list1->node_count == count1 && wapp_str8_list_total_size(list1) == str.size - 3; result = result && list2->node_count == count2 && wapp_str8_list_total_size(list2) == str.size - 4; @@ -561,9 +561,9 @@ TestFuncResult test_str8_rsplit_with_max(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("hello world from me"); - Str8 delim = wapp_str8_lit(" "); - Str8List *list = wapp_str8_rsplit_with_max(&arena, &str, &delim, 2); + Str8 str = wapp_str8_lit("hello world from me"); + Str8 delim = wapp_str8_lit(" "); + Str8List *list = wapp_str8_rsplit_with_max(&arena, &str, &delim, 2); Str8RO splits[] = { wapp_str8_slice(&str, 0, 11), @@ -571,9 +571,9 @@ TestFuncResult test_str8_rsplit_with_max(void) { wapp_str8_slice(&str, 17, 19), }; - u64 index = 0; - u64 count = ARRLEN(splits); - b8 running = true; + u64 index = 0; + u64 count = ARRLEN(splits); + b8 running = true; result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2; @@ -596,13 +596,13 @@ TestFuncResult test_str8_join(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("hello world from me"); - Str8 delim1 = wapp_str8_lit(" "); - Str8 delim2 = wapp_str8_lit("from"); - Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1); - Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2); - Str8 *join1 = wapp_str8_join(&arena, list1, &delim1); - Str8 *join2 = wapp_str8_join(&arena, list2, &delim2); + Str8 str = wapp_str8_lit("hello world from me"); + Str8 delim1 = wapp_str8_lit(" "); + Str8 delim2 = wapp_str8_lit("from"); + Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1); + Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2); + Str8 *join1 = wapp_str8_join(&arena, list1, &delim1); + Str8 *join2 = wapp_str8_join(&arena, list2, &delim2); result = join1->size == str.size && wapp_str8_equal(join1, &str); result = result && join2->size == str.size && wapp_str8_equal(join2, &str); @@ -615,7 +615,7 @@ TestFuncResult test_str8_join(void) { TestFuncResult test_str8_from_bytes(void) { b8 result; - Str8 str = wapp_str8_buf(1024); + Str8 str = wapp_str8_buf(1024); U8Array bytes = wapp_array(u8, U8Array, 'W', 'A', 'P', 'P'); wapp_str8_from_bytes(&str, &bytes); diff --git a/tests/str8/test_str8.cc b/tests/str8/test_str8.cc index 151fdcb..41c610e 100644 --- a/tests/str8/test_str8.cc +++ b/tests/str8/test_str8.cc @@ -6,26 +6,26 @@ TestFuncResult test_str8_lit(void) { b8 result; - Str8 s1 = wapp_str8_lit("Hello world"); - result = s1.capacity == 22 && s1.capacity != s1.size; + Str8 s1 = wapp_str8_lit("Hello world"); + result = s1.capacity == 22 && s1.capacity != s1.size; - Str8 s2 = wapp_str8_lit("Different strokes for different folks"); - result = result && s2.capacity == 74 && s2.capacity != s2.size; + Str8 s2 = wapp_str8_lit("Different strokes for different folks"); + result = result && s2.capacity == 74 && s2.capacity != s2.size; - Str8 s3 = wapp_str8_lit("Discretion is the better part of valour"); - result = result && s3.capacity == 78 && s3.capacity != s3.size; + Str8 s3 = wapp_str8_lit("Discretion is the better part of valour"); + result = result && s3.capacity == 78 && s3.capacity != s3.size; - Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view"); - result = result && s4.capacity == 76 && s4.capacity != s4.size; + Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view"); + result = result && s4.capacity == 76 && s4.capacity != s4.size; - Str8 s5 = wapp_str8_lit("Do as I say, not as I do"); - result = result && s5.capacity == 48 && s5.capacity != s5.size; + Str8 s5 = wapp_str8_lit("Do as I say, not as I do"); + result = result && s5.capacity == 48 && s5.capacity != s5.size; - Str8 s6 = wapp_str8_lit("Do as you would be done by"); - result = result && s6.capacity == 52 && s6.capacity != s6.size; + Str8 s6 = wapp_str8_lit("Do as you would be done by"); + result = result && s6.capacity == 52 && s6.capacity != s6.size; - Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you"); - result = result && s7.capacity == 94 && s7.capacity != s7.size; + Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you"); + result = result && s7.capacity == 94 && s7.capacity != s7.size; return wapp_tester_result(result); } @@ -33,26 +33,26 @@ TestFuncResult test_str8_lit(void) { TestFuncResult test_str8_lit_ro(void) { b8 result; - Str8RO s1 = wapp_str8_lit_ro("Hello world"); - result = s1.capacity == 11 && s1.capacity == s1.size; + Str8RO s1 = wapp_str8_lit_ro("Hello world"); + result = s1.capacity == 11 && s1.capacity == s1.size; - Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks"); - result = result && s2.capacity == 37 && s2.capacity == s2.size; + Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks"); + result = result && s2.capacity == 37 && s2.capacity == s2.size; - Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour"); - result = result && s3.capacity == 39 && s3.capacity == s3.size; + Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour"); + result = result && s3.capacity == 39 && s3.capacity == s3.size; - Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view"); - result = result && s4.capacity == 38 && s4.capacity == s4.size; + Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view"); + result = result && s4.capacity == 38 && s4.capacity == s4.size; - Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do"); - result = result && s5.capacity == 24 && s5.capacity == s5.size; + Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do"); + result = result && s5.capacity == 24 && s5.capacity == s5.size; - Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by"); - result = result && s6.capacity == 26 && s6.capacity == s6.size; + Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by"); + result = result && s6.capacity == 26 && s6.capacity == s6.size; - Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); - result = result && s7.capacity == 47 && s7.capacity == s7.size; + Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); + result = result && s7.capacity == 47 && s7.capacity == s7.size; return wapp_tester_result(result); } @@ -60,17 +60,17 @@ TestFuncResult test_str8_lit_ro(void) { TestFuncResult test_str8_buf(void) { b8 result; - Str8 s1 = wapp_str8_buf(1024); - result = s1.capacity == 1024 && s1.size == 0; + Str8 s1 = wapp_str8_buf(1024); + result = s1.capacity == 1024 && s1.size == 0; - Str8 s2 = wapp_str8_buf(2048); - result = result && s2.capacity == 2048 && s2.size == 0; + Str8 s2 = wapp_str8_buf(2048); + result = result && s2.capacity == 2048 && s2.size == 0; - Str8 s3 = wapp_str8_buf(4096); - result = result && s3.capacity == 4096 && s3.size == 0; + Str8 s3 = wapp_str8_buf(4096); + result = result && s3.capacity == 4096 && s3.size == 0; - Str8 s4 = wapp_str8_buf(8192); - result = result && s4.capacity == 8192 && s4.size == 0; + Str8 s4 = wapp_str8_buf(8192); + result = result && s4.capacity == 8192 && s4.size == 0; return wapp_tester_result(result); } @@ -91,7 +91,7 @@ TestFuncResult test_str8_alloc_buf(void) { return wapp_tester_result(result); } - result = s->capacity == capacity; + result = s->capacity == capacity; const char *cstr = "My name is Abdelrahman"; wapp_str8_copy_cstr_capped(s, cstr); @@ -110,9 +110,9 @@ TestFuncResult test_str8_alloc_cstr(void) { return wapp_tester_result(false); } - const char *str = "Abdelrahman"; - u64 length = strlen(str); - Str8 *s = wapp_str8_alloc_cstr(&allocator, str); + const char *str = "Abdelrahman"; + u64 length = strlen(str); + Str8 *s = wapp_str8_alloc_cstr(&allocator, str); if (!s) { return wapp_tester_result(false); } @@ -131,8 +131,8 @@ TestFuncResult test_str8_alloc_str8(void) { return wapp_tester_result(false); } - Str8 str = wapp_str8_lit("Abdelrahman"); - Str8 *s = wapp_str8_alloc_str8(&allocator, &str); + Str8 str = wapp_str8_lit("Abdelrahman"); + Str8 *s = wapp_str8_alloc_str8(&allocator, &str); if (!s) { return wapp_tester_result(false); } @@ -151,8 +151,8 @@ TestFuncResult test_str8_alloc_substr(void) { return wapp_tester_result(false); } - Str8 str = wapp_str8_lit("Abdelrahman"); - Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8); + Str8 str = wapp_str8_lit("Abdelrahman"); + Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8); if (!s) { return wapp_tester_result(false); } @@ -167,66 +167,66 @@ TestFuncResult test_str8_alloc_substr(void) { TestFuncResult test_str8_get_index_within_bounds(void) { b8 result; - Str8RO s1 = wapp_str8_lit_ro("Hello world"); - result = wapp_str8_get(&s1, 4) == 'o'; + Str8RO s1 = wapp_str8_lit_ro("Hello world"); + result = wapp_str8_get(&s1, 4) == 'o'; - Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks"); - result = result && wapp_str8_get(&s2, 0) == 'D'; + Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks"); + result = result && wapp_str8_get(&s2, 0) == 'D'; - Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour"); - result = result && wapp_str8_get(&s3, 13) == ' '; + Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour"); + result = result && wapp_str8_get(&s3, 13) == ' '; - Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view"); - result = result && wapp_str8_get(&s4, 20) == 'n'; + Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view"); + result = result && wapp_str8_get(&s4, 20) == 'n'; - Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do"); - result = result && wapp_str8_get(&s5, 11) == ','; + Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do"); + result = result && wapp_str8_get(&s5, 11) == ','; - Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by"); - result = result && wapp_str8_get(&s6, 25) == 'y'; + Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by"); + result = result && wapp_str8_get(&s6, 25) == 'y'; - Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); - result = result && wapp_str8_get(&s7, 16) == 's'; + Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); + result = result && wapp_str8_get(&s7, 16) == 's'; return wapp_tester_result(result); } TestFuncResult test_str8_get_index_out_of_bounds(void) { - Str8 s1 = wapp_str8_lit("Hello world"); - b8 result = wapp_str8_get(&s1, 20) == '\0'; + Str8 s1 = wapp_str8_lit("Hello world"); + b8 result = wapp_str8_get(&s1, 20) == '\0'; return wapp_tester_result(result); } TestFuncResult test_str8_set(void) { b8 result; - Str8 s1 = wapp_str8_lit("Hello world"); + Str8 s1 = wapp_str8_lit("Hello world"); wapp_str8_set(&s1, 4, 'f'); - result = wapp_str8_get(&s1, 4) == 'f'; + result = wapp_str8_get(&s1, 4) == 'f'; - Str8 s2 = wapp_str8_lit("Different strokes for different folks"); + Str8 s2 = wapp_str8_lit("Different strokes for different folks"); wapp_str8_set(&s2, 0, 'A'); - result = result && wapp_str8_get(&s2, 0) == 'A'; + result = result && wapp_str8_get(&s2, 0) == 'A'; - Str8 s3 = wapp_str8_lit("Discretion is the better part of valour"); + Str8 s3 = wapp_str8_lit("Discretion is the better part of valour"); wapp_str8_set(&s3, 13, 'u'); - result = result && wapp_str8_get(&s3, 13) == 'u'; + result = result && wapp_str8_get(&s3, 13) == 'u'; - Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view"); + Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view"); wapp_str8_set(&s4, 20, 'R'); - result = result && wapp_str8_get(&s4, 20) == 'R'; + result = result && wapp_str8_get(&s4, 20) == 'R'; - Str8 s5 = wapp_str8_lit("Do as I say, not as I do"); + Str8 s5 = wapp_str8_lit("Do as I say, not as I do"); wapp_str8_set(&s5, 11, '.'); - result = result && wapp_str8_get(&s5, 11) == '.'; + result = result && wapp_str8_get(&s5, 11) == '.'; - Str8 s6 = wapp_str8_lit("Do as you would be done by"); + Str8 s6 = wapp_str8_lit("Do as you would be done by"); wapp_str8_set(&s6, 25, 'w'); - result = result && wapp_str8_get(&s6, 25) == 'w'; + result = result && wapp_str8_get(&s6, 25) == 'w'; - Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you"); + Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you"); wapp_str8_set(&s7, 16, 'i'); - result = result && wapp_str8_get(&s7, 16) == 'i'; + result = result && wapp_str8_get(&s7, 16) == 'i'; return wapp_tester_result(result); } @@ -234,8 +234,8 @@ TestFuncResult test_str8_set(void) { TestFuncResult test_str8_push_back(void) { b8 result; - Str8 expected = wapp_str8_lit("Abdelrahman"); - Str8 buf = wapp_str8_buf(64); + Str8 expected = wapp_str8_lit("Abdelrahman"); + Str8 buf = wapp_str8_buf(64); wapp_str8_push_back(&buf, 'A'); wapp_str8_push_back(&buf, 'b'); wapp_str8_push_back(&buf, 'd'); @@ -291,11 +291,11 @@ TestFuncResult test_str8_alloc_concat(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("Hello world"); - Str8 suffix1 = wapp_str8_lit(" from me."); - Str8 suffix2 = wapp_str8_lit(" This is my code."); - Str8 concat1 = wapp_str8_lit("Hello world from me."); - Str8 concat2 = wapp_str8_lit("Hello world from me. This is my code."); + Str8 str = wapp_str8_lit("Hello world"); + Str8 suffix1 = wapp_str8_lit(" from me."); + Str8 suffix2 = wapp_str8_lit(" This is my code."); + Str8 concat1 = wapp_str8_lit("Hello world from me."); + Str8 concat2 = wapp_str8_lit("Hello world from me. This is my code."); Str8 *output; @@ -313,11 +313,11 @@ TestFuncResult test_str8_alloc_concat(void) { TestFuncResult test_str8_concat_capped(void) { b8 result; - Str8 str = wapp_str8_lit("Hello world"); - Str8 suffix1 = wapp_str8_lit(" from me."); - Str8 suffix2 = wapp_str8_lit(" This is my code."); - Str8 concat1 = wapp_str8_lit("Hello world from me."); - Str8 concat2 = wapp_str8_lit("Hello world from me. T"); + Str8 str = wapp_str8_lit("Hello world"); + Str8 suffix1 = wapp_str8_lit(" from me."); + Str8 suffix2 = wapp_str8_lit(" This is my code."); + Str8 concat1 = wapp_str8_lit("Hello world from me."); + Str8 concat2 = wapp_str8_lit("Hello world from me. T"); wapp_str8_concat_capped(&str, &suffix1); result = str.size == concat1.size && wapp_str8_equal(&str, &concat1); @@ -331,11 +331,11 @@ TestFuncResult test_str8_concat_capped(void) { TestFuncResult test_str8_copy_cstr_capped(void) { b8 result; - Str8 buf = wapp_str8_buf(32); - const char *src1 = "Hello world"; - const char *src2 = "Hello world from the Wizard Apprentice standard library"; - Str8RO src1_cp = wapp_str8_lit_ro("Hello world"); - Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr"); + Str8 buf = wapp_str8_buf(32); + const char *src1 = "Hello world"; + const char *src2 = "Hello world from the Wizard Apprentice standard library"; + Str8RO src1_cp = wapp_str8_lit_ro("Hello world"); + Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr"); wapp_str8_copy_cstr_capped(&buf, src1); result = buf.size == src1_cp.size && wapp_str8_equal(&buf, &src1_cp); @@ -349,10 +349,10 @@ TestFuncResult test_str8_copy_cstr_capped(void) { TestFuncResult test_str8_copy_str8_capped(void) { b8 result; - Str8 buf = wapp_str8_buf(32); - Str8RO src1 = wapp_str8_lit_ro("Hello world"); - Str8RO src2 = wapp_str8_lit_ro("Hello world from the Wizard Apprentice standard library"); - Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr"); + Str8 buf = wapp_str8_buf(32); + Str8RO src1 = wapp_str8_lit_ro("Hello world"); + Str8RO src2 = wapp_str8_lit_ro("Hello world from the Wizard Apprentice standard library"); + Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr"); wapp_str8_copy_str8_capped(&buf, &src1); result = buf.size == src1.size && wapp_str8_equal(&buf, &src1); @@ -366,8 +366,8 @@ TestFuncResult test_str8_copy_str8_capped(void) { TestFuncResult test_str8_format(void) { b8 result; - Str8 buf = wapp_str8_buf(128); - Str8 expected = wapp_str8_lit("My name is Abdelrahman and I am 35 years old"); + Str8 buf = wapp_str8_buf(128); + Str8 expected = wapp_str8_lit("My name is Abdelrahman and I am 35 years old"); wapp_str8_format(&buf, "My name is %s and I am %u years old", "Abdelrahman", 35); @@ -412,11 +412,11 @@ TestFuncResult test_str8_split(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("hello world from me"); - Str8 delim1 = wapp_str8_lit(" "); - Str8 delim2 = wapp_str8_lit("from"); - Str8List *list1 = wapp_str8_split(&arena, &str, &delim1); - Str8List *list2 = wapp_str8_split(&arena, &str, &delim2); + Str8 str = wapp_str8_lit("hello world from me"); + Str8 delim1 = wapp_str8_lit(" "); + Str8 delim2 = wapp_str8_lit("from"); + Str8List *list1 = wapp_str8_split(&arena, &str, &delim1); + Str8List *list2 = wapp_str8_split(&arena, &str, &delim2); Str8RO splits1[] = { wapp_str8_slice(&str, 0, 5), @@ -429,13 +429,13 @@ TestFuncResult test_str8_split(void) { wapp_str8_slice(&str, 16, 19), }; - u64 index1 = 0; - u64 count1 = ARRLEN(splits1); - b8 running1 = true; + u64 index1 = 0; + u64 count1 = ARRLEN(splits1); + b8 running1 = true; - u64 index2 = 0; - u64 count2 = ARRLEN(splits2); - b8 running2 = true; + u64 index2 = 0; + u64 count2 = ARRLEN(splits2); + b8 running2 = true; result = list1->node_count == count1 && wapp_str8_list_total_size(list1) == str.size - 3; result = result && list2->node_count == count2 && wapp_str8_list_total_size(list2) == str.size - 4; @@ -469,9 +469,9 @@ TestFuncResult test_str8_split_with_max(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("hello world from me"); - Str8 delim = wapp_str8_lit(" "); - Str8List *list = wapp_str8_split_with_max(&arena, &str, &delim, 2); + Str8 str = wapp_str8_lit("hello world from me"); + Str8 delim = wapp_str8_lit(" "); + Str8List *list = wapp_str8_split_with_max(&arena, &str, &delim, 2); Str8RO splits[] = { wapp_str8_slice(&str, 0, 5), @@ -479,9 +479,9 @@ TestFuncResult test_str8_split_with_max(void) { wapp_str8_slice(&str, 12, 19), }; - u64 index = 0; - u64 count = ARRLEN(splits); - b8 running = true; + u64 index = 0; + u64 count = ARRLEN(splits); + b8 running = true; result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2; @@ -504,11 +504,11 @@ TestFuncResult test_str8_rsplit(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("hello world from me"); - Str8 delim1 = wapp_str8_lit(" "); - Str8 delim2 = wapp_str8_lit("from"); - Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1); - Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2); + Str8 str = wapp_str8_lit("hello world from me"); + Str8 delim1 = wapp_str8_lit(" "); + Str8 delim2 = wapp_str8_lit("from"); + Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1); + Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2); Str8RO splits1[] = { wapp_str8_slice(&str, 0, 5), @@ -521,13 +521,13 @@ TestFuncResult test_str8_rsplit(void) { wapp_str8_slice(&str, 16, 19), }; - u64 index1 = 0; - u64 count1 = ARRLEN(splits1); - b8 running1 = true; + u64 index1 = 0; + u64 count1 = ARRLEN(splits1); + b8 running1 = true; - u64 index2 = 0; - u64 count2 = ARRLEN(splits2); - b8 running2 = true; + u64 index2 = 0; + u64 count2 = ARRLEN(splits2); + b8 running2 = true; result = list1->node_count == count1 && wapp_str8_list_total_size(list1) == str.size - 3; result = result && list2->node_count == count2 && wapp_str8_list_total_size(list2) == str.size - 4; @@ -561,9 +561,9 @@ TestFuncResult test_str8_rsplit_with_max(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("hello world from me"); - Str8 delim = wapp_str8_lit(" "); - Str8List *list = wapp_str8_rsplit_with_max(&arena, &str, &delim, 2); + Str8 str = wapp_str8_lit("hello world from me"); + Str8 delim = wapp_str8_lit(" "); + Str8List *list = wapp_str8_rsplit_with_max(&arena, &str, &delim, 2); Str8RO splits[] = { wapp_str8_slice(&str, 0, 11), @@ -571,9 +571,9 @@ TestFuncResult test_str8_rsplit_with_max(void) { wapp_str8_slice(&str, 17, 19), }; - u64 index = 0; - u64 count = ARRLEN(splits); - b8 running = true; + u64 index = 0; + u64 count = ARRLEN(splits); + b8 running = true; result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2; @@ -596,13 +596,13 @@ TestFuncResult test_str8_join(void) { b8 result; Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); - Str8 str = wapp_str8_lit("hello world from me"); - Str8 delim1 = wapp_str8_lit(" "); - Str8 delim2 = wapp_str8_lit("from"); - Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1); - Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2); - Str8 *join1 = wapp_str8_join(&arena, list1, &delim1); - Str8 *join2 = wapp_str8_join(&arena, list2, &delim2); + Str8 str = wapp_str8_lit("hello world from me"); + Str8 delim1 = wapp_str8_lit(" "); + Str8 delim2 = wapp_str8_lit("from"); + Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1); + Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2); + Str8 *join1 = wapp_str8_join(&arena, list1, &delim1); + Str8 *join2 = wapp_str8_join(&arena, list2, &delim2); result = join1->size == str.size && wapp_str8_equal(join1, &str); result = result && join2->size == str.size && wapp_str8_equal(join2, &str); @@ -615,9 +615,9 @@ TestFuncResult test_str8_join(void) { TestFuncResult test_str8_from_bytes(void) { b8 result; - Str8 str = wapp_str8_buf(1024); - Str8 expected = wapp_str8_lit_ro("WAPP"); - U8Array bytes = wapp_array(u8, U8Array, 'W', 'A', 'P', 'P'); + Str8 str = wapp_str8_buf(1024); + Str8 expected = wapp_str8_lit_ro("WAPP"); + U8Array bytes = wapp_array(u8, U8Array, 'W', 'A', 'P', 'P'); wapp_str8_from_bytes(&str, &bytes); result = str.size == bytes.count * bytes.item_size; diff --git a/tests/str8/test_str8_list.c b/tests/str8/test_str8_list.c index 62a07f2..1386007 100644 --- a/tests/str8/test_str8_list.c +++ b/tests/str8/test_str8_list.c @@ -10,12 +10,12 @@ TestFuncResult test_str8_list_get(void) { Str8 s4 = wapp_str8_lit("4"); Str8 s5 = wapp_str8_lit("5"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); - Str8Node n4 = wapp_str8_node_from_str8(s4); - Str8Node n5 = wapp_str8_node_from_str8(s5); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8Node n4 = wapp_str8_node_from_str8(s4); + Str8Node n5 = wapp_str8_node_from_str8(s5); wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n2); @@ -26,17 +26,17 @@ TestFuncResult test_str8_list_get(void) { Str8Node *node = wapp_dbl_list_get(Str8, Str8Node, &list, 0); result = node->item == &s1 && wapp_str8_equal(node->item, &s1); - node = wapp_dbl_list_get(Str8, Str8Node, &list, 1); - result = result && node->item == &s2 && wapp_str8_equal(node->item, &s2); + node = wapp_dbl_list_get(Str8, Str8Node, &list, 1); + result = result && node->item == &s2 && wapp_str8_equal(node->item, &s2); - node = wapp_dbl_list_get(Str8, Str8Node, &list, 2); - result = result && node->item == &s3 && wapp_str8_equal(node->item, &s3); + node = wapp_dbl_list_get(Str8, Str8Node, &list, 2); + result = result && node->item == &s3 && wapp_str8_equal(node->item, &s3); - node = wapp_dbl_list_get(Str8, Str8Node, &list, 3); - result = result && node->item == &s4 && wapp_str8_equal(node->item, &s4); + node = wapp_dbl_list_get(Str8, Str8Node, &list, 3); + result = result && node->item == &s4 && wapp_str8_equal(node->item, &s4); - node = wapp_dbl_list_get(Str8, Str8Node, &list, 4); - result = result && node->item == &s5 && wapp_str8_equal(node->item, &s5); + node = wapp_dbl_list_get(Str8, Str8Node, &list, 4); + result = result && node->item == &s5 && wapp_str8_equal(node->item, &s5); return wapp_tester_result(result); } @@ -48,10 +48,10 @@ TestFuncResult test_str8_list_push_front(void) { Str8 s2 = wapp_str8_lit("2"); Str8 s3 = wapp_str8_lit("3"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); 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; @@ -72,10 +72,10 @@ TestFuncResult test_str8_list_push_back(void) { Str8 s2 = wapp_str8_lit("2"); Str8 s3 = wapp_str8_lit("3"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); 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; @@ -100,14 +100,14 @@ TestFuncResult test_str8_list_insert(void) { Str8 s6 = wapp_str8_lit("6"); Str8 s7 = wapp_str8_lit("7"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); - Str8Node n4 = wapp_str8_node_from_str8(s4); - Str8Node n5 = wapp_str8_node_from_str8(s5); - Str8Node n6 = wapp_str8_node_from_str8(s6); - Str8Node n7 = wapp_str8_node_from_str8(s7); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8Node n4 = wapp_str8_node_from_str8(s4); + Str8Node n5 = wapp_str8_node_from_str8(s5); + Str8Node n6 = wapp_str8_node_from_str8(s6); + Str8Node n7 = wapp_str8_node_from_str8(s7); wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n2); @@ -117,11 +117,11 @@ TestFuncResult test_str8_list_insert(void) { Str8Node *node; wapp_dbl_list_insert(Str8, &list, &n6, 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; + 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; wapp_dbl_list_insert(Str8, &list, &n7, 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; + 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; return wapp_tester_result(result); } @@ -135,12 +135,12 @@ TestFuncResult test_str8_list_pop_front(void) { Str8 s4 = wapp_str8_lit("4"); Str8 s5 = wapp_str8_lit("5"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); - Str8Node n4 = wapp_str8_node_from_str8(s4); - Str8Node n5 = wapp_str8_node_from_str8(s5); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8Node n4 = wapp_str8_node_from_str8(s4); + Str8Node n5 = wapp_str8_node_from_str8(s5); wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n2); @@ -151,17 +151,17 @@ TestFuncResult test_str8_list_pop_front(void) { 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; - 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; + 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; - 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; + 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; - 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; + 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; - 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; + 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; return wapp_tester_result(result); } @@ -175,12 +175,12 @@ TestFuncResult test_str8_list_pop_back(void) { Str8 s4 = wapp_str8_lit("4"); Str8 s5 = wapp_str8_lit("5"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); - Str8Node n4 = wapp_str8_node_from_str8(s4); - Str8Node n5 = wapp_str8_node_from_str8(s5); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8Node n4 = wapp_str8_node_from_str8(s4); + Str8Node n5 = wapp_str8_node_from_str8(s5); wapp_dbl_list_push_front(Str8, &list, &n1); wapp_dbl_list_push_front(Str8, &list, &n2); @@ -191,17 +191,17 @@ TestFuncResult test_str8_list_pop_back(void) { 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; - 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; + 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; - 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; + 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; - 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; + 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; - 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; + 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; return wapp_tester_result(result); } @@ -215,12 +215,12 @@ TestFuncResult test_str8_list_remove(void) { Str8 s4 = wapp_str8_lit("4"); Str8 s5 = wapp_str8_lit("5"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); - Str8Node n4 = wapp_str8_node_from_str8(s4); - Str8Node n5 = wapp_str8_node_from_str8(s5); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8Node n4 = wapp_str8_node_from_str8(s4); + Str8Node n5 = wapp_str8_node_from_str8(s5); wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n2); @@ -231,17 +231,17 @@ TestFuncResult test_str8_list_remove(void) { 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; - 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; + 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; - 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; + 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; - 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; + 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; - 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; + 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; return wapp_tester_result(result); } diff --git a/tests/str8/test_str8_list.cc b/tests/str8/test_str8_list.cc index b0783cb..d758a03 100644 --- a/tests/str8/test_str8_list.cc +++ b/tests/str8/test_str8_list.cc @@ -10,12 +10,12 @@ TestFuncResult test_str8_list_get(void) { Str8 s4 = wapp_str8_lit("4"); Str8 s5 = wapp_str8_lit("5"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); - Str8Node n4 = wapp_str8_node_from_str8(s4); - Str8Node n5 = wapp_str8_node_from_str8(s5); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8Node n4 = wapp_str8_node_from_str8(s4); + Str8Node n5 = wapp_str8_node_from_str8(s5); wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n2); @@ -26,17 +26,17 @@ TestFuncResult test_str8_list_get(void) { Str8Node *node = wapp_dbl_list_get(Str8, Str8Node, &list, 0); result = node->item == &s1 && wapp_str8_equal(node->item, &s1); - node = wapp_dbl_list_get(Str8, Str8Node, &list, 1); - result = result && node->item == &s2 && wapp_str8_equal(node->item, &s2); + node = wapp_dbl_list_get(Str8, Str8Node, &list, 1); + result = result && node->item == &s2 && wapp_str8_equal(node->item, &s2); - node = wapp_dbl_list_get(Str8, Str8Node, &list, 2); - result = result && node->item == &s3 && wapp_str8_equal(node->item, &s3); + node = wapp_dbl_list_get(Str8, Str8Node, &list, 2); + result = result && node->item == &s3 && wapp_str8_equal(node->item, &s3); - node = wapp_dbl_list_get(Str8, Str8Node, &list, 3); - result = result && node->item == &s4 && wapp_str8_equal(node->item, &s4); + node = wapp_dbl_list_get(Str8, Str8Node, &list, 3); + result = result && node->item == &s4 && wapp_str8_equal(node->item, &s4); - node = wapp_dbl_list_get(Str8, Str8Node, &list, 4); - result = result && node->item == &s5 && wapp_str8_equal(node->item, &s5); + node = wapp_dbl_list_get(Str8, Str8Node, &list, 4); + result = result && node->item == &s5 && wapp_str8_equal(node->item, &s5); return wapp_tester_result(result); } @@ -48,10 +48,10 @@ TestFuncResult test_str8_list_push_front(void) { Str8 s2 = wapp_str8_lit("2"); Str8 s3 = wapp_str8_lit("3"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); 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; @@ -72,10 +72,10 @@ TestFuncResult test_str8_list_push_back(void) { Str8 s2 = wapp_str8_lit("2"); Str8 s3 = wapp_str8_lit("3"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); 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; @@ -100,14 +100,14 @@ TestFuncResult test_str8_list_insert(void) { Str8 s6 = wapp_str8_lit("6"); Str8 s7 = wapp_str8_lit("7"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); - Str8Node n4 = wapp_str8_node_from_str8(s4); - Str8Node n5 = wapp_str8_node_from_str8(s5); - Str8Node n6 = wapp_str8_node_from_str8(s6); - Str8Node n7 = wapp_str8_node_from_str8(s7); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8Node n4 = wapp_str8_node_from_str8(s4); + Str8Node n5 = wapp_str8_node_from_str8(s5); + Str8Node n6 = wapp_str8_node_from_str8(s6); + Str8Node n7 = wapp_str8_node_from_str8(s7); wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n2); @@ -117,11 +117,11 @@ TestFuncResult test_str8_list_insert(void) { Str8Node *node; wapp_dbl_list_insert(Str8, &list, &n6, 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; + 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; wapp_dbl_list_insert(Str8, &list, &n7, 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; + 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; return wapp_tester_result(result); } @@ -135,12 +135,12 @@ TestFuncResult test_str8_list_pop_front(void) { Str8 s4 = wapp_str8_lit("4"); Str8 s5 = wapp_str8_lit("5"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); - Str8Node n4 = wapp_str8_node_from_str8(s4); - Str8Node n5 = wapp_str8_node_from_str8(s5); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8Node n4 = wapp_str8_node_from_str8(s4); + Str8Node n5 = wapp_str8_node_from_str8(s5); wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n2); @@ -151,17 +151,17 @@ TestFuncResult test_str8_list_pop_front(void) { 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; - 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; + 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; - 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; + 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; - 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; + 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; - 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; + 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; return wapp_tester_result(result); } @@ -175,12 +175,12 @@ TestFuncResult test_str8_list_pop_back(void) { Str8 s4 = wapp_str8_lit("4"); Str8 s5 = wapp_str8_lit("5"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); - Str8Node n4 = wapp_str8_node_from_str8(s4); - Str8Node n5 = wapp_str8_node_from_str8(s5); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8Node n4 = wapp_str8_node_from_str8(s4); + Str8Node n5 = wapp_str8_node_from_str8(s5); wapp_dbl_list_push_front(Str8, &list, &n1); wapp_dbl_list_push_front(Str8, &list, &n2); @@ -191,17 +191,17 @@ TestFuncResult test_str8_list_pop_back(void) { 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; - 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; + 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; - 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; + 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; - 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; + 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; - 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; + 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; return wapp_tester_result(result); } @@ -215,12 +215,12 @@ TestFuncResult test_str8_list_remove(void) { Str8 s4 = wapp_str8_lit("4"); Str8 s5 = wapp_str8_lit("5"); - Str8List list = wapp_dbl_list(Str8, Str8List); - Str8Node n1 = wapp_str8_node_from_str8(s1); - Str8Node n2 = wapp_str8_node_from_str8(s2); - Str8Node n3 = wapp_str8_node_from_str8(s3); - Str8Node n4 = wapp_str8_node_from_str8(s4); - Str8Node n5 = wapp_str8_node_from_str8(s5); + Str8List list = wapp_dbl_list(Str8, Str8List); + Str8Node n1 = wapp_str8_node_from_str8(s1); + Str8Node n2 = wapp_str8_node_from_str8(s2); + Str8Node n3 = wapp_str8_node_from_str8(s3); + Str8Node n4 = wapp_str8_node_from_str8(s4); + Str8Node n5 = wapp_str8_node_from_str8(s5); wapp_dbl_list_push_back(Str8, &list, &n1); wapp_dbl_list_push_back(Str8, &list, &n2); @@ -231,17 +231,17 @@ TestFuncResult test_str8_list_remove(void) { 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; - 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; + 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; - 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; + 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; - 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; + 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; - 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; + 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; return wapp_tester_result(result); } diff --git a/tests/wapptest.cc b/tests/wapptest.cc index 11a6e9b..0e09109 100644 --- a/tests/wapptest.cc +++ b/tests/wapptest.cc @@ -27,13 +27,13 @@ int main(void) { test_i32_array_set, test_i32_array_append_capped, test_i32_array_extend_capped, - test_i32_array_clear, - test_i32_array_pop, test_i32_array_copy_capped, test_i32_array_alloc_capacity, test_i32_array_append_alloc, test_i32_array_extend_alloc, test_i32_array_copy_alloc, + test_i32_array_pop, + test_i32_array_clear, test_str8_lit, test_str8_lit_ro, test_str8_buf,