summaryrefslogtreecommitdiff
path: root/gnu/llvm/unittests/ADT/MapVectorTest.cpp
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2019-01-27 16:43:22 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2019-01-27 16:43:22 +0000
commitb6a478d7aa2abf7e6e7aeb293b0c77a6b00edb64 (patch)
tree744a81d2bb35b8beba356b49171151e54e553c04 /gnu/llvm/unittests/ADT/MapVectorTest.cpp
parent1f30fb5e265a2882c26ec5c86c69f671d0f1aede (diff)
Import LLVM 7.0.1 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/unittests/ADT/MapVectorTest.cpp')
-rw-r--r--gnu/llvm/unittests/ADT/MapVectorTest.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/gnu/llvm/unittests/ADT/MapVectorTest.cpp b/gnu/llvm/unittests/ADT/MapVectorTest.cpp
index bd6602b030f..16e9b5a74f4 100644
--- a/gnu/llvm/unittests/ADT/MapVectorTest.cpp
+++ b/gnu/llvm/unittests/ADT/MapVectorTest.cpp
@@ -157,6 +157,45 @@ TEST(MapVectorTest, NonCopyable) {
ASSERT_EQ(*MV.find(2)->second, 2);
}
+template <class IntType> struct MapVectorMappedTypeTest : ::testing::Test {
+ using int_type = IntType;
+};
+
+using MapIntTypes = ::testing::Types<int, long, long long, unsigned,
+ unsigned long, unsigned long long>;
+TYPED_TEST_CASE(MapVectorMappedTypeTest, MapIntTypes);
+
+TYPED_TEST(MapVectorMappedTypeTest, DifferentDenseMap) {
+ // Test that using a map with a mapped type other than 'unsigned' compiles
+ // and works.
+ using IntType = typename TestFixture::int_type;
+ using MapVectorType = MapVector<int, int, DenseMap<int, IntType>>;
+
+ MapVectorType MV;
+ std::pair<typename MapVectorType::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);
+
+ const std::pair<int, int> Elem(1, 3);
+ R = MV.insert(Elem);
+ ASSERT_EQ(R.first, MV.begin());
+ EXPECT_EQ(R.first->first, 1);
+ EXPECT_EQ(R.first->second, 2);
+ EXPECT_FALSE(R.second);
+
+ int& value = MV[4];
+ EXPECT_EQ(value, 0);
+ value = 5;
+
+ EXPECT_EQ(MV.size(), 2u);
+ EXPECT_EQ(MV[1], 2);
+ EXPECT_EQ(MV[4], 5);
+}
+
TEST(SmallMapVectorSmallTest, insert_pop) {
SmallMapVector<int, int, 32> MV;
std::pair<SmallMapVector<int, int, 32>::iterator, bool> R;