diff --git a/velox/common/memory/tests/MemoryAllocatorTest.cpp b/velox/common/memory/tests/MemoryAllocatorTest.cpp index 40d2ef804e4..fb160d40b1f 100644 --- a/velox/common/memory/tests/MemoryAllocatorTest.cpp +++ b/velox/common/memory/tests/MemoryAllocatorTest.cpp @@ -1310,6 +1310,23 @@ TEST_P(MemoryAllocatorTest, badNonContiguousAllocation) { instance_->freeNonContiguous(*allocation); } +TEST_P(MemoryAllocatorTest, exceedSizeClass) { + AllocationPool pool(pool_.get()); + pool.newRun(AllocationTraits::pageBytes(1)); + auto* allocation = pool.allocationAt(0); + ASSERT_EQ(allocation->numRuns(), 1); + std::for_each( + instance_->sizeClasses().begin(), + instance_->sizeClasses().end(), + [&](const auto& sizeClass) { + ASSERT_NO_THROW( + pool.newRun(AllocationTraits::pageBytes(sizeClass + 1))); + allocation = pool.allocationAt(pool.currentRunIndex()); + ASSERT_EQ(allocation->numRuns(), 1); + }); + pool.clear(); +} + TEST_P(MemoryAllocatorTest, contiguousAllocation) { const MachinePageCount kNumPages = instance_->largestSizeClass() + 1; auto allocation = std::make_unique();