X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=unittests%2FADT%2FStringMapTest.cpp;h=4ed0b76f0f41a2024c93104ce5d5399526e13487;hb=00552e3875ee5f382db6c98286a241a7d0efe1b8;hp=215d3dfa02e5a86ec482b684806adf847e35ff1d;hpb=4110a7ac7ac9f5814b6828e498efdb3e75110f66;p=oota-llvm.git diff --git a/unittests/ADT/StringMapTest.cpp b/unittests/ADT/StringMapTest.cpp index 215d3dfa02e..4ed0b76f0f4 100644 --- a/unittests/ADT/StringMapTest.cpp +++ b/unittests/ADT/StringMapTest.cpp @@ -244,21 +244,27 @@ TEST_F(StringMapTest, InsertRehashingPairTest) { // Create a non-default constructable value struct StringMapTestStruct { StringMapTestStruct(int i) : i(i) {} - StringMapTestStruct() LLVM_DELETED_FUNCTION; + StringMapTestStruct() = delete; int i; }; TEST_F(StringMapTest, NonDefaultConstructable) { StringMap t; - t.GetOrCreateValue("Test", StringMapTestStruct(123)); + t.insert(std::make_pair("Test", StringMapTestStruct(123))); StringMap::iterator iter = t.find("Test"); ASSERT_NE(iter, t.end()); ASSERT_EQ(iter->second.i, 123); } +struct Immovable { + Immovable() {} + Immovable(Immovable&&) = delete; // 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; @@ -266,21 +272,27 @@ struct MoveOnly { } private: - MoveOnly(const MoveOnly &); - MoveOnly &operator=(const MoveOnly &); + MoveOnly(const MoveOnly &) = delete; + MoveOnly &operator=(const MoveOnly &) = delete; }; -TEST_F(StringMapTest, MoveOnlyKey) { +TEST_F(StringMapTest, MoveOnly) { StringMap t; - t.GetOrCreateValue("Test", MoveOnly(42)); + t.insert(std::make_pair("Test", MoveOnly(42))); StringRef Key = "Test"; StringMapEntry::Create(Key, MoveOnly(42)) ->Destroy(); } +TEST_F(StringMapTest, CtorArg) { + StringRef Key = "Test"; + StringMapEntry::Create(Key, Immovable()) + ->Destroy(); +} + TEST_F(StringMapTest, MoveConstruct) { StringMap A; - A.GetOrCreateValue("x", 42); + A["x"] = 42; StringMap 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 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());