StringMap support for move-only values.
[oota-llvm.git] / unittests / ADT / StringMapTest.cpp
index b6d41bcc8e5a9fd79fe712c70ebd1e18cb8a4119..42a03886180322b76a611116505b9e96a5bf21a8 100644 (file)
@@ -218,4 +218,20 @@ TEST_F(StringMapTest, NonDefaultConstructable) {
   ASSERT_EQ(iter->second.i, 123);
 }
 
+struct MoveOnly {
+  int i;
+  MoveOnly(int i) : i(i) {}
+  MoveOnly(MoveOnly&&) = default;
+  MoveOnly(const MoveOnly&) = delete;
+  MoveOnly &operator=(MoveOnly&&) = default;
+  MoveOnly &operator=(const MoveOnly&) = delete;
+};
+
+TEST_F(StringMapTest, MoveOnlyKey) {
+  StringMap<MoveOnly> t;
+  t.GetOrCreateValue("Test", MoveOnly(42));
+  StringRef Key = "Test";
+  StringMapEntry<MoveOnly>::Create(Key.begin(), Key.end(), MoveOnly(42))->Destroy();
+}
+
 } // end anonymous namespace