Rename Tester

This commit is contained in:
2026-06-26 15:53:08 +01:00
parent cdca775681
commit 28f95b1d41
34 changed files with 479 additions and 479 deletions
+8 -8
View File
@@ -8,23 +8,23 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
wp_intern void handle_test_result(TestFuncResult result); wp_intern void handleTestResult(WpTestFuncResult result);
void run_tests(TestFunc *func1, ...) { void _runTests(WpTestFunc *func1, ...) {
printf("\n"); printf("\n");
handle_test_result(func1()); handleTestResult(func1());
va_list args; va_list args;
va_start(args, func1); va_start(args, func1);
TestFunc *func = va_arg(args, TestFunc *); WpTestFunc *func = va_arg(args, WpTestFunc *);
while (func) { while (func) {
TestFuncResult result = func(); WpTestFuncResult result = func();
handle_test_result(result); handleTestResult(result);
func = va_arg(args, TestFunc *); func = va_arg(args, WpTestFunc *);
} }
va_end(args); va_end(args);
@@ -32,7 +32,7 @@ void run_tests(TestFunc *func1, ...) {
printf("\n"); printf("\n");
} }
wp_intern void handle_test_result(TestFuncResult result) { wp_intern void handleTestResult(WpTestFuncResult result) {
TerminalColour colour; TerminalColour colour;
Str8 result_text = wapp_str8_buf(64); Str8 result_text = wapp_str8_buf(64);
+7 -7
View File
@@ -10,24 +10,24 @@
#ifdef WP_PLATFORM_CPP #ifdef WP_PLATFORM_CPP
BEGIN_C_LINKAGE BEGIN_C_LINKAGE
#define wapp_tester_result(PASSED) (TestFuncResult{wapp_str8_lit_ro(__func__), PASSED, {}}) #define wpTesterResult(PASSED) (WpTestFuncResult{wapp_str8_lit_ro(__func__), PASSED, {}})
#else #else
#define wapp_tester_result(PASSED) ((TestFuncResult){.name = wapp_str8_lit_ro(__func__), .passed = PASSED}) #define wpTesterResult(PASSED) ((WpTestFuncResult){.name = wapp_str8_lit_ro(__func__), .passed = PASSED})
#endif // !WP_PLATFORM_CPP #endif // !WP_PLATFORM_CPP
#define wapp_tester_run_tests(...) run_tests(__VA_ARGS__, NULL) #define wpTesterRun(...) _runTests(__VA_ARGS__, NULL)
typedef struct TestFuncResult TestFuncResult; typedef struct WpTestFuncResult WpTestFuncResult;
struct TestFuncResult { struct WpTestFuncResult {
Str8 name; Str8 name;
b8 passed; b8 passed;
wpMiscUtilsReservePadding(sizeof(Str8) + sizeof(b8)); wpMiscUtilsReservePadding(sizeof(Str8) + sizeof(b8));
}; };
typedef TestFuncResult(TestFunc)(void); typedef WpTestFuncResult(WpTestFunc)(void);
void run_tests(TestFunc *func1, ...); void _runTests(WpTestFunc *func1, ...);
#ifdef WP_PLATFORM_CPP #ifdef WP_PLATFORM_CPP
END_C_LINKAGE END_C_LINKAGE
+8 -8
View File
@@ -9,7 +9,7 @@
wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {0}; wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {0};
wp_intern Allocator temp_allocator = {0}; wp_intern Allocator temp_allocator = {0};
TestFuncResult test_arena_allocator(void) { WpTestFuncResult test_arena_allocator(void) {
Allocator allocator = wapp_mem_arena_allocator_init(4096); Allocator allocator = wapp_mem_arena_allocator_init(4096);
b8 result = allocator.obj != NULL && allocator.alloc != NULL && b8 result = allocator.obj != NULL && allocator.alloc != NULL &&
allocator.alloc_aligned != NULL && allocator.alloc_aligned != NULL &&
@@ -20,10 +20,10 @@ TestFuncResult test_arena_allocator(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_allocator_with_buffer(void) { WpTestFuncResult test_arena_allocator_with_buffer(void) {
u8 buffer[KiB(4)] = {0}; u8 buffer[KiB(4)] = {0};
Allocator allocator = wapp_mem_arena_allocator_init_with_buffer(buffer, KiB(4)); Allocator allocator = wapp_mem_arena_allocator_init_with_buffer(buffer, KiB(4));
@@ -36,10 +36,10 @@ TestFuncResult test_arena_allocator_with_buffer(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_allocator_temp_begin(void) { WpTestFuncResult test_arena_allocator_temp_begin(void) {
temp_allocator = wapp_mem_arena_allocator_init_with_buffer(temp_buf, TEMP_BUF_SIZE); temp_allocator = wapp_mem_arena_allocator_init_with_buffer(temp_buf, TEMP_BUF_SIZE);
i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32)); i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
@@ -51,10 +51,10 @@ TestFuncResult test_arena_allocator_temp_begin(void) {
i32 *num3 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32)); i32 *num3 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
result = result && num3 == NULL; result = result && num3 == NULL;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_allocator_temp_end(void) { WpTestFuncResult test_arena_allocator_temp_end(void) {
wapp_mem_arena_allocator_temp_end(&temp_allocator); wapp_mem_arena_allocator_temp_end(&temp_allocator);
i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32)); i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
b8 result = num1 != NULL; b8 result = num1 != NULL;
@@ -63,5 +63,5 @@ TestFuncResult test_arena_allocator_temp_end(void) {
wapp_mem_arena_allocator_destroy(&temp_allocator); wapp_mem_arena_allocator_destroy(&temp_allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
+8 -8
View File
@@ -9,7 +9,7 @@
wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {}; wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {};
wp_intern Allocator temp_allocator = {}; wp_intern Allocator temp_allocator = {};
TestFuncResult test_arena_allocator(void) { WpTestFuncResult test_arena_allocator(void) {
Allocator allocator = wapp_mem_arena_allocator_init(4096); Allocator allocator = wapp_mem_arena_allocator_init(4096);
b8 result = allocator.obj != nullptr && allocator.alloc != nullptr && b8 result = allocator.obj != nullptr && allocator.alloc != nullptr &&
allocator.alloc_aligned != nullptr && allocator.alloc_aligned != nullptr &&
@@ -20,10 +20,10 @@ TestFuncResult test_arena_allocator(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_allocator_with_buffer(void) { WpTestFuncResult test_arena_allocator_with_buffer(void) {
u8 buffer[KiB(4)] = {0}; u8 buffer[KiB(4)] = {0};
Allocator allocator = wapp_mem_arena_allocator_init_with_buffer(buffer, KiB(4)); Allocator allocator = wapp_mem_arena_allocator_init_with_buffer(buffer, KiB(4));
@@ -36,10 +36,10 @@ TestFuncResult test_arena_allocator_with_buffer(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_allocator_temp_begin(void) { WpTestFuncResult test_arena_allocator_temp_begin(void) {
temp_allocator = wapp_mem_arena_allocator_init_with_buffer(temp_buf, TEMP_BUF_SIZE); temp_allocator = wapp_mem_arena_allocator_init_with_buffer(temp_buf, TEMP_BUF_SIZE);
i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32)); i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
@@ -51,10 +51,10 @@ TestFuncResult test_arena_allocator_temp_begin(void) {
i32 *num3 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32)); i32 *num3 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
result = result && num3 == NULL; result = result && num3 == NULL;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_allocator_temp_end(void) { WpTestFuncResult test_arena_allocator_temp_end(void) {
wapp_mem_arena_allocator_temp_end(&temp_allocator); wapp_mem_arena_allocator_temp_end(&temp_allocator);
i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32)); i32 *num1 = (i32 *)wapp_mem_allocator_alloc(&temp_allocator, sizeof(i32));
b8 result = num1 != NULL; b8 result = num1 != NULL;
@@ -63,5 +63,5 @@ TestFuncResult test_arena_allocator_temp_end(void) {
wapp_mem_arena_allocator_destroy(&temp_allocator); wapp_mem_arena_allocator_destroy(&temp_allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
+4 -4
View File
@@ -3,9 +3,9 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_arena_allocator(void); WpTestFuncResult test_arena_allocator(void);
TestFuncResult test_arena_allocator_with_buffer(void); WpTestFuncResult test_arena_allocator_with_buffer(void);
TestFuncResult test_arena_allocator_temp_begin(void); WpTestFuncResult test_arena_allocator_temp_begin(void);
TestFuncResult test_arena_allocator_temp_end(void); WpTestFuncResult test_arena_allocator_temp_end(void);
#endif // !TEST_ALLOCATOR_H #endif // !TEST_ALLOCATOR_H
+30 -30
View File
@@ -16,18 +16,18 @@ wp_intern u8 buf[ARENA_BUF_SIZE] = {0};
wp_intern Arena *temp_arena = NULL; wp_intern Arena *temp_arena = NULL;
wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {0}; wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {0};
TestFuncResult test_arena_init_buffer(void) { WpTestFuncResult test_arena_init_buffer(void) {
b8 result = wapp_mem_arena_init_buffer(&buf_arena, buf, ARENA_BUF_SIZE); b8 result = wapp_mem_arena_init_buffer(&buf_arena, buf, ARENA_BUF_SIZE);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_init_allocated(void) { WpTestFuncResult test_arena_init_allocated(void) {
b8 result = wapp_mem_arena_init_allocated(&arena, ARENA_CAPACITY); b8 result = wapp_mem_arena_init_allocated(&arena, ARENA_CAPACITY);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) { WpTestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
Arena *large_arena = NULL; Arena *large_arena = NULL;
u64 capacity = GiB(512); u64 capacity = GiB(512);
b8 result = wapp_mem_arena_init_allocated(&large_arena, capacity); b8 result = wapp_mem_arena_init_allocated(&large_arena, capacity);
@@ -35,10 +35,10 @@ TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
wapp_mem_arena_destroy(&large_arena); wapp_mem_arena_destroy(&large_arena);
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_alloc_with_buffer(void) { WpTestFuncResult test_arena_alloc_with_buffer(void) {
i32 *arr = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32)); i32 *arr = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32));
b8 result = arr != NULL; b8 result = arr != NULL;
@@ -46,10 +46,10 @@ TestFuncResult test_arena_alloc_with_buffer(void) {
arr[i] = i * 10; arr[i] = i * 10;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) { WpTestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
array = wapp_mem_arena_alloc(arena, count * sizeof(i32)); array = wapp_mem_arena_alloc(arena, count * sizeof(i32));
b8 result = array != NULL; b8 result = array != NULL;
@@ -57,17 +57,17 @@ TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
array[i] = i * 10; array[i] = i * 10;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_alloc_fails_when_over_capacity(void) { WpTestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
u8 *bytes = wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2); u8 *bytes = wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2);
b8 result = bytes == NULL; b8 result = bytes == NULL;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_realloc_bigger_size(void) { WpTestFuncResult test_arena_realloc_bigger_size(void) {
u64 old_count = 10; u64 old_count = 10;
u64 new_count = 20; u64 new_count = 20;
i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
@@ -78,19 +78,19 @@ TestFuncResult test_arena_realloc_bigger_size(void) {
i32 *new_bytes = wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32)); i32 *new_bytes = wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
if (!new_bytes) { if (!new_bytes) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
for (u64 i = 0; i < new_count; ++i) { for (u64 i = 0; i < new_count; ++i) {
if (i < old_count && new_bytes[i] != bytes[i]) { if (i < old_count && new_bytes[i] != bytes[i]) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
} }
return wapp_tester_result(true); return wpTesterResult(true);
} }
TestFuncResult test_arena_realloc_smaller_size(void) { WpTestFuncResult test_arena_realloc_smaller_size(void) {
u64 old_count = 10; u64 old_count = 10;
u64 new_count = 5; u64 new_count = 5;
i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
@@ -101,19 +101,19 @@ TestFuncResult test_arena_realloc_smaller_size(void) {
i32 *new_bytes = wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32)); i32 *new_bytes = wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
if (!new_bytes) { if (!new_bytes) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
for (u64 i = 0; i < new_count; ++i) { for (u64 i = 0; i < new_count; ++i) {
if (i < new_count && new_bytes[i] != bytes[i]) { if (i < new_count && new_bytes[i] != bytes[i]) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
} }
return wapp_tester_result(true); return wpTesterResult(true);
} }
TestFuncResult test_arena_temp_begin(void) { WpTestFuncResult test_arena_temp_begin(void) {
b8 result = wapp_mem_arena_init_buffer(&temp_arena, temp_buf, TEMP_BUF_SIZE); b8 result = wapp_mem_arena_init_buffer(&temp_arena, temp_buf, TEMP_BUF_SIZE);
i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32)); i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
result = result && num1 != NULL; result = result && num1 != NULL;
@@ -124,10 +124,10 @@ TestFuncResult test_arena_temp_begin(void) {
i32 *num3 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32)); i32 *num3 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
result = result && num3 == NULL; result = result && num3 == NULL;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_temp_end(void) { WpTestFuncResult test_arena_temp_end(void) {
wapp_mem_arena_temp_end(temp_arena); wapp_mem_arena_temp_end(temp_arena);
i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32)); i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
b8 result = num1 != NULL; b8 result = num1 != NULL;
@@ -136,10 +136,10 @@ TestFuncResult test_arena_temp_end(void) {
wapp_mem_arena_destroy(&temp_arena); wapp_mem_arena_destroy(&temp_arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_clear(void) { WpTestFuncResult test_arena_clear(void) {
wapp_mem_arena_clear(arena); wapp_mem_arena_clear(arena);
b8 result = true; b8 result = true;
@@ -150,19 +150,19 @@ TestFuncResult test_arena_clear(void) {
} }
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_destroy_buffer(void) { WpTestFuncResult test_arena_destroy_buffer(void) {
wapp_mem_arena_destroy(&buf_arena); wapp_mem_arena_destroy(&buf_arena);
b8 result = buf_arena == NULL; b8 result = buf_arena == NULL;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_destroy_allocated(void) { WpTestFuncResult test_arena_destroy_allocated(void) {
wapp_mem_arena_destroy(&arena); wapp_mem_arena_destroy(&arena);
b8 result = arena == NULL; b8 result = arena == NULL;
return wapp_tester_result(result); return wpTesterResult(result);
} }
+30 -30
View File
@@ -16,18 +16,18 @@ wp_intern u8 buf[ARENA_BUF_SIZE] = {};
wp_intern Arena *temp_arena = NULL; wp_intern Arena *temp_arena = NULL;
wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {}; wp_intern u8 temp_buf[TEMP_BUF_SIZE] = {};
TestFuncResult test_arena_init_buffer(void) { WpTestFuncResult test_arena_init_buffer(void) {
b8 result = wapp_mem_arena_init_buffer(&buf_arena, buf, ARENA_BUF_SIZE); b8 result = wapp_mem_arena_init_buffer(&buf_arena, buf, ARENA_BUF_SIZE);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_init_allocated(void) { WpTestFuncResult test_arena_init_allocated(void) {
b8 result = wapp_mem_arena_init_allocated(&arena, ARENA_CAPACITY); b8 result = wapp_mem_arena_init_allocated(&arena, ARENA_CAPACITY);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) { WpTestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
Arena *large_arena = nullptr; Arena *large_arena = nullptr;
u64 capacity = GiB(512); u64 capacity = GiB(512);
b8 result = wapp_mem_arena_init_allocated(&large_arena, capacity); b8 result = wapp_mem_arena_init_allocated(&large_arena, capacity);
@@ -35,10 +35,10 @@ TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
wapp_mem_arena_destroy(&large_arena); wapp_mem_arena_destroy(&large_arena);
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_alloc_with_buffer(void) { WpTestFuncResult test_arena_alloc_with_buffer(void) {
i32 *arr = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32)); i32 *arr = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32));
b8 result = arr != NULL; b8 result = arr != NULL;
@@ -46,10 +46,10 @@ TestFuncResult test_arena_alloc_with_buffer(void) {
arr[i] = i * 10; arr[i] = i * 10;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) { WpTestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
array = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32)); array = (i32 *)wapp_mem_arena_alloc(arena, count * sizeof(i32));
b8 result = array != nullptr; b8 result = array != nullptr;
@@ -57,17 +57,17 @@ TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
array[i] = i * 10; array[i] = i * 10;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_alloc_fails_when_over_capacity(void) { WpTestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
u8 *bytes = (u8 *)wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2); u8 *bytes = (u8 *)wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2);
b8 result = bytes == nullptr; b8 result = bytes == nullptr;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_realloc_bigger_size(void) { WpTestFuncResult test_arena_realloc_bigger_size(void) {
u64 old_count = 10; u64 old_count = 10;
u64 new_count = 20; u64 new_count = 20;
i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
@@ -78,19 +78,19 @@ TestFuncResult test_arena_realloc_bigger_size(void) {
i32 *new_bytes = (i32 *)wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32)); i32 *new_bytes = (i32 *)wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
if (!new_bytes) { if (!new_bytes) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
for (u64 i = 0; i < new_count; ++i) { for (u64 i = 0; i < new_count; ++i) {
if (i < old_count && new_bytes[i] != bytes[i]) { if (i < old_count && new_bytes[i] != bytes[i]) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
} }
return wapp_tester_result(true); return wpTesterResult(true);
} }
TestFuncResult test_arena_realloc_smaller_size(void) { WpTestFuncResult test_arena_realloc_smaller_size(void) {
u64 old_count = 10; u64 old_count = 10;
u64 new_count = 5; u64 new_count = 5;
i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32)); i32 *bytes = (i32 *)wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
@@ -101,19 +101,19 @@ TestFuncResult test_arena_realloc_smaller_size(void) {
i32 *new_bytes = (i32 *)wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32)); i32 *new_bytes = (i32 *)wapp_mem_arena_realloc(arena, bytes, old_count * sizeof(i32), new_count * sizeof(i32));
if (!new_bytes) { if (!new_bytes) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
for (u64 i = 0; i < new_count; ++i) { for (u64 i = 0; i < new_count; ++i) {
if (i < new_count && new_bytes[i] != bytes[i]) { if (i < new_count && new_bytes[i] != bytes[i]) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
} }
return wapp_tester_result(true); return wpTesterResult(true);
} }
TestFuncResult test_arena_temp_begin(void) { WpTestFuncResult test_arena_temp_begin(void) {
b8 result = wapp_mem_arena_init_buffer(&temp_arena, temp_buf, TEMP_BUF_SIZE); b8 result = wapp_mem_arena_init_buffer(&temp_arena, temp_buf, TEMP_BUF_SIZE);
i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32)); i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
result = result && num1 != NULL; result = result && num1 != NULL;
@@ -124,10 +124,10 @@ TestFuncResult test_arena_temp_begin(void) {
i32 *num3 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32)); i32 *num3 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
result = result && num3 == NULL; result = result && num3 == NULL;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_temp_end(void) { WpTestFuncResult test_arena_temp_end(void) {
wapp_mem_arena_temp_end(temp_arena); wapp_mem_arena_temp_end(temp_arena);
i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32)); i32 *num1 = (i32 *)wapp_mem_arena_alloc(temp_arena, sizeof(i32));
b8 result = num1 != NULL; b8 result = num1 != NULL;
@@ -136,10 +136,10 @@ TestFuncResult test_arena_temp_end(void) {
wapp_mem_arena_destroy(&temp_arena); wapp_mem_arena_destroy(&temp_arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_clear(void) { WpTestFuncResult test_arena_clear(void) {
wapp_mem_arena_clear(arena); wapp_mem_arena_clear(arena);
b8 result = true; b8 result = true;
@@ -150,19 +150,19 @@ TestFuncResult test_arena_clear(void) {
} }
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_destroy_buffer(void) { WpTestFuncResult test_arena_destroy_buffer(void) {
wapp_mem_arena_destroy(&buf_arena); wapp_mem_arena_destroy(&buf_arena);
b8 result = buf_arena == NULL; b8 result = buf_arena == NULL;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_arena_destroy_allocated(void) { WpTestFuncResult test_arena_destroy_allocated(void) {
wapp_mem_arena_destroy(&arena); wapp_mem_arena_destroy(&arena);
b8 result = arena == nullptr; b8 result = arena == nullptr;
return wapp_tester_result(result); return wpTesterResult(result);
} }
+13 -13
View File
@@ -3,18 +3,18 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_arena_init_buffer(void); WpTestFuncResult test_arena_init_buffer(void);
TestFuncResult test_arena_init_allocated(void); WpTestFuncResult test_arena_init_allocated(void);
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void); WpTestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void);
TestFuncResult test_arena_alloc_with_buffer(void); WpTestFuncResult test_arena_alloc_with_buffer(void);
TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void); WpTestFuncResult test_arena_alloc_succeeds_when_within_capacity(void);
TestFuncResult test_arena_alloc_fails_when_over_capacity(void); WpTestFuncResult test_arena_alloc_fails_when_over_capacity(void);
TestFuncResult test_arena_realloc_bigger_size(void); WpTestFuncResult test_arena_realloc_bigger_size(void);
TestFuncResult test_arena_realloc_smaller_size(void); WpTestFuncResult test_arena_realloc_smaller_size(void);
TestFuncResult test_arena_clear(void); WpTestFuncResult test_arena_clear(void);
TestFuncResult test_arena_temp_begin(void); WpTestFuncResult test_arena_temp_begin(void);
TestFuncResult test_arena_temp_end(void); WpTestFuncResult test_arena_temp_end(void);
TestFuncResult test_arena_destroy_buffer(void); WpTestFuncResult test_arena_destroy_buffer(void);
TestFuncResult test_arena_destroy_allocated(void); WpTestFuncResult test_arena_destroy_allocated(void);
#endif // !TEST_ARENA_H #endif // !TEST_ARENA_H
+26 -26
View File
@@ -1,7 +1,7 @@
#include "test_i32_array.h" #include "test_i32_array.h"
#include "wapp.h" #include "wapp.h"
TestFuncResult test_i32_array(void) { WpTestFuncResult test_i32_array(void) {
b8 result; b8 result;
I32Array array = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7); I32Array array = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7);
@@ -19,10 +19,10 @@ TestFuncResult test_i32_array(void) {
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_with_capacity(void) { WpTestFuncResult test_i32_array_with_capacity(void) {
b8 result; b8 result;
I32Array array1 = wapp_array_with_capacity(i32, 64, ARRAY_INIT_NONE); I32Array array1 = wapp_array_with_capacity(i32, 64, ARRAY_INIT_NONE);
@@ -31,10 +31,10 @@ TestFuncResult test_i32_array_with_capacity(void) {
I32Array array2 = wapp_array_with_capacity(i32, 64, ARRAY_INIT_FILLED); I32Array array2 = wapp_array_with_capacity(i32, 64, ARRAY_INIT_FILLED);
result = wapp_array_count(array2) == 64 && wapp_array_capacity(array2) == 64; result = wapp_array_count(array2) == 64 && wapp_array_capacity(array2) == 64;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_get(void) { WpTestFuncResult test_i32_array_get(void) {
b8 result = true; b8 result = true;
I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
@@ -51,10 +51,10 @@ TestFuncResult test_i32_array_get(void) {
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_set(void) { WpTestFuncResult test_i32_array_set(void) {
b8 result = true; b8 result = true;
I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
@@ -73,10 +73,10 @@ TestFuncResult test_i32_array_set(void) {
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_append_capped(void) { WpTestFuncResult test_i32_array_append_capped(void) {
b8 result; b8 result;
I32Array array = wapp_array_with_capacity(i32, 64, ARRAY_INIT_NONE); I32Array array = wapp_array_with_capacity(i32, 64, ARRAY_INIT_NONE);
@@ -91,10 +91,10 @@ TestFuncResult test_i32_array_append_capped(void) {
result = result && wapp_array_count(array) == 2; result = result && wapp_array_count(array) == 2;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_extend_capped(void) { WpTestFuncResult test_i32_array_extend_capped(void) {
b8 result; b8 result;
I32Array array1 = wapp_array(i32, 1, 2, 3, 4); I32Array array1 = wapp_array(i32, 1, 2, 3, 4);
@@ -106,10 +106,10 @@ TestFuncResult test_i32_array_extend_capped(void) {
result = result && wapp_array_count(array1) == 6; result = result && wapp_array_count(array1) == 6;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_copy_capped(void) { WpTestFuncResult test_i32_array_copy_capped(void) {
b8 result; b8 result;
I32Array src = wapp_array(i32, 1, 2, 3, 4, 5); I32Array src = wapp_array(i32, 1, 2, 3, 4, 5);
@@ -142,10 +142,10 @@ TestFuncResult test_i32_array_copy_capped(void) {
running = index < expected_count; running = index < expected_count;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_alloc_capacity(void) { WpTestFuncResult test_i32_array_alloc_capacity(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
@@ -156,10 +156,10 @@ TestFuncResult test_i32_array_alloc_capacity(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_append_alloc(void) { WpTestFuncResult test_i32_array_append_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
@@ -183,10 +183,10 @@ TestFuncResult test_i32_array_append_alloc(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_extend_alloc(void) { WpTestFuncResult test_i32_array_extend_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
@@ -202,10 +202,10 @@ TestFuncResult test_i32_array_extend_alloc(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_copy_alloc(void) { WpTestFuncResult test_i32_array_copy_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
@@ -242,10 +242,10 @@ TestFuncResult test_i32_array_copy_alloc(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_pop(void) { WpTestFuncResult test_i32_array_pop(void) {
b8 result; b8 result;
I32Array array1 = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array1 = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
@@ -256,10 +256,10 @@ TestFuncResult test_i32_array_pop(void) {
result = item1 == 8 && item2 == 0; result = item1 == 8 && item2 == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_clear(void) { WpTestFuncResult test_i32_array_clear(void) {
b8 result; b8 result;
I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
@@ -269,5 +269,5 @@ TestFuncResult test_i32_array_clear(void) {
result = result && wapp_array_count(array) == 0; result = result && wapp_array_count(array) == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
+26 -26
View File
@@ -1,7 +1,7 @@
#include "test_i32_array.h" #include "test_i32_array.h"
#include "wapp.h" #include "wapp.h"
TestFuncResult test_i32_array(void) { WpTestFuncResult test_i32_array(void) {
b8 result; b8 result;
I32Array array = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7); I32Array array = wapp_array(i32, 1, 2, 3, 4, 5, 6, 7);
@@ -19,10 +19,10 @@ TestFuncResult test_i32_array(void) {
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_with_capacity(void) { WpTestFuncResult test_i32_array_with_capacity(void) {
b8 result; b8 result;
I32Array array1 = wapp_array_with_capacity(i32, 64, ARRAY_INIT_NONE); I32Array array1 = wapp_array_with_capacity(i32, 64, ARRAY_INIT_NONE);
@@ -31,10 +31,10 @@ TestFuncResult test_i32_array_with_capacity(void) {
I32Array array2 = wapp_array_with_capacity(i32, 64, ARRAY_INIT_FILLED); I32Array array2 = wapp_array_with_capacity(i32, 64, ARRAY_INIT_FILLED);
result = wapp_array_count(array2) == 64 && wapp_array_capacity(array2) == 64; result = wapp_array_count(array2) == 64 && wapp_array_capacity(array2) == 64;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_get(void) { WpTestFuncResult test_i32_array_get(void) {
b8 result = true; b8 result = true;
I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
@@ -51,10 +51,10 @@ TestFuncResult test_i32_array_get(void) {
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_set(void) { WpTestFuncResult test_i32_array_set(void) {
b8 result = true; b8 result = true;
I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
@@ -73,10 +73,10 @@ TestFuncResult test_i32_array_set(void) {
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_append_capped(void) { WpTestFuncResult test_i32_array_append_capped(void) {
b8 result; b8 result;
I32Array array = wapp_array_with_capacity(i32, 64, ARRAY_INIT_NONE); I32Array array = wapp_array_with_capacity(i32, 64, ARRAY_INIT_NONE);
@@ -93,10 +93,10 @@ TestFuncResult test_i32_array_append_capped(void) {
result = result && wapp_array_count(array) == 2; result = result && wapp_array_count(array) == 2;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_extend_capped(void) { WpTestFuncResult test_i32_array_extend_capped(void) {
b8 result; b8 result;
I32Array array1 = wapp_array(i32, 1, 2, 3, 4); I32Array array1 = wapp_array(i32, 1, 2, 3, 4);
@@ -108,10 +108,10 @@ TestFuncResult test_i32_array_extend_capped(void) {
result = result && wapp_array_count(array1) == 6; result = result && wapp_array_count(array1) == 6;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_copy_capped(void) { WpTestFuncResult test_i32_array_copy_capped(void) {
b8 result; b8 result;
I32Array src = wapp_array(i32, 1, 2, 3, 4, 5); I32Array src = wapp_array(i32, 1, 2, 3, 4, 5);
@@ -144,10 +144,10 @@ TestFuncResult test_i32_array_copy_capped(void) {
running = index < expected_count; running = index < expected_count;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_alloc_capacity(void) { WpTestFuncResult test_i32_array_alloc_capacity(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
@@ -158,10 +158,10 @@ TestFuncResult test_i32_array_alloc_capacity(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_append_alloc(void) { WpTestFuncResult test_i32_array_append_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
@@ -186,10 +186,10 @@ TestFuncResult test_i32_array_append_alloc(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_extend_alloc(void) { WpTestFuncResult test_i32_array_extend_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
@@ -205,10 +205,10 @@ TestFuncResult test_i32_array_extend_alloc(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_copy_alloc(void) { WpTestFuncResult test_i32_array_copy_alloc(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(MiB(4)); Allocator allocator = wapp_mem_arena_allocator_init(MiB(4));
@@ -245,10 +245,10 @@ TestFuncResult test_i32_array_copy_alloc(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_clear(void) { WpTestFuncResult test_i32_array_clear(void) {
b8 result; b8 result;
I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
@@ -258,10 +258,10 @@ TestFuncResult test_i32_array_clear(void) {
result = result && wapp_array_count(array) == 0; result = result && wapp_array_count(array) == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_i32_array_pop(void) { WpTestFuncResult test_i32_array_pop(void) {
b8 result; b8 result;
I32Array array1 = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8); I32Array array1 = wapp_array(i32, 0, 1, 2, 3, 4, 5, 6, 7, 8);
@@ -272,5 +272,5 @@ TestFuncResult test_i32_array_pop(void) {
result = item1 == 8 && item2 == 0; result = item1 == 8 && item2 == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
+13 -13
View File
@@ -3,18 +3,18 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_i32_array(void); WpTestFuncResult test_i32_array(void);
TestFuncResult test_i32_array_with_capacity(void); WpTestFuncResult test_i32_array_with_capacity(void);
TestFuncResult test_i32_array_get(void); WpTestFuncResult test_i32_array_get(void);
TestFuncResult test_i32_array_set(void); WpTestFuncResult test_i32_array_set(void);
TestFuncResult test_i32_array_append_capped(void); WpTestFuncResult test_i32_array_append_capped(void);
TestFuncResult test_i32_array_extend_capped(void); WpTestFuncResult test_i32_array_extend_capped(void);
TestFuncResult test_i32_array_copy_capped(void); WpTestFuncResult test_i32_array_copy_capped(void);
TestFuncResult test_i32_array_alloc_capacity(void); WpTestFuncResult test_i32_array_alloc_capacity(void);
TestFuncResult test_i32_array_append_alloc(void); WpTestFuncResult test_i32_array_append_alloc(void);
TestFuncResult test_i32_array_extend_alloc(void); WpTestFuncResult test_i32_array_extend_alloc(void);
TestFuncResult test_i32_array_copy_alloc(void); WpTestFuncResult test_i32_array_copy_alloc(void);
TestFuncResult test_i32_array_pop(void); WpTestFuncResult test_i32_array_pop(void);
TestFuncResult test_i32_array_clear(void); WpTestFuncResult test_i32_array_clear(void);
#endif // !TEST_INT_ARRAY_H #endif // !TEST_INT_ARRAY_H
+2 -2
View File
@@ -2,7 +2,7 @@
#include "test_str8_array.h" #include "test_str8_array.h"
TestFuncResult test_str8_array(void) { WpTestFuncResult test_str8_array(void) {
b8 result; b8 result;
Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")}; Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")};
@@ -21,5 +21,5 @@ TestFuncResult test_str8_array(void) {
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
+2 -2
View File
@@ -2,7 +2,7 @@
#include "test_str8_array.h" #include "test_str8_array.h"
TestFuncResult test_str8_array(void) { WpTestFuncResult test_str8_array(void) {
b8 result; b8 result;
Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")}; Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")};
@@ -26,5 +26,5 @@ TestFuncResult test_str8_array(void) {
running = index < count; running = index < count;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
+1 -1
View File
@@ -5,6 +5,6 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_str8_array(void); WpTestFuncResult test_str8_array(void);
#endif // !TEST_STR8_ARRAY_H #endif // !TEST_STR8_ARRAY_H
+8 -8
View File
@@ -6,7 +6,7 @@
#define MAIN_BUF_SIZE 4096 #define MAIN_BUF_SIZE 4096
#define TMP_BUF_SIZE 1024 #define TMP_BUF_SIZE 1024
TestFuncResult test_cpath_join_path(void) { WpTestFuncResult test_cpath_join_path(void) {
b8 result; b8 result;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
@@ -77,13 +77,13 @@ TestFuncResult test_cpath_join_path(void) {
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_cpath_dirname(void) { WpTestFuncResult test_cpath_dirname(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8)); Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) { if (wapp_mem_allocator_invalid(&arena)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
b8 result; b8 result;
@@ -125,13 +125,13 @@ TestFuncResult test_cpath_dirname(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_cpath_dirup(void) { WpTestFuncResult test_cpath_dirup(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8)); Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) { if (wapp_mem_allocator_invalid(&arena)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
b8 result; b8 result;
@@ -177,5 +177,5 @@ TestFuncResult test_cpath_dirup(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
+8 -8
View File
@@ -6,7 +6,7 @@
#define MAIN_BUF_SIZE 4096 #define MAIN_BUF_SIZE 4096
#define TMP_BUF_SIZE 1024 #define TMP_BUF_SIZE 1024
TestFuncResult test_cpath_join_path(void) { WpTestFuncResult test_cpath_join_path(void) {
b8 result; b8 result;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE); Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
@@ -95,13 +95,13 @@ TestFuncResult test_cpath_join_path(void) {
wapp_cpath_join_path(&out, &parts); wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected); result = result && wapp_str8_equal(&out, &expected);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_cpath_dirname(void) { WpTestFuncResult test_cpath_dirname(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8)); Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) { if (wapp_mem_allocator_invalid(&arena)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
b8 result; b8 result;
@@ -145,13 +145,13 @@ TestFuncResult test_cpath_dirname(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_cpath_dirup(void) { WpTestFuncResult test_cpath_dirup(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(8)); Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
if (wapp_mem_allocator_invalid(&arena)) { if (wapp_mem_allocator_invalid(&arena)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
b8 result; b8 result;
@@ -197,5 +197,5 @@ TestFuncResult test_cpath_dirup(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
+3 -3
View File
@@ -3,8 +3,8 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_cpath_join_path(void); WpTestFuncResult test_cpath_join_path(void);
TestFuncResult test_cpath_dirname(void); WpTestFuncResult test_cpath_dirname(void);
TestFuncResult test_cpath_dirup(void); WpTestFuncResult test_cpath_dirup(void);
#endif // !TEST_CPATH_H #endif // !TEST_CPATH_H
+24 -24
View File
@@ -13,18 +13,18 @@ wp_intern I32Array src_array3 = wapp_array(i32, 10, 11, 12, 13, 14);
wp_intern I32Array dst_array = wapp_array_with_capacity(i32, DST_CAPACITY, false); wp_intern I32Array dst_array = wapp_array_with_capacity(i32, DST_CAPACITY, false);
wp_intern i32 dst_buf[DST_CAPACITY] = {0}; wp_intern i32 dst_buf[DST_CAPACITY] = {0};
TestFuncResult test_wapp_file_open(void) { WpTestFuncResult test_wapp_file_open(void) {
arena = wapp_mem_arena_allocator_init(KiB(16)); arena = wapp_mem_arena_allocator_init(KiB(16));
test_fp = wapp_file_open(&arena, &test_filename, WAPP_ACCESS_WRITE_EX); test_fp = wapp_file_open(&arena, &test_filename, WAPP_ACCESS_WRITE_EX);
return wapp_tester_result(test_fp != NULL); return wpTesterResult(test_fp != NULL);
} }
TestFuncResult test_wapp_file_get_current_position(void) { WpTestFuncResult test_wapp_file_get_current_position(void) {
i64 pos = wapp_file_get_current_position(test_fp); i64 pos = wapp_file_get_current_position(test_fp);
return wapp_tester_result(pos == 0); return wpTesterResult(pos == 0);
} }
TestFuncResult test_wapp_file_seek(void) { WpTestFuncResult test_wapp_file_seek(void) {
wapp_file_write_array((GenericArray)src_array1, test_fp, wapp_array_count(src_array1)); wapp_file_write_array((GenericArray)src_array1, test_fp, wapp_array_count(src_array1));
i64 seek_result = wapp_file_seek(test_fp, 0, WAPP_SEEK_END); i64 seek_result = wapp_file_seek(test_fp, 0, WAPP_SEEK_END);
@@ -32,15 +32,15 @@ TestFuncResult test_wapp_file_seek(void) {
wapp_file_seek(test_fp, 0, WAPP_SEEK_START); wapp_file_seek(test_fp, 0, WAPP_SEEK_START);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_wapp_file_get_length(void) { WpTestFuncResult test_wapp_file_get_length(void) {
i64 length = wapp_file_get_length(test_fp); i64 length = wapp_file_get_length(test_fp);
return wapp_tester_result(length == (i64)(wapp_array_count(src_array1) * wapp_array_item_size(src_array1))); return wpTesterResult(length == (i64)(wapp_array_count(src_array1) * wapp_array_item_size(src_array1)));
} }
TestFuncResult test_wapp_file_read(void) { WpTestFuncResult test_wapp_file_read(void) {
wapp_file_seek(test_fp, 0, WAPP_SEEK_START); wapp_file_seek(test_fp, 0, WAPP_SEEK_START);
u64 byte_count = DST_CAPACITY * sizeof(i32); u64 byte_count = DST_CAPACITY * sizeof(i32);
@@ -57,19 +57,19 @@ TestFuncResult test_wapp_file_read(void) {
running = index < DST_CAPACITY; running = index < DST_CAPACITY;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_wapp_file_write(void) { WpTestFuncResult test_wapp_file_write(void) {
wapp_file_seek(test_fp, 0, WAPP_SEEK_END); wapp_file_seek(test_fp, 0, WAPP_SEEK_END);
u64 expected_count = wapp_array_count(src_array2) * wapp_array_item_size(src_array2); u64 expected_count = wapp_array_count(src_array2) * wapp_array_item_size(src_array2);
i64 count = wapp_file_write((void *)src_array2, test_fp, expected_count); i64 count = wapp_file_write((void *)src_array2, test_fp, expected_count);
return wapp_tester_result(count >= 0 && (u64)count == expected_count); return wpTesterResult(count >= 0 && (u64)count == expected_count);
} }
TestFuncResult test_wapp_file_read_array(void) { WpTestFuncResult test_wapp_file_read_array(void) {
wapp_file_seek(test_fp, 0, WAPP_SEEK_START); wapp_file_seek(test_fp, 0, WAPP_SEEK_START);
u64 count = wapp_file_read_array((GenericArray)dst_array, test_fp, wapp_array_count(src_array1)); u64 count = wapp_file_read_array((GenericArray)dst_array, test_fp, wapp_array_count(src_array1));
@@ -86,33 +86,33 @@ TestFuncResult test_wapp_file_read_array(void) {
running = index < wapp_array_count(dst_array); running = index < wapp_array_count(dst_array);
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_wapp_file_write_array(void) { WpTestFuncResult test_wapp_file_write_array(void) {
wapp_file_seek(test_fp, 0, WAPP_SEEK_END); wapp_file_seek(test_fp, 0, WAPP_SEEK_END);
i64 count = wapp_file_write_array((GenericArray)src_array3, test_fp, wapp_array_count(src_array3)); i64 count = wapp_file_write_array((GenericArray)src_array3, test_fp, wapp_array_count(src_array3));
return wapp_tester_result(count >= 0 && (u64)count == wapp_array_count(src_array3)); return wpTesterResult(count >= 0 && (u64)count == wapp_array_count(src_array3));
} }
TestFuncResult test_wapp_file_flush(void) { WpTestFuncResult test_wapp_file_flush(void) {
i32 flush_result = wapp_file_flush(test_fp); i32 flush_result = wapp_file_flush(test_fp);
return wapp_tester_result(flush_result == 0); return wpTesterResult(flush_result == 0);
} }
TestFuncResult test_wapp_file_close(void) { WpTestFuncResult test_wapp_file_close(void) {
i32 close_result = wapp_file_close(test_fp); i32 close_result = wapp_file_close(test_fp);
return wapp_tester_result(close_result == 0); return wpTesterResult(close_result == 0);
} }
TestFuncResult test_wapp_file_rename(void) { WpTestFuncResult test_wapp_file_rename(void) {
i32 rename_result = wapp_file_rename(&test_filename, &new_filename); i32 rename_result = wapp_file_rename(&test_filename, &new_filename);
return wapp_tester_result(rename_result == 0); return wpTesterResult(rename_result == 0);
} }
TestFuncResult test_wapp_file_remove(void) { WpTestFuncResult test_wapp_file_remove(void) {
i32 remove_result = wapp_file_remove(&new_filename); i32 remove_result = wapp_file_remove(&new_filename);
return wapp_tester_result(remove_result == 0); return wpTesterResult(remove_result == 0);
} }
+24 -24
View File
@@ -13,22 +13,22 @@ wp_intern I32Array src_array2;
wp_intern I32Array src_array3; wp_intern I32Array src_array3;
wp_intern I32Array dst_array ; wp_intern I32Array dst_array ;
TestFuncResult test_wapp_file_open(void) { WpTestFuncResult test_wapp_file_open(void) {
arena = wapp_mem_arena_allocator_init(KiB(16)); arena = wapp_mem_arena_allocator_init(KiB(16));
src_array1 = wapp_array(i32, 0, 1, 2, 3, 4); src_array1 = wapp_array(i32, 0, 1, 2, 3, 4);
src_array2 = wapp_array(i32, 5, 6, 7, 8, 9); src_array2 = wapp_array(i32, 5, 6, 7, 8, 9);
src_array3 = wapp_array(i32, 10, 11, 12, 13, 14); src_array3 = wapp_array(i32, 10, 11, 12, 13, 14);
dst_array = wapp_array_with_capacity(i32, DST_CAPACITY, false); dst_array = wapp_array_with_capacity(i32, DST_CAPACITY, false);
test_fp = wapp_file_open(&arena, &test_filename, WAPP_ACCESS_WRITE_EX); test_fp = wapp_file_open(&arena, &test_filename, WAPP_ACCESS_WRITE_EX);
return wapp_tester_result(test_fp != NULL); return wpTesterResult(test_fp != NULL);
} }
TestFuncResult test_wapp_file_get_current_position(void) { WpTestFuncResult test_wapp_file_get_current_position(void) {
i64 pos = wapp_file_get_current_position(test_fp); i64 pos = wapp_file_get_current_position(test_fp);
return wapp_tester_result(pos == 0); return wpTesterResult(pos == 0);
} }
TestFuncResult test_wapp_file_seek(void) { WpTestFuncResult test_wapp_file_seek(void) {
wapp_file_write_array((GenericArray)src_array1, test_fp, wapp_array_count(src_array1)); wapp_file_write_array((GenericArray)src_array1, test_fp, wapp_array_count(src_array1));
i64 seek_result = wapp_file_seek(test_fp, 0, WAPP_SEEK_END); i64 seek_result = wapp_file_seek(test_fp, 0, WAPP_SEEK_END);
@@ -36,15 +36,15 @@ TestFuncResult test_wapp_file_seek(void) {
wapp_file_seek(test_fp, 0, WAPP_SEEK_START); wapp_file_seek(test_fp, 0, WAPP_SEEK_START);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_wapp_file_get_length(void) { WpTestFuncResult test_wapp_file_get_length(void) {
i64 length = wapp_file_get_length(test_fp); i64 length = wapp_file_get_length(test_fp);
return wapp_tester_result(length == (i64)(wapp_array_count(src_array1) * wapp_array_item_size(src_array1))); return wpTesterResult(length == (i64)(wapp_array_count(src_array1) * wapp_array_item_size(src_array1)));
} }
TestFuncResult test_wapp_file_read(void) { WpTestFuncResult test_wapp_file_read(void) {
wapp_file_seek(test_fp, 0, WAPP_SEEK_START); wapp_file_seek(test_fp, 0, WAPP_SEEK_START);
u64 byte_count = DST_CAPACITY * sizeof(i32); u64 byte_count = DST_CAPACITY * sizeof(i32);
@@ -61,19 +61,19 @@ TestFuncResult test_wapp_file_read(void) {
running = index < DST_CAPACITY; running = index < DST_CAPACITY;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_wapp_file_write(void) { WpTestFuncResult test_wapp_file_write(void) {
wapp_file_seek(test_fp, 0, WAPP_SEEK_END); wapp_file_seek(test_fp, 0, WAPP_SEEK_END);
u64 expected_count = wapp_array_count(src_array2) * wapp_array_item_size(src_array2); u64 expected_count = wapp_array_count(src_array2) * wapp_array_item_size(src_array2);
i64 count = wapp_file_write((void *)src_array2, test_fp, expected_count); i64 count = wapp_file_write((void *)src_array2, test_fp, expected_count);
return wapp_tester_result(count >= 0 && (u64)count == expected_count); return wpTesterResult(count >= 0 && (u64)count == expected_count);
} }
TestFuncResult test_wapp_file_read_array(void) { WpTestFuncResult test_wapp_file_read_array(void) {
wapp_file_seek(test_fp, 0, WAPP_SEEK_START); wapp_file_seek(test_fp, 0, WAPP_SEEK_START);
u64 count = wapp_file_read_array((GenericArray)dst_array, test_fp, wapp_array_count(src_array1)); u64 count = wapp_file_read_array((GenericArray)dst_array, test_fp, wapp_array_count(src_array1));
@@ -90,33 +90,33 @@ TestFuncResult test_wapp_file_read_array(void) {
running = index < wapp_array_count(dst_array); running = index < wapp_array_count(dst_array);
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_wapp_file_write_array(void) { WpTestFuncResult test_wapp_file_write_array(void) {
wapp_file_seek(test_fp, 0, WAPP_SEEK_END); wapp_file_seek(test_fp, 0, WAPP_SEEK_END);
i64 count = wapp_file_write_array((GenericArray)src_array3, test_fp, wapp_array_count(src_array3)); i64 count = wapp_file_write_array((GenericArray)src_array3, test_fp, wapp_array_count(src_array3));
return wapp_tester_result(count >= 0 && (u64)count == wapp_array_count(src_array3)); return wpTesterResult(count >= 0 && (u64)count == wapp_array_count(src_array3));
} }
TestFuncResult test_wapp_file_flush(void) { WpTestFuncResult test_wapp_file_flush(void) {
i32 flush_result = wapp_file_flush(test_fp); i32 flush_result = wapp_file_flush(test_fp);
return wapp_tester_result(flush_result == 0); return wpTesterResult(flush_result == 0);
} }
TestFuncResult test_wapp_file_close(void) { WpTestFuncResult test_wapp_file_close(void) {
i32 close_result = wapp_file_close(test_fp); i32 close_result = wapp_file_close(test_fp);
return wapp_tester_result(close_result == 0); return wpTesterResult(close_result == 0);
} }
TestFuncResult test_wapp_file_rename(void) { WpTestFuncResult test_wapp_file_rename(void) {
i32 rename_result = wapp_file_rename(&test_filename, &new_filename); i32 rename_result = wapp_file_rename(&test_filename, &new_filename);
return wapp_tester_result(rename_result == 0); return wpTesterResult(rename_result == 0);
} }
TestFuncResult test_wapp_file_remove(void) { WpTestFuncResult test_wapp_file_remove(void) {
i32 remove_result = wapp_file_remove(&new_filename); i32 remove_result = wapp_file_remove(&new_filename);
return wapp_tester_result(remove_result == 0); return wpTesterResult(remove_result == 0);
} }
+12 -12
View File
@@ -5,17 +5,17 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_wapp_file_open(void); WpTestFuncResult test_wapp_file_open(void);
TestFuncResult test_wapp_file_get_current_position(void); WpTestFuncResult test_wapp_file_get_current_position(void);
TestFuncResult test_wapp_file_seek(void); WpTestFuncResult test_wapp_file_seek(void);
TestFuncResult test_wapp_file_get_length(void); WpTestFuncResult test_wapp_file_get_length(void);
TestFuncResult test_wapp_file_read(void); WpTestFuncResult test_wapp_file_read(void);
TestFuncResult test_wapp_file_write(void); WpTestFuncResult test_wapp_file_write(void);
TestFuncResult test_wapp_file_read_array(void); WpTestFuncResult test_wapp_file_read_array(void);
TestFuncResult test_wapp_file_write_array(void); WpTestFuncResult test_wapp_file_write_array(void);
TestFuncResult test_wapp_file_flush(void); WpTestFuncResult test_wapp_file_flush(void);
TestFuncResult test_wapp_file_close(void); WpTestFuncResult test_wapp_file_close(void);
TestFuncResult test_wapp_file_rename(void); WpTestFuncResult test_wapp_file_rename(void);
TestFuncResult test_wapp_file_remove(void); WpTestFuncResult test_wapp_file_remove(void);
#endif // !TEST_FILE_H #endif // !TEST_FILE_H
+6 -6
View File
@@ -5,7 +5,7 @@
#define CAPACITY 8 #define CAPACITY 8
TestFuncResult test_queue_push(void) { WpTestFuncResult test_queue_push(void) {
I32Queue queue = wapp_queue(i32, CAPACITY); I32Queue queue = wapp_queue(i32, CAPACITY);
for (u64 i = 0; i < CAPACITY; ++i) { for (u64 i = 0; i < CAPACITY; ++i) {
@@ -19,10 +19,10 @@ TestFuncResult test_queue_push(void) {
result = result && value != NULL && *value == (i32)i; result = result && value != NULL && *value == (i32)i;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_queue_push_alloc(void) { WpTestFuncResult test_queue_push_alloc(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(64)); Allocator arena = wapp_mem_arena_allocator_init(MiB(64));
I32Queue queue = wapp_queue(i32, CAPACITY); I32Queue queue = wapp_queue(i32, CAPACITY);
@@ -67,10 +67,10 @@ TestFuncResult test_queue_push_alloc(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_queue_pop(void) { WpTestFuncResult test_queue_pop(void) {
I32Queue queue = wapp_queue(i32, CAPACITY); I32Queue queue = wapp_queue(i32, CAPACITY);
for (u64 i = 0; i < CAPACITY; ++i) { for (u64 i = 0; i < CAPACITY; ++i) {
i32 item = (i32)i; i32 item = (i32)i;
@@ -94,5 +94,5 @@ TestFuncResult test_queue_pop(void) {
result = result && value != NULL && *value == (i32)half_count + (i32)i; result = result && value != NULL && *value == (i32)half_count + (i32)i;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
+6 -6
View File
@@ -3,7 +3,7 @@
#define CAPACITY 8 #define CAPACITY 8
TestFuncResult test_queue_push(void) { WpTestFuncResult test_queue_push(void) {
I32Queue queue = wapp_queue(i32, CAPACITY); I32Queue queue = wapp_queue(i32, CAPACITY);
for (u64 i = 0; i < CAPACITY; ++i) { for (u64 i = 0; i < CAPACITY; ++i) {
@@ -17,10 +17,10 @@ TestFuncResult test_queue_push(void) {
result = result && value != NULL && *value == (i32)i; result = result && value != NULL && *value == (i32)i;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_queue_push_alloc(void) { WpTestFuncResult test_queue_push_alloc(void) {
Allocator arena = wapp_mem_arena_allocator_init(MiB(64)); Allocator arena = wapp_mem_arena_allocator_init(MiB(64));
I32Queue queue = wapp_queue(i32, CAPACITY); I32Queue queue = wapp_queue(i32, CAPACITY);
@@ -65,10 +65,10 @@ TestFuncResult test_queue_push_alloc(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_queue_pop(void) { WpTestFuncResult test_queue_pop(void) {
I32Queue queue = wapp_queue(i32, CAPACITY); I32Queue queue = wapp_queue(i32, CAPACITY);
for (u64 i = 0; i < CAPACITY; ++i) { for (u64 i = 0; i < CAPACITY; ++i) {
i32 item = (i32)i; i32 item = (i32)i;
@@ -92,5 +92,5 @@ TestFuncResult test_queue_pop(void) {
result = result && value != NULL && *value == (i32)half_count + (i32)i; result = result && value != NULL && *value == (i32)half_count + (i32)i;
} }
return wapp_tester_result(result); return wpTesterResult(result);
} }
+3 -3
View File
@@ -5,8 +5,8 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_queue_push(void); WpTestFuncResult test_queue_push(void);
TestFuncResult test_queue_push_alloc(void); WpTestFuncResult test_queue_push_alloc(void);
TestFuncResult test_queue_pop(void); WpTestFuncResult test_queue_pop(void);
#endif // !TEST_QUEUE_H #endif // !TEST_QUEUE_H
+8 -8
View File
@@ -4,7 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
TestFuncResult test_commander_cmd_success(void) { WpTestFuncResult test_commander_cmd_success(void) {
Str8List cmd = wapp_dbl_list(Str8); Str8List cmd = wapp_dbl_list(Str8);
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit("echo")); wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit("echo"));
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit("hello world")); wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit("hello world"));
@@ -13,10 +13,10 @@ TestFuncResult test_commander_cmd_success(void) {
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR; result.error == SHELL_ERR_NO_ERROR;
return wapp_tester_result(succeeded); return wpTesterResult(succeeded);
} }
TestFuncResult test_commander_cmd_failure(void) { WpTestFuncResult test_commander_cmd_failure(void) {
Str8List cmd = wapp_dbl_list(Str8); Str8List cmd = wapp_dbl_list(Str8);
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit("grep")); wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit("grep"));
@@ -24,10 +24,10 @@ TestFuncResult test_commander_cmd_failure(void) {
b8 failed = result.exited && result.exit_code != EXIT_SUCCESS && b8 failed = result.exited && result.exit_code != EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR; result.error == SHELL_ERR_NO_ERROR;
return wapp_tester_result(failed); return wpTesterResult(failed);
} }
TestFuncResult test_commander_cmd_out_buf_success(void) { WpTestFuncResult test_commander_cmd_out_buf_success(void) {
Str8 buf = wapp_str8_buf(64); Str8 buf = wapp_str8_buf(64);
Str8 expected = wapp_str8_buf(64); Str8 expected = wapp_str8_buf(64);
char msg[] = "hello world"; char msg[] = "hello world";
@@ -41,10 +41,10 @@ TestFuncResult test_commander_cmd_out_buf_success(void) {
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg)); result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg));
return wapp_tester_result(succeeded); return wpTesterResult(succeeded);
} }
TestFuncResult test_commander_cmd_out_buf_failure(void) { WpTestFuncResult test_commander_cmd_out_buf_failure(void) {
Str8 buf = wapp_str8_buf(4); Str8 buf = wapp_str8_buf(4);
Str8 expected = wapp_str8_buf(64); Str8 expected = wapp_str8_buf(64);
char msg[] = "hello world"; char msg[] = "hello world";
@@ -58,5 +58,5 @@ TestFuncResult test_commander_cmd_out_buf_failure(void) {
b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS && b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected); result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected);
return wapp_tester_result(failed); return wpTesterResult(failed);
} }
@@ -4,7 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
TestFuncResult test_commander_cmd_success(void) { WpTestFuncResult test_commander_cmd_success(void) {
Str8List cmd = wapp_dbl_list(Str8); Str8List cmd = wapp_dbl_list(Str8);
Str8 echo = wapp_str8_lit("echo"); Str8 echo = wapp_str8_lit("echo");
Str8 msg = wapp_str8_lit("hello world"); Str8 msg = wapp_str8_lit("hello world");
@@ -15,10 +15,10 @@ TestFuncResult test_commander_cmd_success(void) {
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR; result.error == SHELL_ERR_NO_ERROR;
return wapp_tester_result(succeeded); return wpTesterResult(succeeded);
} }
TestFuncResult test_commander_cmd_failure(void) { WpTestFuncResult test_commander_cmd_failure(void) {
Str8List cmd = wapp_dbl_list(Str8); Str8List cmd = wapp_dbl_list(Str8);
Str8 grep = wapp_str8_lit("grep"); Str8 grep = wapp_str8_lit("grep");
wapp_dbl_list_push_back(Str8, &cmd, &grep); wapp_dbl_list_push_back(Str8, &cmd, &grep);
@@ -27,10 +27,10 @@ TestFuncResult test_commander_cmd_failure(void) {
b8 failed = result.exited && result.exit_code != EXIT_SUCCESS && b8 failed = result.exited && result.exit_code != EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR; result.error == SHELL_ERR_NO_ERROR;
return wapp_tester_result(failed); return wpTesterResult(failed);
} }
TestFuncResult test_commander_cmd_out_buf_success(void) { WpTestFuncResult test_commander_cmd_out_buf_success(void) {
Str8 buf = wapp_str8_buf(64); Str8 buf = wapp_str8_buf(64);
Str8 expected = wapp_str8_buf(64); Str8 expected = wapp_str8_buf(64);
char msg[] = "hello world"; char msg[] = "hello world";
@@ -46,10 +46,10 @@ TestFuncResult test_commander_cmd_out_buf_success(void) {
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS && b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg)); result.error == SHELL_ERR_NO_ERROR && wapp_str8_equal_to_count(&buf, &expected, strlen(msg));
return wapp_tester_result(succeeded); return wpTesterResult(succeeded);
} }
TestFuncResult test_commander_cmd_out_buf_failure(void) { WpTestFuncResult test_commander_cmd_out_buf_failure(void) {
Str8 buf = wapp_str8_buf(4); Str8 buf = wapp_str8_buf(4);
Str8 expected = wapp_str8_buf(64); Str8 expected = wapp_str8_buf(64);
char msg[] = "hello world"; char msg[] = "hello world";
@@ -65,5 +65,5 @@ TestFuncResult test_commander_cmd_out_buf_failure(void) {
b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS && b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected); result.error == SHELL_ERR_OUT_BUF_FULL && !wapp_str8_equal(&buf, &expected);
return wapp_tester_result(failed); return wpTesterResult(failed);
} }
+4 -4
View File
@@ -3,9 +3,9 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_commander_cmd_success(void); WpTestFuncResult test_commander_cmd_success(void);
TestFuncResult test_commander_cmd_failure(void); WpTestFuncResult test_commander_cmd_failure(void);
TestFuncResult test_commander_cmd_out_buf_success(void); WpTestFuncResult test_commander_cmd_out_buf_success(void);
TestFuncResult test_commander_cmd_out_buf_failure(void); WpTestFuncResult test_commander_cmd_out_buf_failure(void);
#endif // !TEST_SHELL_COMMANDER_H #endif // !TEST_SHELL_COMMANDER_H
+59 -59
View File
@@ -3,7 +3,7 @@
#define ARRLEN(ARR) (sizeof(ARR) / sizeof(ARR[0])) #define ARRLEN(ARR) (sizeof(ARR) / sizeof(ARR[0]))
TestFuncResult test_str8_lit(void) { WpTestFuncResult test_str8_lit(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("Hello world"); Str8 s1 = wapp_str8_lit("Hello world");
@@ -27,10 +27,10 @@ TestFuncResult test_str8_lit(void) {
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");
result = result && s7.capacity == 94 && s7.capacity != s7.size; result = result && s7.capacity == 94 && s7.capacity != s7.size;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_lit_ro(void) { WpTestFuncResult test_str8_lit_ro(void) {
b8 result; b8 result;
Str8RO s1 = wapp_str8_lit_ro("Hello world"); Str8RO s1 = wapp_str8_lit_ro("Hello world");
@@ -54,10 +54,10 @@ TestFuncResult test_str8_lit_ro(void) {
Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); 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; result = result && s7.capacity == 47 && s7.capacity == s7.size;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_buf(void) { WpTestFuncResult test_str8_buf(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_buf(1024); Str8 s1 = wapp_str8_buf(1024);
@@ -72,14 +72,14 @@ TestFuncResult test_str8_buf(void) {
Str8 s4 = wapp_str8_buf(8192); Str8 s4 = wapp_str8_buf(8192);
result = result && s4.capacity == 8192 && s4.size == 0; result = result && s4.capacity == 8192 && s4.size == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_alloc_buf(void) { WpTestFuncResult test_str8_alloc_buf(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100)); Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) { if (wapp_mem_allocator_invalid(&allocator)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
u64 capacity = 4096; u64 capacity = 4096;
@@ -100,71 +100,71 @@ TestFuncResult test_str8_alloc_buf(void) {
TEST_ALLOC_BUF_CLEANUP: TEST_ALLOC_BUF_CLEANUP:
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_alloc_cstr(void) { WpTestFuncResult test_str8_alloc_cstr(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100)); Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) { if (wapp_mem_allocator_invalid(&allocator)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
char *str = "Abdelrahman"; char *str = "Abdelrahman";
u64 length = strlen(str); u64 length = strlen(str);
Str8 *s = wapp_str8_alloc_cstr(&allocator, str); Str8 *s = wapp_str8_alloc_cstr(&allocator, str);
if (!s) { if (!s) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
result = s->size == length && memcmp(s->buf, str, length) == 0; result = s->size == length && memcmp(s->buf, str, length) == 0;
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_alloc_str8(void) { WpTestFuncResult test_str8_alloc_str8(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100)); Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) { if (wapp_mem_allocator_invalid(&allocator)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
Str8 str = wapp_str8_lit("Abdelrahman"); Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_str8(&allocator, &str); Str8 *s = wapp_str8_alloc_str8(&allocator, &str);
if (!s) { if (!s) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
result = wapp_str8_equal(s, &str); result = wapp_str8_equal(s, &str);
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_alloc_substr(void) { WpTestFuncResult test_str8_alloc_substr(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100)); Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) { if (wapp_mem_allocator_invalid(&allocator)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
Str8 str = wapp_str8_lit("Abdelrahman"); Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8); Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8);
if (!s) { if (!s) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
result = s->size == 5 && memcmp(s->buf, "elrah", s->size) == 0; result = s->size == 5 && memcmp(s->buf, "elrah", s->size) == 0;
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_get_index_within_bounds(void) { WpTestFuncResult test_str8_get_index_within_bounds(void) {
b8 result; b8 result;
Str8RO s1 = wapp_str8_lit_ro("Hello world"); Str8RO s1 = wapp_str8_lit_ro("Hello world");
@@ -188,16 +188,16 @@ TestFuncResult test_str8_get_index_within_bounds(void) {
Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); 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'; result = result && wapp_str8_get(&s7, 16) == 's';
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_get_index_out_of_bounds(void) { WpTestFuncResult test_str8_get_index_out_of_bounds(void) {
Str8 s1 = wapp_str8_lit("Hello world"); Str8 s1 = wapp_str8_lit("Hello world");
b8 result = wapp_str8_get(&s1, 20) == '\0'; b8 result = wapp_str8_get(&s1, 20) == '\0';
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_set(void) { WpTestFuncResult test_str8_set(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("Hello world"); Str8 s1 = wapp_str8_lit("Hello world");
@@ -228,10 +228,10 @@ TestFuncResult test_str8_set(void) {
wapp_str8_set(&s7, 16, 'i'); 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); return wpTesterResult(result);
} }
TestFuncResult test_str8_push_back(void) { WpTestFuncResult test_str8_push_back(void) {
b8 result; b8 result;
Str8 expected = wapp_str8_lit("Abdelrahman"); Str8 expected = wapp_str8_lit("Abdelrahman");
@@ -250,10 +250,10 @@ TestFuncResult test_str8_push_back(void) {
result = wapp_str8_equal(&buf, &expected); result = wapp_str8_equal(&buf, &expected);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_equal(void) { WpTestFuncResult test_str8_equal(void) {
b8 result; b8 result;
Str8RO s1 = wapp_str8_lit_ro("hello"); Str8RO s1 = wapp_str8_lit_ro("hello");
@@ -265,10 +265,10 @@ TestFuncResult test_str8_equal(void) {
result = result && wapp_str8_equal(&s1, &s3) == true; result = result && wapp_str8_equal(&s1, &s3) == true;
result = result && wapp_str8_equal(&s1, &s4) == false; result = result && wapp_str8_equal(&s1, &s4) == false;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_slice(void) { WpTestFuncResult test_str8_slice(void) {
b8 result; b8 result;
Str8 s = wapp_str8_lit("Different strokes for different folks"); Str8 s = wapp_str8_lit("Different strokes for different folks");
@@ -284,10 +284,10 @@ TestFuncResult test_str8_slice(void) {
Str8RO sub4 = wapp_str8_slice(&s, 70, 80); Str8RO sub4 = wapp_str8_slice(&s, 70, 80);
result = result && sub4.size == 0 && sub4.capacity == 0; result = result && sub4.size == 0 && sub4.capacity == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_alloc_concat(void) { WpTestFuncResult test_str8_alloc_concat(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -307,10 +307,10 @@ TestFuncResult test_str8_alloc_concat(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_concat_capped(void) { WpTestFuncResult test_str8_concat_capped(void) {
b8 result; b8 result;
Str8 str = wapp_str8_lit("Hello world"); Str8 str = wapp_str8_lit("Hello world");
@@ -325,10 +325,10 @@ TestFuncResult test_str8_concat_capped(void) {
wapp_str8_concat_capped(&str, &suffix2); wapp_str8_concat_capped(&str, &suffix2);
result = result && str.size == concat2.size && wapp_str8_equal(&str, &concat2); result = result && str.size == concat2.size && wapp_str8_equal(&str, &concat2);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_copy_cstr_capped(void) { WpTestFuncResult test_str8_copy_cstr_capped(void) {
b8 result; b8 result;
Str8 buf = wapp_str8_buf(32); Str8 buf = wapp_str8_buf(32);
@@ -343,10 +343,10 @@ TestFuncResult test_str8_copy_cstr_capped(void) {
wapp_str8_copy_cstr_capped(&buf, src2); wapp_str8_copy_cstr_capped(&buf, src2);
result = result && buf.size == src2_cp.size && buf.size == buf.capacity && wapp_str8_equal(&buf, &src2_cp); result = result && buf.size == src2_cp.size && buf.size == buf.capacity && wapp_str8_equal(&buf, &src2_cp);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_copy_str8_capped(void) { WpTestFuncResult test_str8_copy_str8_capped(void) {
b8 result; b8 result;
Str8 buf = wapp_str8_buf(32); Str8 buf = wapp_str8_buf(32);
@@ -360,10 +360,10 @@ TestFuncResult test_str8_copy_str8_capped(void) {
wapp_str8_copy_str8_capped(&buf, &src2); wapp_str8_copy_str8_capped(&buf, &src2);
result = result && buf.size < src2.size && buf.size == buf.capacity && wapp_str8_equal(&buf, &src2_cp); result = result && buf.size < src2.size && buf.size == buf.capacity && wapp_str8_equal(&buf, &src2_cp);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_format(void) { WpTestFuncResult test_str8_format(void) {
b8 result; b8 result;
Str8 buf = wapp_str8_buf(128); Str8 buf = wapp_str8_buf(128);
@@ -373,10 +373,10 @@ TestFuncResult test_str8_format(void) {
result = wapp_str8_equal(&buf, &expected); result = wapp_str8_equal(&buf, &expected);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_find(void) { WpTestFuncResult test_str8_find(void) {
b8 result; b8 result;
Str8RO s = wapp_str8_lit("Do as I say, not as I do"); Str8RO s = wapp_str8_lit("Do as I say, not as I do");
@@ -389,10 +389,10 @@ TestFuncResult test_str8_find(void) {
result = result && (wapp_str8_find(&s, wapp_str8_lit_ro("not sa I")) == -1); result = result && (wapp_str8_find(&s, wapp_str8_lit_ro("not sa I")) == -1);
result = result && (wapp_str8_find(&s, wapp_str8_lit_ro("Do unto others as you would have them do to you")) == -1); result = result && (wapp_str8_find(&s, wapp_str8_lit_ro("Do unto others as you would have them do to you")) == -1);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_rfind(void) { WpTestFuncResult test_str8_rfind(void) {
b8 result; b8 result;
Str8RO s = wapp_str8_lit("Do as I say, not as I do"); Str8RO s = wapp_str8_lit("Do as I say, not as I do");
@@ -405,10 +405,10 @@ TestFuncResult test_str8_rfind(void) {
result = result && (wapp_str8_rfind(&s, wapp_str8_lit_ro("not sa I")) == -1); result = result && (wapp_str8_rfind(&s, wapp_str8_lit_ro("not sa I")) == -1);
result = result && (wapp_str8_rfind(&s, wapp_str8_lit_ro("Do unto others as you would have them do to you")) == -1); result = result && (wapp_str8_rfind(&s, wapp_str8_lit_ro("Do unto others as you would have them do to you")) == -1);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_split(void) { WpTestFuncResult test_str8_split(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -462,10 +462,10 @@ TestFuncResult test_str8_split(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_split_with_max(void) { WpTestFuncResult test_str8_split_with_max(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -497,10 +497,10 @@ TestFuncResult test_str8_split_with_max(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_rsplit(void) { WpTestFuncResult test_str8_rsplit(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -554,10 +554,10 @@ TestFuncResult test_str8_rsplit(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_rsplit_with_max(void) { WpTestFuncResult test_str8_rsplit_with_max(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -589,10 +589,10 @@ TestFuncResult test_str8_rsplit_with_max(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_join(void) { WpTestFuncResult test_str8_join(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -609,10 +609,10 @@ TestFuncResult test_str8_join(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_from_bytes(void) { WpTestFuncResult test_str8_from_bytes(void) {
b8 result; b8 result;
Str8 str = wapp_str8_buf(1024); Str8 str = wapp_str8_buf(1024);
@@ -622,5 +622,5 @@ TestFuncResult test_str8_from_bytes(void) {
result = str.size == wapp_array_count(bytes) * wapp_array_item_size(bytes); result = str.size == wapp_array_count(bytes) * wapp_array_item_size(bytes);
result = result && wapp_str8_equal(&str, &wapp_str8_lit_ro("WAPP")); result = result && wapp_str8_equal(&str, &wapp_str8_lit_ro("WAPP"));
return wapp_tester_result(result); return wpTesterResult(result);
} }
+60 -60
View File
@@ -3,7 +3,7 @@
#define ARRLEN(ARR) (sizeof(ARR) / sizeof(ARR[0])) #define ARRLEN(ARR) (sizeof(ARR) / sizeof(ARR[0]))
TestFuncResult test_str8_lit(void) { WpTestFuncResult test_str8_lit(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("Hello world"); Str8 s1 = wapp_str8_lit("Hello world");
@@ -27,10 +27,10 @@ TestFuncResult test_str8_lit(void) {
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");
result = result && s7.capacity == 94 && s7.capacity != s7.size; result = result && s7.capacity == 94 && s7.capacity != s7.size;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_lit_ro(void) { WpTestFuncResult test_str8_lit_ro(void) {
b8 result; b8 result;
Str8RO s1 = wapp_str8_lit_ro("Hello world"); Str8RO s1 = wapp_str8_lit_ro("Hello world");
@@ -54,10 +54,10 @@ TestFuncResult test_str8_lit_ro(void) {
Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); 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; result = result && s7.capacity == 47 && s7.capacity == s7.size;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_buf(void) { WpTestFuncResult test_str8_buf(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_buf(1024); Str8 s1 = wapp_str8_buf(1024);
@@ -72,14 +72,14 @@ TestFuncResult test_str8_buf(void) {
Str8 s4 = wapp_str8_buf(8192); Str8 s4 = wapp_str8_buf(8192);
result = result && s4.capacity == 8192 && s4.size == 0; result = result && s4.capacity == 8192 && s4.size == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_alloc_buf(void) { WpTestFuncResult test_str8_alloc_buf(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100)); Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) { if (wapp_mem_allocator_invalid(&allocator)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
u64 capacity = 4096; u64 capacity = 4096;
@@ -88,7 +88,7 @@ TestFuncResult test_str8_alloc_buf(void) {
if (!s) { if (!s) {
result = false; result = false;
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
result = s->capacity == capacity; result = s->capacity == capacity;
@@ -100,71 +100,71 @@ TestFuncResult test_str8_alloc_buf(void) {
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_alloc_cstr(void) { WpTestFuncResult test_str8_alloc_cstr(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100)); Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) { if (wapp_mem_allocator_invalid(&allocator)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
const char *str = "Abdelrahman"; const char *str = "Abdelrahman";
u64 length = strlen(str); u64 length = strlen(str);
Str8 *s = wapp_str8_alloc_cstr(&allocator, str); Str8 *s = wapp_str8_alloc_cstr(&allocator, str);
if (!s) { if (!s) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
result = s->size == length && memcmp(s->buf, str, length) == 0; result = s->size == length && memcmp(s->buf, str, length) == 0;
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_alloc_str8(void) { WpTestFuncResult test_str8_alloc_str8(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100)); Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) { if (wapp_mem_allocator_invalid(&allocator)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
Str8 str = wapp_str8_lit("Abdelrahman"); Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_str8(&allocator, &str); Str8 *s = wapp_str8_alloc_str8(&allocator, &str);
if (!s) { if (!s) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
result = wapp_str8_equal(s, &str); result = wapp_str8_equal(s, &str);
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_alloc_substr(void) { WpTestFuncResult test_str8_alloc_substr(void) {
b8 result; b8 result;
Allocator allocator = wapp_mem_arena_allocator_init(KiB(100)); Allocator allocator = wapp_mem_arena_allocator_init(KiB(100));
if (wapp_mem_allocator_invalid(&allocator)) { if (wapp_mem_allocator_invalid(&allocator)) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
Str8 str = wapp_str8_lit("Abdelrahman"); Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8); Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8);
if (!s) { if (!s) {
return wapp_tester_result(false); return wpTesterResult(false);
} }
result = s->size == 5 && memcmp(s->buf, "elrah", s->size) == 0; result = s->size == 5 && memcmp(s->buf, "elrah", s->size) == 0;
wapp_mem_arena_allocator_destroy(&allocator); wapp_mem_arena_allocator_destroy(&allocator);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_get_index_within_bounds(void) { WpTestFuncResult test_str8_get_index_within_bounds(void) {
b8 result; b8 result;
Str8RO s1 = wapp_str8_lit_ro("Hello world"); Str8RO s1 = wapp_str8_lit_ro("Hello world");
@@ -188,16 +188,16 @@ TestFuncResult test_str8_get_index_within_bounds(void) {
Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you"); 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'; result = result && wapp_str8_get(&s7, 16) == 's';
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_get_index_out_of_bounds(void) { WpTestFuncResult test_str8_get_index_out_of_bounds(void) {
Str8 s1 = wapp_str8_lit("Hello world"); Str8 s1 = wapp_str8_lit("Hello world");
b8 result = wapp_str8_get(&s1, 20) == '\0'; b8 result = wapp_str8_get(&s1, 20) == '\0';
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_set(void) { WpTestFuncResult test_str8_set(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("Hello world"); Str8 s1 = wapp_str8_lit("Hello world");
@@ -228,10 +228,10 @@ TestFuncResult test_str8_set(void) {
wapp_str8_set(&s7, 16, 'i'); 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); return wpTesterResult(result);
} }
TestFuncResult test_str8_push_back(void) { WpTestFuncResult test_str8_push_back(void) {
b8 result; b8 result;
Str8 expected = wapp_str8_lit("Abdelrahman"); Str8 expected = wapp_str8_lit("Abdelrahman");
@@ -250,10 +250,10 @@ TestFuncResult test_str8_push_back(void) {
result = wapp_str8_equal(&buf, &expected); result = wapp_str8_equal(&buf, &expected);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_equal(void) { WpTestFuncResult test_str8_equal(void) {
b8 result; b8 result;
Str8RO s1 = wapp_str8_lit_ro("hello"); Str8RO s1 = wapp_str8_lit_ro("hello");
@@ -265,10 +265,10 @@ TestFuncResult test_str8_equal(void) {
result = result && wapp_str8_equal(&s1, &s3) == (b8)true; result = result && wapp_str8_equal(&s1, &s3) == (b8)true;
result = result && wapp_str8_equal(&s1, &s4) == (b8)false; result = result && wapp_str8_equal(&s1, &s4) == (b8)false;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_slice(void) { WpTestFuncResult test_str8_slice(void) {
b8 result; b8 result;
Str8 s = wapp_str8_lit("Different strokes for different folks"); Str8 s = wapp_str8_lit("Different strokes for different folks");
@@ -284,10 +284,10 @@ TestFuncResult test_str8_slice(void) {
Str8RO sub4 = wapp_str8_slice(&s, 70, 80); Str8RO sub4 = wapp_str8_slice(&s, 70, 80);
result = result && sub4.size == 0 && sub4.capacity == 0; result = result && sub4.size == 0 && sub4.capacity == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_alloc_concat(void) { WpTestFuncResult test_str8_alloc_concat(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -307,10 +307,10 @@ TestFuncResult test_str8_alloc_concat(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_concat_capped(void) { WpTestFuncResult test_str8_concat_capped(void) {
b8 result; b8 result;
Str8 str = wapp_str8_lit("Hello world"); Str8 str = wapp_str8_lit("Hello world");
@@ -325,10 +325,10 @@ TestFuncResult test_str8_concat_capped(void) {
wapp_str8_concat_capped(&str, &suffix2); wapp_str8_concat_capped(&str, &suffix2);
result = result && str.size == concat2.size && wapp_str8_equal(&str, &concat2); result = result && str.size == concat2.size && wapp_str8_equal(&str, &concat2);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_copy_cstr_capped(void) { WpTestFuncResult test_str8_copy_cstr_capped(void) {
b8 result; b8 result;
Str8 buf = wapp_str8_buf(32); Str8 buf = wapp_str8_buf(32);
@@ -343,10 +343,10 @@ TestFuncResult test_str8_copy_cstr_capped(void) {
wapp_str8_copy_cstr_capped(&buf, src2); wapp_str8_copy_cstr_capped(&buf, src2);
result = result && buf.size == src2_cp.size && buf.size == buf.capacity && wapp_str8_equal(&buf, &src2_cp); result = result && buf.size == src2_cp.size && buf.size == buf.capacity && wapp_str8_equal(&buf, &src2_cp);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_copy_str8_capped(void) { WpTestFuncResult test_str8_copy_str8_capped(void) {
b8 result; b8 result;
Str8 buf = wapp_str8_buf(32); Str8 buf = wapp_str8_buf(32);
@@ -360,10 +360,10 @@ TestFuncResult test_str8_copy_str8_capped(void) {
wapp_str8_copy_str8_capped(&buf, &src2); wapp_str8_copy_str8_capped(&buf, &src2);
result = result && buf.size < src2.size && buf.size == buf.capacity && wapp_str8_equal(&buf, &src2_cp); result = result && buf.size < src2.size && buf.size == buf.capacity && wapp_str8_equal(&buf, &src2_cp);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_format(void) { WpTestFuncResult test_str8_format(void) {
b8 result; b8 result;
Str8 buf = wapp_str8_buf(128); Str8 buf = wapp_str8_buf(128);
@@ -373,10 +373,10 @@ TestFuncResult test_str8_format(void) {
result = wapp_str8_equal(&buf, &expected); result = wapp_str8_equal(&buf, &expected);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_find(void) { WpTestFuncResult test_str8_find(void) {
b8 result; b8 result;
Str8RO s = wapp_str8_lit("Do as I say, not as I do"); Str8RO s = wapp_str8_lit("Do as I say, not as I do");
@@ -389,10 +389,10 @@ TestFuncResult test_str8_find(void) {
result = result && (wapp_str8_find(&s, wapp_str8_lit_ro("not sa I")) == -1); result = result && (wapp_str8_find(&s, wapp_str8_lit_ro("not sa I")) == -1);
result = result && (wapp_str8_find(&s, wapp_str8_lit_ro("Do unto others as you would have them do to you")) == -1); result = result && (wapp_str8_find(&s, wapp_str8_lit_ro("Do unto others as you would have them do to you")) == -1);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_rfind(void) { WpTestFuncResult test_str8_rfind(void) {
b8 result; b8 result;
Str8RO s = wapp_str8_lit("Do as I say, not as I do"); Str8RO s = wapp_str8_lit("Do as I say, not as I do");
@@ -405,10 +405,10 @@ TestFuncResult test_str8_rfind(void) {
result = result && (wapp_str8_rfind(&s, wapp_str8_lit_ro("not sa I")) == -1); result = result && (wapp_str8_rfind(&s, wapp_str8_lit_ro("not sa I")) == -1);
result = result && (wapp_str8_rfind(&s, wapp_str8_lit_ro("Do unto others as you would have them do to you")) == -1); result = result && (wapp_str8_rfind(&s, wapp_str8_lit_ro("Do unto others as you would have them do to you")) == -1);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_split(void) { WpTestFuncResult test_str8_split(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -462,10 +462,10 @@ TestFuncResult test_str8_split(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_split_with_max(void) { WpTestFuncResult test_str8_split_with_max(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -497,10 +497,10 @@ TestFuncResult test_str8_split_with_max(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_rsplit(void) { WpTestFuncResult test_str8_rsplit(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -554,10 +554,10 @@ TestFuncResult test_str8_rsplit(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_rsplit_with_max(void) { WpTestFuncResult test_str8_rsplit_with_max(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -589,10 +589,10 @@ TestFuncResult test_str8_rsplit_with_max(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_join(void) { WpTestFuncResult test_str8_join(void) {
b8 result; b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100)); Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
@@ -609,10 +609,10 @@ TestFuncResult test_str8_join(void) {
wapp_mem_arena_allocator_destroy(&arena); wapp_mem_arena_allocator_destroy(&arena);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_from_bytes(void) { WpTestFuncResult test_str8_from_bytes(void) {
b8 result; b8 result;
Str8 str = wapp_str8_buf(1024); Str8 str = wapp_str8_buf(1024);
@@ -623,5 +623,5 @@ TestFuncResult test_str8_from_bytes(void) {
result = str.size == wapp_array_count(bytes) * wapp_array_item_size(bytes); result = str.size == wapp_array_count(bytes) * wapp_array_item_size(bytes);
result = result && wapp_str8_equal(&str, &expected); result = result && wapp_str8_equal(&str, &expected);
return wapp_tester_result(result); return wpTesterResult(result);
} }
+26 -26
View File
@@ -3,31 +3,31 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_str8_lit(void); WpTestFuncResult test_str8_lit(void);
TestFuncResult test_str8_lit_ro(void); WpTestFuncResult test_str8_lit_ro(void);
TestFuncResult test_str8_buf(void); WpTestFuncResult test_str8_buf(void);
TestFuncResult test_str8_alloc_buf(void); WpTestFuncResult test_str8_alloc_buf(void);
TestFuncResult test_str8_alloc_cstr(void); WpTestFuncResult test_str8_alloc_cstr(void);
TestFuncResult test_str8_alloc_str8(void); WpTestFuncResult test_str8_alloc_str8(void);
TestFuncResult test_str8_alloc_substr(void); WpTestFuncResult test_str8_alloc_substr(void);
TestFuncResult test_str8_alloc_concat(void); WpTestFuncResult test_str8_alloc_concat(void);
TestFuncResult test_str8_get_index_within_bounds(void); WpTestFuncResult test_str8_get_index_within_bounds(void);
TestFuncResult test_str8_get_index_out_of_bounds(void); WpTestFuncResult test_str8_get_index_out_of_bounds(void);
TestFuncResult test_str8_set(void); WpTestFuncResult test_str8_set(void);
TestFuncResult test_str8_push_back(void); WpTestFuncResult test_str8_push_back(void);
TestFuncResult test_str8_equal(void); WpTestFuncResult test_str8_equal(void);
TestFuncResult test_str8_slice(void); WpTestFuncResult test_str8_slice(void);
TestFuncResult test_str8_concat_capped(void); WpTestFuncResult test_str8_concat_capped(void);
TestFuncResult test_str8_copy_cstr_capped(void); WpTestFuncResult test_str8_copy_cstr_capped(void);
TestFuncResult test_str8_copy_str8_capped(void); WpTestFuncResult test_str8_copy_str8_capped(void);
TestFuncResult test_str8_format(void); WpTestFuncResult test_str8_format(void);
TestFuncResult test_str8_find(void); WpTestFuncResult test_str8_find(void);
TestFuncResult test_str8_rfind(void); WpTestFuncResult test_str8_rfind(void);
TestFuncResult test_str8_split(void); WpTestFuncResult test_str8_split(void);
TestFuncResult test_str8_split_with_max(void); WpTestFuncResult test_str8_split_with_max(void);
TestFuncResult test_str8_rsplit(void); WpTestFuncResult test_str8_rsplit(void);
TestFuncResult test_str8_rsplit_with_max(void); WpTestFuncResult test_str8_rsplit_with_max(void);
TestFuncResult test_str8_join(void); WpTestFuncResult test_str8_join(void);
TestFuncResult test_str8_from_bytes(void); WpTestFuncResult test_str8_from_bytes(void);
#endif // !TEST_STR8_H #endif // !TEST_STR8_H
+16 -16
View File
@@ -1,7 +1,7 @@
#include "test_str8_list.h" #include "test_str8_list.h"
#include "wapp.h" #include "wapp.h"
TestFuncResult test_str8_list_get(void) { WpTestFuncResult test_str8_list_get(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -33,10 +33,10 @@ TestFuncResult test_str8_list_get(void) {
node = wapp_dbl_list_get(Str8, &list, 4); node = wapp_dbl_list_get(Str8, &list, 4);
result = result && node == &s5 && wapp_str8_equal(node, &s5); result = result && node == &s5 && wapp_str8_equal(node, &s5);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_push_front(void) { WpTestFuncResult test_str8_list_push_front(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -54,10 +54,10 @@ TestFuncResult test_str8_list_push_front(void) {
wapp_dbl_list_push_front(Str8, &list, &s3); wapp_dbl_list_push_front(Str8, &list, &s3);
result = result && list.first->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && list.first->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_push_back(void) { WpTestFuncResult test_str8_list_push_back(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -75,10 +75,10 @@ TestFuncResult test_str8_list_push_back(void) {
wapp_dbl_list_push_back(Str8, &list, &s3); wapp_dbl_list_push_back(Str8, &list, &s3);
result = result && list.last->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && list.last->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_insert(void) { WpTestFuncResult test_str8_list_insert(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -105,10 +105,10 @@ TestFuncResult test_str8_list_insert(void) {
node = wapp_dbl_list_get(Str8, &list, 5); node = wapp_dbl_list_get(Str8, &list, 5);
result = result && node != NULL && node == &s7 && wapp_str8_list_total_size(&list) == 7 && list.node_count == 7; result = result && node != NULL && node == &s7 && wapp_str8_list_total_size(&list) == 7 && list.node_count == 7;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_pop_front(void) { WpTestFuncResult test_str8_list_pop_front(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -140,10 +140,10 @@ TestFuncResult test_str8_list_pop_front(void) {
node = wapp_dbl_list_pop_front(Str8, &list); node = wapp_dbl_list_pop_front(Str8, &list);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_pop_back(void) { WpTestFuncResult test_str8_list_pop_back(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -175,10 +175,10 @@ TestFuncResult test_str8_list_pop_back(void) {
node = wapp_dbl_list_pop_back(Str8, &list); node = wapp_dbl_list_pop_back(Str8, &list);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_remove(void) { WpTestFuncResult test_str8_list_remove(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -210,10 +210,10 @@ TestFuncResult test_str8_list_remove(void) {
node = wapp_dbl_list_remove(Str8, &list, 0); node = wapp_dbl_list_remove(Str8, &list, 0);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_empty(void) { WpTestFuncResult test_str8_list_empty(void) {
b8 result; b8 result;
Str8List list = wapp_dbl_list(Str8); Str8List list = wapp_dbl_list(Str8);
@@ -226,5 +226,5 @@ TestFuncResult test_str8_list_empty(void) {
result = list.first == NULL && list.last == NULL && list.node_count == 0 && wapp_str8_list_total_size(&list) == 0; result = list.first == NULL && list.last == NULL && list.node_count == 0 && wapp_str8_list_total_size(&list) == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
+16 -16
View File
@@ -1,7 +1,7 @@
#include "test_str8_list.h" #include "test_str8_list.h"
#include "wapp.h" #include "wapp.h"
TestFuncResult test_str8_list_get(void) { WpTestFuncResult test_str8_list_get(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -33,10 +33,10 @@ TestFuncResult test_str8_list_get(void) {
node = wapp_dbl_list_get(Str8, &list, 4); node = wapp_dbl_list_get(Str8, &list, 4);
result = result && node == &s5 && wapp_str8_equal(node, &s5); result = result && node == &s5 && wapp_str8_equal(node, &s5);
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_push_front(void) { WpTestFuncResult test_str8_list_push_front(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -54,10 +54,10 @@ TestFuncResult test_str8_list_push_front(void) {
wapp_dbl_list_push_front(Str8, &list, &s3); wapp_dbl_list_push_front(Str8, &list, &s3);
result = result && list.first->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && list.first->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_push_back(void) { WpTestFuncResult test_str8_list_push_back(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -75,10 +75,10 @@ TestFuncResult test_str8_list_push_back(void) {
wapp_dbl_list_push_back(Str8, &list, &s3); wapp_dbl_list_push_back(Str8, &list, &s3);
result = result && list.last->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3; result = result && list.last->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_insert(void) { WpTestFuncResult test_str8_list_insert(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -105,10 +105,10 @@ TestFuncResult test_str8_list_insert(void) {
node = wapp_dbl_list_get(Str8, &list, 5); node = wapp_dbl_list_get(Str8, &list, 5);
result = result && node != NULL && node == &s7 && wapp_str8_list_total_size(&list) == 7 && list.node_count == 7; result = result && node != NULL && node == &s7 && wapp_str8_list_total_size(&list) == 7 && list.node_count == 7;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_pop_front(void) { WpTestFuncResult test_str8_list_pop_front(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -140,10 +140,10 @@ TestFuncResult test_str8_list_pop_front(void) {
node = wapp_dbl_list_pop_front(Str8, &list); node = wapp_dbl_list_pop_front(Str8, &list);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_pop_back(void) { WpTestFuncResult test_str8_list_pop_back(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -175,10 +175,10 @@ TestFuncResult test_str8_list_pop_back(void) {
node = wapp_dbl_list_pop_back(Str8, &list); node = wapp_dbl_list_pop_back(Str8, &list);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_remove(void) { WpTestFuncResult test_str8_list_remove(void) {
b8 result; b8 result;
Str8 s1 = wapp_str8_lit("1"); Str8 s1 = wapp_str8_lit("1");
@@ -210,10 +210,10 @@ TestFuncResult test_str8_list_remove(void) {
node = wapp_dbl_list_remove(Str8, &list, 0); node = wapp_dbl_list_remove(Str8, &list, 0);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0; result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
TestFuncResult test_str8_list_empty(void) { WpTestFuncResult test_str8_list_empty(void) {
b8 result; b8 result;
Str8List list = wapp_dbl_list(Str8); Str8List list = wapp_dbl_list(Str8);
@@ -234,5 +234,5 @@ TestFuncResult test_str8_list_empty(void) {
result = list.first == NULL && list.last == NULL && list.node_count == 0 && wapp_str8_list_total_size(&list) == 0; result = list.first == NULL && list.last == NULL && list.node_count == 0 && wapp_str8_list_total_size(&list) == 0;
return wapp_tester_result(result); return wpTesterResult(result);
} }
+8 -8
View File
@@ -3,13 +3,13 @@
#include "wapp.h" #include "wapp.h"
TestFuncResult test_str8_list_get(void); WpTestFuncResult test_str8_list_get(void);
TestFuncResult test_str8_list_push_front(void); WpTestFuncResult test_str8_list_push_front(void);
TestFuncResult test_str8_list_push_back(void); WpTestFuncResult test_str8_list_push_back(void);
TestFuncResult test_str8_list_insert(void); WpTestFuncResult test_str8_list_insert(void);
TestFuncResult test_str8_list_pop_front(void); WpTestFuncResult test_str8_list_pop_front(void);
TestFuncResult test_str8_list_pop_back(void); WpTestFuncResult test_str8_list_pop_back(void);
TestFuncResult test_str8_list_remove(void); WpTestFuncResult test_str8_list_remove(void);
TestFuncResult test_str8_list_empty(void); WpTestFuncResult test_str8_list_empty(void);
#endif // !TEST_STR8_LIST_H #endif // !TEST_STR8_LIST_H
+1 -1
View File
@@ -12,7 +12,7 @@
#include <stdlib.h> #include <stdlib.h>
int main(void) { int main(void) {
wapp_tester_run_tests( wpTesterRun(
test_arena_allocator, test_arena_allocator,
test_arena_allocator_with_buffer, test_arena_allocator_with_buffer,
test_arena_allocator_temp_begin, test_arena_allocator_temp_begin,
+1 -1
View File
@@ -12,7 +12,7 @@
#include <stdlib.h> #include <stdlib.h>
int main(void) { int main(void) {
wapp_tester_run_tests( wpTesterRun(
test_arena_allocator, test_arena_allocator,
test_arena_allocator_with_buffer, test_arena_allocator_with_buffer,
test_arena_allocator_temp_begin, test_arena_allocator_temp_begin,