38#include <gtest/gtest.h>
48constexpr std::size_t kBlockSize = 64;
52TEST(AhMemTest, AllocateReturnsValidBuffer)
55 ASSERT_NE(ptr,
nullptr);
56 std::memset(ptr, 0xAB, kBlockSize);
60TEST(AhMemTest, AllocateRejectsZeroSize)
62 EXPECT_THROW(
static_cast<void>(
Aleph::allocate(0)), std::invalid_argument);
65TEST(AhMemTest, AllocateZeroedClearsMemory)
68 ASSERT_NE(ptr,
nullptr);
69 const unsigned char * bytes =
70 static_cast<const unsigned char *
>(ptr);
71 for (std::size_t i = 0; i < kBlockSize; ++i)
72 EXPECT_EQ(bytes[i], 0u);
76TEST(AhMemTest, AllocateZeroedRejectsZeroSize)
79 std::invalid_argument);
Aleph-w memory allocation helpers and instrumentation hooks.
T * allocate(AhArenaAllocator &arena, Args &&... args)
Allocate and construct an object in an arena.
void * allocate_zeroed(const std::size_t size)
Allocate size zero-initialized bytes.
void deallocate(AhArenaAllocator &arena, T *ptr) noexcept
Destruct and deallocate an object from an arena.