1 //===- unittest/ADT/MapVectorTest.cpp - MapVector unit tests ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "gtest/gtest.h"
11 #include "llvm/ADT/MapVector.h"
16 TEST(MapVectorTest, insert_pop) {
17 MapVector<int, int> MV;
18 std::pair<MapVector<int, int>::iterator, bool> R;
20 R = MV.insert(std::make_pair(1, 2));
21 ASSERT_EQ(R.first, MV.begin());
22 EXPECT_EQ(R.first->first, 1);
23 EXPECT_EQ(R.first->second, 2);
24 EXPECT_TRUE(R.second);
26 R = MV.insert(std::make_pair(1, 3));
27 ASSERT_EQ(R.first, MV.begin());
28 EXPECT_EQ(R.first->first, 1);
29 EXPECT_EQ(R.first->second, 2);
30 EXPECT_FALSE(R.second);
32 R = MV.insert(std::make_pair(4, 5));
33 ASSERT_NE(R.first, MV.end());
34 EXPECT_EQ(R.first->first, 4);
35 EXPECT_EQ(R.first->second, 5);
36 EXPECT_TRUE(R.second);
38 EXPECT_EQ(MV.size(), 2u);
43 EXPECT_EQ(MV.size(), 1u);
46 R = MV.insert(std::make_pair(4, 7));
47 ASSERT_NE(R.first, MV.end());
48 EXPECT_EQ(R.first->first, 4);
49 EXPECT_EQ(R.first->second, 7);
50 EXPECT_TRUE(R.second);
52 EXPECT_EQ(MV.size(), 2u);