Implement POSIX file IO
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "test_file.h"
|
||||
|
||||
#define DST_CAPACITY 5
|
||||
wapp_intern Allocator arena = {0};
|
||||
wapp_intern Str8RO test_filename = wapp_str8_lit_ro_initialiser_list("wapptest.bin");
|
||||
wapp_intern Str8RO new_filename = wapp_str8_lit_ro_initialiser_list("wapptest2.bin");
|
||||
wapp_intern WFile *test_fp = NULL;
|
||||
@@ -13,7 +14,8 @@ wapp_intern I32Array dst_array = wapp_array_with_capacity(i32, DST_CAPACI
|
||||
wapp_intern i32 dst_buf[DST_CAPACITY] = {0};
|
||||
|
||||
TestFuncResult test_wapp_file_open(void) {
|
||||
test_fp = wapp_file_open(&test_filename, WAPP_FA_MODE_WB_EX);
|
||||
arena = wapp_mem_arena_allocator_init(KiB(16));
|
||||
test_fp = wapp_file_open(&arena, &test_filename, WAPP_ACCESS_WRITE_BIN_EX);
|
||||
return wapp_tester_result(test_fp != NULL);
|
||||
}
|
||||
|
||||
@@ -25,8 +27,8 @@ TestFuncResult test_wapp_file_get_current_position(void) {
|
||||
TestFuncResult test_wapp_file_seek(void) {
|
||||
wapp_file_write_array((GenericArray)src_array1, test_fp, wapp_array_count(src_array1));
|
||||
|
||||
i32 seek_result = wapp_file_seek(test_fp, 0, WAPP_SEEK_END);
|
||||
b8 result = seek_result == 0;
|
||||
i64 seek_result = wapp_file_seek(test_fp, 0, WAPP_SEEK_END);
|
||||
b8 result = seek_result == (i64)(wapp_array_count(src_array1) * wapp_array_item_size(src_array1));
|
||||
|
||||
wapp_file_seek(test_fp, 0, WAPP_SEEK_START);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "test_file.h"
|
||||
|
||||
#define DST_CAPACITY 5
|
||||
wapp_intern Allocator arena = {};
|
||||
wapp_intern Str8RO test_filename = wapp_str8_lit_ro_initialiser_list("wapptest.bin");
|
||||
wapp_intern Str8RO new_filename = wapp_str8_lit_ro_initialiser_list("wapptest2.bin");
|
||||
wapp_intern WFile *test_fp = NULL;
|
||||
@@ -13,11 +14,12 @@ wapp_intern I32Array src_array3;
|
||||
wapp_intern I32Array dst_array ;
|
||||
|
||||
TestFuncResult test_wapp_file_open(void) {
|
||||
arena = wapp_mem_arena_allocator_init(KiB(16));
|
||||
src_array1 = wapp_array(i32, 0, 1, 2, 3, 4);
|
||||
src_array2 = wapp_array(i32, 5, 6, 7, 8, 9);
|
||||
src_array3 = wapp_array(i32, 10, 11, 12, 13, 14);
|
||||
dst_array = wapp_array_with_capacity(i32, DST_CAPACITY, false);
|
||||
test_fp = wapp_file_open(&test_filename, WAPP_FA_MODE_WB_EX);
|
||||
test_fp = wapp_file_open(&arena, &test_filename, WAPP_ACCESS_WRITE_BIN_EX);
|
||||
return wapp_tester_result(test_fp != NULL);
|
||||
}
|
||||
|
||||
@@ -29,8 +31,8 @@ TestFuncResult test_wapp_file_get_current_position(void) {
|
||||
TestFuncResult test_wapp_file_seek(void) {
|
||||
wapp_file_write_array((GenericArray)src_array1, test_fp, wapp_array_count(src_array1));
|
||||
|
||||
i32 seek_result = wapp_file_seek(test_fp, 0, WAPP_SEEK_END);
|
||||
b8 result = seek_result == 0;
|
||||
i64 seek_result = wapp_file_seek(test_fp, 0, WAPP_SEEK_END);
|
||||
b8 result = seek_result == (i64)(wapp_array_count(src_array1) * wapp_array_item_size(src_array1));
|
||||
|
||||
wapp_file_seek(test_fp, 0, WAPP_SEEK_START);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user