#include <gtest/gtest.h>
#include "common/PoolAlloc.h"
namespace angle
{
TEST(PoolAllocatorTest, Interface)
{ … }
#if !defined(ANGLE_POOL_ALLOC_GUARD_BLOCKS)
class PoolAllocatorAlignmentTest : public testing::TestWithParam<int>
{};
TEST_P(PoolAllocatorAlignmentTest, Alignment)
{
int alignment = GetParam();
PoolAllocator poolAllocator(4096, alignment);
for (uint32_t i = 0; i < 100; ++i)
{
const size_t numBytes = rand() % (1024 * 4) + 1;
void *allocation = poolAllocator.allocate(numBytes);
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(allocation) % alignment)
<< "Iteration " << i << " allocating " << numBytes;
}
}
INSTANTIATE_TEST_SUITE_P(,
PoolAllocatorAlignmentTest,
testing::Values(2, 4, 8, 16, 32, 64, 128),
testing::PrintToStringParamName());
#endif
}