diff --git a/unittests/ADT/StringMapTest.cpp b/unittests/ADT/StringMapTest.cpp index 2ab09b56064..130a799848d 100644 --- a/unittests/ADT/StringMapTest.cpp +++ b/unittests/ADT/StringMapTest.cpp @@ -203,4 +203,19 @@ TEST_F(StringMapTest, InsertTest) { assertSingleItemMap(); } +// Create a non-default constructable value +TEST_F(StringMapTest, NonDefaultConstructable) { + struct StringMapTestStruct { + StringMapTestStruct(int i) : i(i) {} + StringMapTestStruct() LLVM_DELETED_FUNCTION; + int i; + }; + + StringMap t; + t.GetOrCreateValue("Test", StringMapTestStruct(123)); + StringMap::iterator iter = t.find("Test"); + ASSERT_NE(iter, t.end()); + ASSERT_EQ(iter->second.i, 123); +} + } // end anonymous namespace