Fix MSVC errors and warnings
This commit is contained in:
@@ -26,7 +26,7 @@ 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.realloc != NULL && allocator.realloc_aligned != NULL &&
|
||||
allocator.free == NULL;
|
||||
void *ptr = wapp_mem_allocator_alloc(&allocator, 20);
|
||||
result = result && (ptr != NULL);
|
||||
|
@@ -48,21 +48,21 @@ TestFuncResult test_arena_alloc_fails_when_over_capacity(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_realloc_bigger_size(void) {
|
||||
u64 count = 10;
|
||||
u64 old_count = 10;
|
||||
u64 new_count = 20;
|
||||
i32 *bytes = wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
|
||||
|
||||
for (u64 i = 0; i < count; ++i) {
|
||||
bytes[i] = i;
|
||||
for (u64 i = 0; i < old_count; ++i) {
|
||||
bytes[i] = (i32)i;
|
||||
}
|
||||
|
||||
i32 *new_bytes = wapp_mem_arena_realloc(arena, bytes, 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) {
|
||||
return wapp_tester_result(false);
|
||||
}
|
||||
|
||||
for (u64 i = 0; i < new_count; ++i) {
|
||||
if (i < count && new_bytes[i] != bytes[i]) {
|
||||
if (i < old_count && new_bytes[i] != bytes[i]) {
|
||||
return wapp_tester_result(false);
|
||||
}
|
||||
}
|
||||
@@ -71,15 +71,15 @@ TestFuncResult test_arena_realloc_bigger_size(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_arena_realloc_smaller_size(void) {
|
||||
u64 count = 10;
|
||||
u64 old_count = 10;
|
||||
u64 new_count = 5;
|
||||
i32 *bytes = wapp_mem_arena_alloc(arena, count * sizeof(i32));
|
||||
i32 *bytes = wapp_mem_arena_alloc(arena, old_count * sizeof(i32));
|
||||
|
||||
for (u64 i = 0; i < count; ++i) {
|
||||
bytes[i] = i;
|
||||
for (u64 i = 0; i < old_count; ++i) {
|
||||
bytes[i] = (i32)i;
|
||||
}
|
||||
|
||||
i32 *new_bytes = wapp_mem_arena_realloc(arena, bytes, 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) {
|
||||
return wapp_tester_result(false);
|
||||
}
|
||||
|
@@ -26,12 +26,13 @@ TestFuncResult test_commander_cmd_out_buf_success(void) {
|
||||
char buf[64] = {0};
|
||||
char expected_output[64] = {0};
|
||||
const char *msg = "hello world";
|
||||
u64 length = strlen(msg);
|
||||
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;
|
||||
strncmp(buf, expected_output, length) == 0;
|
||||
|
||||
return wapp_tester_result(succeeded);
|
||||
}
|
||||
@@ -39,9 +40,10 @@ TestFuncResult test_commander_cmd_out_buf_success(void) {
|
||||
TestFuncResult test_commander_cmd_out_buf_failure(void) {
|
||||
char buf[4] = {0};
|
||||
const char *msg = "hello world";
|
||||
u64 length = strlen(msg);
|
||||
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;
|
||||
result.error == SHELL_ERR_OUT_BUF_FULL && strncmp(buf, msg, length) != 0;
|
||||
|
||||
return wapp_tester_result(failed);
|
||||
}
|
||||
|
Reference in New Issue
Block a user