EXPECT_EQ(1U, Alloc.GetNumSlabs());
}
+// Test requesting alignment that goes past the end of the current slab.
+TEST(AllocatorTest, TestAlignmentPastSlab) {
+ BumpPtrAllocator Alloc;
+ Alloc.Allocate(4095, 1);
+
+ // Aligning the current slab pointer is likely to move it past the end of the
+ // slab, which would confuse any unsigned comparisons with the difference of
+ // the the end pointer and the aligned pointer.
+ Alloc.Allocate(1024, 8192);
+
+ EXPECT_EQ(2U, Alloc.GetNumSlabs());
+}
+
// Mock slab allocator that returns slabs aligned on 4096 bytes. There is no
// easy portable way to do this, so this is kind of a hack.
class MockSlabAllocator {