summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-08-24 16:55:52 +0200
committerTor Egge <Tor.Egge@online.no>2023-08-24 16:55:52 +0200
commit63c4469acfef92b9a6ec40593eeef5726afc72ed (patch)
tree2885e81cfd075406802803a7ca56fb8d1debbfea /vespalib
parent0ad9a0678d11acd51504cf98d9de7474f53a1d13 (diff)
Extend test for reusing file offset.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/util/mmap_file_allocator/mmap_file_allocator_test.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/vespalib/src/tests/util/mmap_file_allocator/mmap_file_allocator_test.cpp b/vespalib/src/tests/util/mmap_file_allocator/mmap_file_allocator_test.cpp
index d2088ccb2b7..61faf4e5168 100644
--- a/vespalib/src/tests/util/mmap_file_allocator/mmap_file_allocator_test.cpp
+++ b/vespalib/src/tests/util/mmap_file_allocator/mmap_file_allocator_test.cpp
@@ -12,6 +12,7 @@ namespace {
vespalib::string basedir("mmap-file-allocator-dir");
vespalib::string hello("hello");
+vespalib::string world("world");
struct MyAlloc
{
@@ -107,14 +108,26 @@ TEST_P(MmapFileAllocatorTest, mmap_file_allocator_works)
TEST_P(MmapFileAllocatorTest, reuse_file_offset_works)
{
+ constexpr size_t size_400 = 400;
+ constexpr size_t size_600 = 600;
+ assert(hello.size() + 1 <= size_400);
+ assert(world.size() + 1 <= size_600);
{
- MyAlloc buf(_allocator, _allocator.alloc(hello.size() + 1));
+ MyAlloc buf(_allocator, _allocator.alloc(size_400));
memcpy(buf.data, hello.c_str(), hello.size() + 1);
}
{
- MyAlloc buf(_allocator, _allocator.alloc(hello.size() + 1));
+ MyAlloc buf(_allocator, _allocator.alloc(size_400));
EXPECT_EQ(0, memcmp(buf.data, hello.c_str(), hello.size() + 1));
}
+ {
+ MyAlloc buf(_allocator, _allocator.alloc(size_600));
+ memcpy(buf.data, world.c_str(), world.size() + 1);
+ }
+ {
+ MyAlloc buf(_allocator, _allocator.alloc(size_600));
+ EXPECT_EQ(0, memcmp(buf.data, world.c_str(), world.size() + 1));
+ }
}
GTEST_MAIN_RUN_ALL_TESTS()