[Orc][Kaleidoscope] Build Kaleidoscope/Orc tutorials with warnings.
[oota-llvm.git] / unittests / ADT / ImmutableMapTest.cpp
1 //===----------- ImmutableMapTest.cpp - ImmutableMap unit tests ------------===//
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/ImmutableMap.h"
12
13 using namespace llvm;
14
15 namespace {
16
17 TEST(ImmutableMapTest, EmptyIntMapTest) {
18   ImmutableMap<int, int>::Factory f;
19
20   EXPECT_TRUE(f.getEmptyMap() == f.getEmptyMap());
21   EXPECT_FALSE(f.getEmptyMap() != f.getEmptyMap());
22   EXPECT_TRUE(f.getEmptyMap().isEmpty());
23
24   ImmutableMap<int, int> S = f.getEmptyMap();
25   EXPECT_EQ(0u, S.getHeight());
26   EXPECT_TRUE(S.begin() == S.end());
27   EXPECT_FALSE(S.begin() != S.end());
28 }
29
30 TEST(ImmutableMapTest, MultiElemIntMapTest) {
31   ImmutableMap<int, int>::Factory f;
32   ImmutableMap<int, int> S = f.getEmptyMap();
33
34   ImmutableMap<int, int> S2 = f.add(f.add(f.add(S, 3, 10), 4, 11), 5, 12);
35
36   EXPECT_TRUE(S.isEmpty());
37   EXPECT_FALSE(S2.isEmpty());
38
39   EXPECT_EQ(nullptr, S.lookup(3));
40   EXPECT_EQ(nullptr, S.lookup(9));
41
42   EXPECT_EQ(10, *S2.lookup(3));
43   EXPECT_EQ(11, *S2.lookup(4));
44   EXPECT_EQ(12, *S2.lookup(5));
45
46   EXPECT_EQ(5, S2.getMaxElement()->first);
47   EXPECT_EQ(3U, S2.getHeight());
48 }
49
50 }