summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-04-16 10:48:27 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-04-16 10:48:27 +0000
commitd66a3fe1064313da76aa39cda8bf0481d5f101a8 (patch)
treed63f11bb8b921ce5d6ba34371665375f556c3e6c /unittests
parentb78eac2d4d614010dc75f58371ca444bd7dbc6af (diff)
downloadllvm-d66a3fe1064313da76aa39cda8bf0481d5f101a8.tar.gz
llvm-d66a3fe1064313da76aa39cda8bf0481d5f101a8.tar.bz2
llvm-d66a3fe1064313da76aa39cda8bf0481d5f101a8.tar.xz
[Allocator] Make BumpPtrAllocator movable and move assignable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206372 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Support/AllocatorTest.cpp15
1 files changed, 15 insertions, 0 deletions
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.