From 476a6dab9f1caee281666dd718db1a438cae14f1 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 25 Jan 2013 22:11:02 +0000 Subject: Add an insert() method to MapVector. Adds the first MapVector unit test. llvm-svn: 173505 --- llvm/unittests/ADT/MapVectorTest.cpp | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 llvm/unittests/ADT/MapVectorTest.cpp (limited to 'llvm/unittests/ADT/MapVectorTest.cpp') 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 + +using namespace llvm; + +TEST(MapVectorTest, insert) { + MapVector MV; + std::pair::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); +} -- cgit v1.1