diff options
Diffstat (limited to 'unittests/ADT/StringMapTest.cpp')
-rw-r--r-- | unittests/ADT/StringMapTest.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/unittests/ADT/StringMapTest.cpp b/unittests/ADT/StringMapTest.cpp index 028375d..33d668f 100644 --- a/unittests/ADT/StringMapTest.cpp +++ b/unittests/ADT/StringMapTest.cpp @@ -250,15 +250,21 @@ struct StringMapTestStruct { TEST_F(StringMapTest, NonDefaultConstructable) { StringMap<StringMapTestStruct> t; - t.GetOrCreateValue("Test", StringMapTestStruct(123)); + t.insert(std::make_pair("Test", StringMapTestStruct(123))); StringMap<StringMapTestStruct>::iterator iter = t.find("Test"); ASSERT_NE(iter, t.end()); 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,17 +276,23 @@ private: MoveOnly &operator=(const MoveOnly &) LLVM_DELETED_FUNCTION; }; -TEST_F(StringMapTest, MoveOnlyKey) { +TEST_F(StringMapTest, MoveOnly) { StringMap<MoveOnly> t; - t.GetOrCreateValue("Test", MoveOnly(42)); + t.insert(std::make_pair("Test", MoveOnly(42))); StringRef Key = "Test"; StringMapEntry<MoveOnly>::Create(Key, MoveOnly(42)) ->Destroy(); } +TEST_F(StringMapTest, CtorArg) { + StringRef Key = "Test"; + StringMapEntry<MoveOnly>::Create(Key, Immovable()) + ->Destroy(); +} + TEST_F(StringMapTest, MoveConstruct) { StringMap<int> A; - A.GetOrCreateValue("x", 42); + A["x"] = 42; StringMap<int> B = std::move(A); ASSERT_EQ(A.size(), 0u); ASSERT_EQ(B.size(), 1u); @@ -325,7 +337,7 @@ struct Countable { TEST_F(StringMapTest, MoveDtor) { int InstanceCount = 0; StringMap<Countable> A; - A.GetOrCreateValue("x", Countable(42, InstanceCount)); + A.insert(std::make_pair("x", Countable(42, InstanceCount))); ASSERT_EQ(InstanceCount, 1); auto I = A.find("x"); ASSERT_NE(I, A.end()); |