llvm-ar: Clean up memory management with OwningPtr.
[oota-llvm.git] / unittests / Support / AllocatorTest.cpp
index 6c0fca90456e706ed7d2001d65a78845e9be3cb5..cb9fa430369b7231dde61507b31dff6da9314a8f 100644 (file)
@@ -8,7 +8,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Support/Allocator.h"
-
 #include "gtest/gtest.h"
 #include <cstdlib>
 
@@ -93,6 +92,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(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 : public SlabAllocator {