summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-01 20:36:32 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-01 20:36:32 +0000
commit680458275fd6c05ce3683d86483eff1254d0df80 (patch)
tree41916d8fc358650bb6939fd2951995d3e9e46a95 /unittests
parentfa2ab3e4abcecebb8d9a6d8822d8b4beef02bd74 (diff)
downloadllvm-680458275fd6c05ce3683d86483eff1254d0df80.tar.gz
llvm-680458275fd6c05ce3683d86483eff1254d0df80.tar.bz2
llvm-680458275fd6c05ce3683d86483eff1254d0df80.tar.xz
If BumpPtrAllocator is requested to allocate a size that exceeds the slab size,
increase the slab size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151834 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Support/AllocatorTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/unittests/Support/AllocatorTest.cpp b/unittests/Support/AllocatorTest.cpp
index 6c0fca9045..bc5bd3dc40 100644
--- a/unittests/Support/AllocatorTest.cpp
+++ b/unittests/Support/AllocatorTest.cpp
@@ -93,6 +93,14 @@ TEST(AllocatorTest, TestOverflow) {
EXPECT_EQ(2U, Alloc.GetNumSlabs());
}
+// Test allocating with a size larger than the initial slab size.
+TEST(AllocatorTest, TestSmallSlabSize) {
+ BumpPtrAllocator Alloc(128);
+
+ Alloc.Allocate(200, 0);
+ EXPECT_EQ(1U, 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 : public SlabAllocator {