aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/StringMapTest.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2016-03-30 19:54:56 +0000
committerHal Finkel <hfinkel@anl.gov>2016-03-30 19:54:56 +0000
commit38bf13d02ce7dda0a9fc77c94457da0be8cf5c1b (patch)
treefe83c137628fd918bdeac3b777dbc9c1d61af3ed /llvm/unittests/ADT/StringMapTest.cpp
parent4709190376d2d29f5b26a69f540feac31444080a (diff)
downloadllvm-38bf13d02ce7dda0a9fc77c94457da0be8cf5c1b.zip
llvm-38bf13d02ce7dda0a9fc77c94457da0be8cf5c1b.tar.gz
llvm-38bf13d02ce7dda0a9fc77c94457da0be8cf5c1b.tar.bz2
Add a copy constructor to StringMap
There is code under review that requires StringMap to have a copy constructor, and this makes StringMap more consistent with our other containers (like DenseMap) that have copy constructors. Differential Revision: http://reviews.llvm.org/D18506 llvm-svn: 264906
Diffstat (limited to 'llvm/unittests/ADT/StringMapTest.cpp')
-rw-r--r--llvm/unittests/ADT/StringMapTest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
index 562126e..a85cae1 100644
--- a/llvm/unittests/ADT/StringMapTest.cpp
+++ b/llvm/unittests/ADT/StringMapTest.cpp
@@ -157,6 +157,33 @@ TEST_F(StringMapTest, SmallFullMapTest) {
EXPECT_EQ(5, Map.lookup("funf"));
}
+TEST_F(StringMapTest, CopyCtorTest) {
+ llvm::StringMap<int> Map;
+
+ Map["eins"] = 1;
+ Map["zwei"] = 2;
+ Map["drei"] = 3;
+ Map.erase("drei");
+ Map.erase("eins");
+ Map["veir"] = 4;
+ Map["funf"] = 5;
+
+ EXPECT_EQ(3u, Map.size());
+ EXPECT_EQ(0, Map.lookup("eins"));
+ EXPECT_EQ(2, Map.lookup("zwei"));
+ EXPECT_EQ(0, Map.lookup("drei"));
+ EXPECT_EQ(4, Map.lookup("veir"));
+ EXPECT_EQ(5, Map.lookup("funf"));
+
+ llvm::StringMap<int> Map2(Map);
+ EXPECT_EQ(3u, Map2.size());
+ EXPECT_EQ(0, Map2.lookup("eins"));
+ EXPECT_EQ(2, Map2.lookup("zwei"));
+ EXPECT_EQ(0, Map2.lookup("drei"));
+ EXPECT_EQ(4, Map2.lookup("veir"));
+ EXPECT_EQ(5, Map2.lookup("funf"));
+}
+
// A more complex iteration test.
TEST_F(StringMapTest, IterationTest) {
bool visited[100];