summaryrefslogtreecommitdiff
path: root/unittests
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
commit4c9b681d6d5cdf9adf6df0067daf0b1911083026 (patch)
treecb2ed0cbbbeea6c8c719d05ca7238480838a65dc /unittests
parenta11df460ace96f61b3f0d7320d7681e37d407d5a (diff)
downloadllvm-4c9b681d6d5cdf9adf6df0067daf0b1911083026.tar.gz
llvm-4c9b681d6d5cdf9adf6df0067daf0b1911083026.tar.bz2
llvm-4c9b681d6d5cdf9adf6df0067daf0b1911083026.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198377 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/StringMapTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/unittests/ADT/StringMapTest.cpp b/unittests/ADT/StringMapTest.cpp
index 2ab09b5606..130a799848 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<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