aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/ADT/StringMapTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/ADT/StringMapTest.cpp')
-rw-r--r--unittests/ADT/StringMapTest.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/unittests/ADT/StringMapTest.cpp b/unittests/ADT/StringMapTest.cpp
index 5bb65cb..b6d41bc 100644
--- a/unittests/ADT/StringMapTest.cpp
+++ b/unittests/ADT/StringMapTest.cpp
@@ -183,23 +183,6 @@ TEST_F(StringMapTest, IterationTest) {
}
}
-} // end anonymous namespace
-
-namespace llvm {
-
-template <>
-class StringMapEntryInitializer<uint32_t> {
-public:
- template <typename InitTy>
- static void Initialize(StringMapEntry<uint32_t> &T, InitTy InitVal) {
- T.second = InitVal;
- }
-};
-
-} // end llvm namespace
-
-namespace {
-
// Test StringMapEntry::Create() method.
TEST_F(StringMapTest, StringMapEntryTest) {
StringMap<uint32_t>::value_type* entry =
@@ -220,4 +203,19 @@ TEST_F(StringMapTest, InsertTest) {
assertSingleItemMap();
}
+// Create a non-default constructable value
+struct StringMapTestStruct {
+ StringMapTestStruct(int i) : i(i) {}
+ StringMapTestStruct() LLVM_DELETED_FUNCTION;
+ int i;
+};
+
+TEST_F(StringMapTest, NonDefaultConstructable) {
+ 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