aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/MapVectorTest.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2013-01-25 22:11:02 +0000
committerNick Lewycky <nicholas@mxc.ca>2013-01-25 22:11:02 +0000
commit476a6dab9f1caee281666dd718db1a438cae14f1 (patch)
treeafa0d02617f43d36ac0215eeb05da137c6f6997e /llvm/unittests/ADT/MapVectorTest.cpp
parent699ad11c58161b719a6d9b05a7469631c77efce4 (diff)
downloadllvm-476a6dab9f1caee281666dd718db1a438cae14f1.zip
llvm-476a6dab9f1caee281666dd718db1a438cae14f1.tar.gz
llvm-476a6dab9f1caee281666dd718db1a438cae14f1.tar.bz2
Add an insert() method to MapVector. Adds the first MapVector unit test.
llvm-svn: 173505
Diffstat (limited to 'llvm/unittests/ADT/MapVectorTest.cpp')
-rw-r--r--llvm/unittests/ADT/MapVectorTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/MapVectorTest.cpp b/llvm/unittests/ADT/MapVectorTest.cpp
new file mode 100644
index 0000000..9f61369
--- /dev/null
+++ b/llvm/unittests/ADT/MapVectorTest.cpp
@@ -0,0 +1,41 @@
+//===- unittest/ADT/MapVectorTest.cpp - MapVector unit tests ----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gtest/gtest.h"
+#include "llvm/ADT/MapVector.h"
+#include <utility>
+
+using namespace llvm;
+
+TEST(MapVectorTest, insert) {
+ MapVector<int, int> MV;
+ std::pair<MapVector<int, int>::iterator, bool> R;
+
+ R = MV.insert(std::make_pair(1, 2));
+ ASSERT_EQ(R.first, MV.begin());
+ EXPECT_EQ(R.first->first, 1);
+ EXPECT_EQ(R.first->second, 2);
+ EXPECT_TRUE(R.second);
+
+ R = MV.insert(std::make_pair(1, 3));
+ ASSERT_EQ(R.first, MV.begin());
+ EXPECT_EQ(R.first->first, 1);
+ EXPECT_EQ(R.first->second, 2);
+ EXPECT_FALSE(R.second);
+
+ R = MV.insert(std::make_pair(4, 5));
+ ASSERT_NE(R.first, MV.end());
+ EXPECT_EQ(R.first->first, 4);
+ EXPECT_EQ(R.first->second, 5);
+ EXPECT_TRUE(R.second);
+
+ EXPECT_EQ(MV.size(), 2u);
+ EXPECT_EQ(MV[1], 2);
+ EXPECT_EQ(MV[4], 5);
+}