From d66a3fe1064313da76aa39cda8bf0481d5f101a8 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206372 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Support/AllocatorTest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'unittests') diff --git a/unittests/Support/AllocatorTest.cpp b/unittests/Support/AllocatorTest.cpp index 8c2ddadf7f..0fc84c7613 100644 --- a/unittests/Support/AllocatorTest.cpp +++ b/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