Reformat
This commit is contained in:
@@ -8,11 +8,11 @@
|
||||
|
||||
TestFuncResult test_libc_allocator(void) {
|
||||
Allocator allocator = wapp_mem_libc_allocator();
|
||||
bool result = allocator.obj == NULL && allocator.alloc != NULL &&
|
||||
allocator.alloc_aligned != NULL && allocator.realloc != NULL &&
|
||||
allocator.realloc_aligned == NULL && allocator.free != NULL;
|
||||
void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
|
||||
result = result && (ptr != NULL);
|
||||
bool result = allocator.obj == NULL && allocator.alloc != NULL &&
|
||||
allocator.alloc_aligned != NULL && allocator.realloc != NULL &&
|
||||
allocator.realloc_aligned == NULL && allocator.free != NULL;
|
||||
void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
|
||||
result = result && (ptr != NULL);
|
||||
|
||||
if (ptr != NULL) {
|
||||
wapp_mem_allocator_free(&allocator, &ptr);
|
||||
@@ -24,12 +24,12 @@ TestFuncResult test_libc_allocator(void) {
|
||||
|
||||
TestFuncResult test_arena_allocator(void) {
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(4096);
|
||||
bool result = allocator.obj != NULL && allocator.alloc != NULL &&
|
||||
allocator.alloc_aligned != NULL &&
|
||||
allocator.realloc == NULL & allocator.realloc_aligned == NULL &&
|
||||
allocator.free == NULL;
|
||||
void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
|
||||
result = result && (ptr != NULL);
|
||||
bool result = allocator.obj != NULL && allocator.alloc != NULL &&
|
||||
allocator.alloc_aligned != NULL &&
|
||||
allocator.realloc == NULL & allocator.realloc_aligned == NULL &&
|
||||
allocator.free == NULL;
|
||||
void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
|
||||
result = result && (ptr != NULL);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
|
||||
|
@@ -9,8 +9,8 @@
|
||||
#define ARENA_CAPACITY 1024
|
||||
|
||||
internal Arena *arena = NULL;
|
||||
internal i32 count = 20;
|
||||
internal i32 *array = NULL;
|
||||
internal i32 count = 20;
|
||||
internal i32 *array = NULL;
|
||||
|
||||
TestFuncResult test_arena_init(void) {
|
||||
bool result = wapp_mem_arena_init(&arena, ARENA_CAPACITY);
|
||||
@@ -20,8 +20,8 @@ TestFuncResult test_arena_init(void) {
|
||||
|
||||
TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
||||
Arena *large_arena = NULL;
|
||||
u64 capacity = GB(512);
|
||||
bool result = wapp_mem_arena_init(&large_arena, capacity);
|
||||
u64 capacity = GB(512);
|
||||
bool result = wapp_mem_arena_init(&large_arena, capacity);
|
||||
if (result) {
|
||||
wapp_mem_arena_destroy(&large_arena);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ TestFuncResult test_arena_init_succeeds_when_reserving_very_large_size(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
array = wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
array = wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
bool result = array != NULL;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
@@ -41,7 +41,7 @@ TestFuncResult test_arena_alloc_succeeds_when_within_capacity(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
|
||||
u8 *bytes = wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2);
|
||||
u8 *bytes = wapp_mem_arena_alloc(arena, ARENA_CAPACITY * 2);
|
||||
bool result = bytes == NULL;
|
||||
|
||||
return wapp_tester_result(result);
|
||||
|
@@ -7,49 +7,41 @@
|
||||
#include <string.h>
|
||||
|
||||
TestFuncResult test_commander_cmd_success(void) {
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, 0,
|
||||
"echo", "hello world");
|
||||
|
||||
bool succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR;
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, 0, "echo", "hello world");
|
||||
bool succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR;
|
||||
|
||||
return wapp_tester_result(succeeded);
|
||||
}
|
||||
|
||||
TestFuncResult test_commander_cmd_failure(void) {
|
||||
CMDResult result =
|
||||
wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, 0, "grep");
|
||||
|
||||
bool failed = result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR;
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, 0, "grep");
|
||||
bool failed = result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR;
|
||||
|
||||
return wapp_tester_result(failed);
|
||||
}
|
||||
|
||||
TestFuncResult test_commander_cmd_out_buf_success(void) {
|
||||
char buf[64] = {0};
|
||||
char buf[64] = {0};
|
||||
char expected_output[64] = {0};
|
||||
const char *msg = "hello world";
|
||||
const char *msg = "hello world";
|
||||
sprintf(expected_output, "%s\n", msg);
|
||||
|
||||
CMDResult result =
|
||||
wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, buf, 64, "echo", msg);
|
||||
|
||||
bool succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR &&
|
||||
strcmp(buf, expected_output) == 0;
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, buf, 64, "echo", msg);
|
||||
bool succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_NO_ERROR &&
|
||||
strcmp(buf, expected_output) == 0;
|
||||
|
||||
return wapp_tester_result(succeeded);
|
||||
}
|
||||
|
||||
TestFuncResult test_commander_cmd_out_buf_failure(void) {
|
||||
char buf[4] = {0};
|
||||
const char *msg = "hello world";
|
||||
CMDResult result =
|
||||
wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, buf, 4, "echo", msg);
|
||||
|
||||
bool failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_OUT_BUF_FULL && strcmp(buf, msg) != 0;
|
||||
char buf[4] = {0};
|
||||
const char *msg = "hello world";
|
||||
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, buf, 4, "echo", msg);
|
||||
bool failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
|
||||
result.error == SHELL_ERR_OUT_BUF_FULL && strcmp(buf, msg) != 0;
|
||||
|
||||
return wapp_tester_result(failed);
|
||||
}
|
||||
|
Reference in New Issue
Block a user