aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/StringMapTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/ADT/StringMapTest.cpp')
-rw-r--r--llvm/unittests/ADT/StringMapTest.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
index 028375d..af9b611 100644
--- a/llvm/unittests/ADT/StringMapTest.cpp
+++ b/llvm/unittests/ADT/StringMapTest.cpp
@@ -256,9 +256,15 @@ TEST_F(StringMapTest, NonDefaultConstructable) {
ASSERT_EQ(iter->second.i, 123);
}
+struct Immovable {
+ Immovable() {}
+ Immovable(Immovable&&) LLVM_DELETED_FUNCTION; // will disable the other special members
+};
+
struct MoveOnly {
int i;
MoveOnly(int i) : i(i) {}
+ MoveOnly(const Immovable&) : i(0) {}
MoveOnly(MoveOnly &&RHS) : i(RHS.i) {}
MoveOnly &operator=(MoveOnly &&RHS) {
i = RHS.i;
@@ -270,7 +276,7 @@ private:
MoveOnly &operator=(const MoveOnly &) LLVM_DELETED_FUNCTION;
};
-TEST_F(StringMapTest, MoveOnlyKey) {
+TEST_F(StringMapTest, MoveOnly) {
StringMap<MoveOnly> t;
t.GetOrCreateValue("Test", MoveOnly(42));
StringRef Key = "Test";
@@ -278,6 +284,14 @@ TEST_F(StringMapTest, MoveOnlyKey) {
->Destroy();
}
+TEST_F(StringMapTest, CtorArg) {
+ StringMap<MoveOnly> t;
+ t.GetOrCreateValue("Test", Immovable());
+ StringRef Key = "Test";
+ StringMapEntry<MoveOnly>::Create(Key, Immovable())
+ ->Destroy();
+}
+
TEST_F(StringMapTest, MoveConstruct) {
StringMap<int> A;
A.GetOrCreateValue("x", 42);