[llvm] r198377 - Test coverage for non-default-constructible elements in a StringMap

David Blaikie dblaikie at gmail.com
Thu Jan 2 15:57:28 PST 2014


Author: dblaikie
Date: Thu Jan  2 17:57:28 2014
New Revision: 198377

URL: http://llvm.org/viewvc/llvm-project?rev=198377&view=rev
Log:
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.

Modified:
    llvm/trunk/unittests/ADT/StringMapTest.cpp

Modified: llvm/trunk/unittests/ADT/StringMapTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringMapTest.cpp?rev=198377&r1=198376&r2=198377&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/StringMapTest.cpp (original)
+++ llvm/trunk/unittests/ADT/StringMapTest.cpp Thu Jan  2 17:57:28 2014
@@ -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





More information about the llvm-commits mailing list