summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/StringMapTest.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-01-02 23:57:28 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-01-02 23:57:28 +0000
commite9c66ed80a18b053103135348d63d5b7f8732c13 (patch)
treea8ba088e56cbe2a6ea833f9600e3babca7ae03f1 /llvm/unittests/ADT/StringMapTest.cpp
parenta9376ff571e8dfcd97f909497d929e119ef16787 (diff)
downloadbcm5719-llvm-e9c66ed80a18b053103135348d63d5b7f8732c13.tar.gz
bcm5719-llvm-e9c66ed80a18b053103135348d63d5b7f8732c13.zip
Test coverage for non-default-constructible elements in a StringMap
This functionality was enabled by r198374. Here's a test to ensure it works and we don't regress it. Based on a patch by Maciej Piechotka. llvm-svn: 198377
Diffstat (limited to 'llvm/unittests/ADT/StringMapTest.cpp')
-rw-r--r--llvm/unittests/ADT/StringMapTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
index 2ab09b56064..130a799848d 100644
--- a/llvm/unittests/ADT/StringMapTest.cpp
+++ b/llvm/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<StringMapTestStruct> t;
+ t.GetOrCreateValue("Test", StringMapTestStruct(123));
+ StringMap<StringMapTestStruct>::iterator iter = t.find("Test");
+ ASSERT_NE(iter, t.end());
+ ASSERT_EQ(iter->second.i, 123);
+}
+
} // end anonymous namespace
OpenPOWER on IntegriCloud