diff --git a/test/cases/fs_mmap_offset.c b/test/cases/fs_mmap_offset.c index 294293f3..155417a4 100644 --- a/test/cases/fs_mmap_offset.c +++ b/test/cases/fs_mmap_offset.c @@ -30,7 +30,7 @@ TEST_FIXTURE_TEARDOWN(fs) ev_fs_remove(NULL, NULL, s_file_path, 0, NULL); } -TEST_F(fs, mmap_offset_half) +TEST_F(fs, mmap_offset_half_size_0) { ev_file_t* file = ev_malloc(sizeof(ev_file_t)); ASSERT_EQ_INT(ev_file_open(NULL, file, NULL, s_file_path, EV_FS_O_RDONLY, 0, NULL), 0); @@ -47,3 +47,21 @@ TEST_F(fs, mmap_offset_half) ev_file_munmap(view); ev_free(view); } + +TEST_F(fs, mmap_offset_half_size_half) +{ + ev_file_t* file = ev_malloc(sizeof(ev_file_t)); + ASSERT_EQ_INT(ev_file_open(NULL, file, NULL, s_file_path, EV_FS_O_RDONLY, 0, NULL), 0); + + ev_file_map_t* view = ev_malloc(sizeof(ev_file_map_t)); + ASSERT_EQ_INT(ev_file_mmap(view, file, s_mmap_offset_granularity, s_mmap_offset_granularity, EV_FS_S_IRUSR), 0); + + const char* data = view->addr; + ASSERT_EQ_INT(memcmp(data, s_file_data + s_mmap_offset_granularity, s_mmap_offset_granularity), 0); + + ev_file_close(file, NULL); + ev_free(file); + + ev_file_munmap(view); + ev_free(view); +}