blob: 9f613697d57409a90aacb52fa8c177e8292e9a6b [file] [log] [blame]
Nick Lewycky6bbf4ff2013-01-25 22:11:02 +00001//===- unittest/ADT/MapVectorTest.cpp - MapVector unit tests ----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "gtest/gtest.h"
11#include "llvm/ADT/MapVector.h"
12#include <utility>
13
14using namespace llvm;
15
16TEST(MapVectorTest, insert) {
17 MapVector<int, int> MV;
18 std::pair<MapVector<int, int>::iterator, bool> R;
19
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);
25
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);
31
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);
37
38 EXPECT_EQ(MV.size(), 2u);
39 EXPECT_EQ(MV[1], 2);
40 EXPECT_EQ(MV[4], 5);
41}