From 0e31ed9058570d2e115c8bcd86c9b50612c94d13 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 16 Apr 2014 10:48:27 +0000 Subject: [Allocator] Make BumpPtrAllocator movable and move assignable. llvm-svn: 206372 --- llvm/unittests/Support/AllocatorTest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'llvm/unittests/Support/AllocatorTest.cpp') diff --git a/llvm/unittests/Support/AllocatorTest.cpp b/llvm/unittests/Support/AllocatorTest.cpp index 8c2ddadf7fa..0fc84c7613f 100644 --- a/llvm/unittests/Support/AllocatorTest.cpp +++ b/llvm/unittests/Support/AllocatorTest.cpp @@ -29,6 +29,21 @@ TEST(AllocatorTest, Basics) { EXPECT_EQ(2, b[9]); EXPECT_EQ(3, *c); EXPECT_EQ(1U, Alloc.GetNumSlabs()); + + BumpPtrAllocator Alloc2 = std::move(Alloc); + EXPECT_EQ(0U, Alloc.GetNumSlabs()); + EXPECT_EQ(1U, Alloc2.GetNumSlabs()); + + // Make sure the old pointers still work. These are especially interesting + // under ASan or Valgrind. + EXPECT_EQ(1, *a); + EXPECT_EQ(2, b[0]); + EXPECT_EQ(2, b[9]); + EXPECT_EQ(3, *c); + + Alloc = std::move(Alloc2); + EXPECT_EQ(0U, Alloc2.GetNumSlabs()); + EXPECT_EQ(1U, Alloc.GetNumSlabs()); } // Allocate enough bytes to create three slabs. -- cgit v1.2.3