Lines Matching refs:map
12 #include <map>
76 // allows all of the map implementations to be tested with shared
81 T Map;
110 // Empty map tests
113 EXPECT_EQ(0u, this->Map.size());
114 EXPECT_TRUE(this->Map.empty());
117 EXPECT_TRUE(this->Map.begin() == this->Map.end());
120 EXPECT_FALSE(this->Map.count(this->getKey()));
121 EXPECT_TRUE(this->Map.find(this->getKey()) == this->Map.end());
124 this->Map.lookup(this->getKey()));
131 this->Map.lookup(this->getKey()));
135 // Constant map tests
137 const TypeParam &ConstMap = this->Map;
143 // A map with a single entry
145 this->Map[this->getKey()] = this->getValue();
148 EXPECT_EQ(1u, this->Map.size());
149 EXPECT_FALSE(this->Map.begin() == this->Map.end());
150 EXPECT_FALSE(this->Map.empty());
153 typename TypeParam::iterator it = this->Map.begin();
157 EXPECT_TRUE(it == this->Map.end());
160 EXPECT_TRUE(this->Map.count(this->getKey()));
161 EXPECT_TRUE(this->Map.find(this->getKey()) == this->Map.begin());
162 EXPECT_EQ(this->getValue(), this->Map.lookup(this->getKey()));
163 EXPECT_EQ(this->getValue(), this->Map[this->getKey()]);
168 this->Map[this->getKey()] = this->getValue();
169 this->Map.clear();
171 EXPECT_EQ(0u, this->Map.size());
172 EXPECT_TRUE(this->Map.empty());
173 EXPECT_TRUE(this->Map.begin() == this->Map.end());
178 this->Map[this->getKey()] = this->getValue();
179 this->Map.erase(this->Map.begin());
181 EXPECT_EQ(0u, this->Map.size());
182 EXPECT_TRUE(this->Map.empty());
183 EXPECT_TRUE(this->Map.begin() == this->Map.end());
188 this->Map[this->getKey()] = this->getValue();
189 this->Map.erase(this->getKey());
191 EXPECT_EQ(0u, this->Map.size());
192 EXPECT_TRUE(this->Map.empty());
193 EXPECT_TRUE(this->Map.begin() == this->Map.end());
198 this->Map.insert(std::make_pair(this->getKey(), this->getValue()));
199 EXPECT_EQ(1u, this->Map.size());
200 EXPECT_EQ(this->getValue(), this->Map[this->getKey()]);
205 this->Map[this->getKey()] = this->getValue();
206 TypeParam copyMap(this->Map);
215 this->Map[this->getKey(Key)] = this->getValue(Key);
216 TypeParam copyMap(this->Map);
223 // Test copying from a default-constructed map.
225 TypeParam copyMap(this->Map);
230 // Test copying from an empty map where SmallDenseMap isn't small.
233 this->Map[this->getKey(Key)] = this->getValue(Key);
234 this->Map.clear();
235 TypeParam copyMap(this->Map);
242 this->Map[this->getKey()] = this->getValue();
243 TypeParam copyMap = this->Map;
251 this->Map[this->getKey()] = this->getValue();
254 this->Map.swap(otherMap);
255 EXPECT_EQ(0u, this->Map.size());
256 EXPECT_TRUE(this->Map.empty());
260 this->Map.swap(otherMap);
263 EXPECT_EQ(1u, this->Map.size());
264 EXPECT_EQ(this->getValue(), this->Map[this->getKey()]);
266 // Make this more interesting by inserting 100 numbers into the map.
268 this->Map[this->getKey(i)] = this->getValue(i);
270 this->Map.swap(otherMap);
271 EXPECT_EQ(0u, this->Map.size());
272 EXPECT_TRUE(this->Map.empty());
277 this->Map.swap(otherMap);
280 EXPECT_EQ(100u, this->Map.size());
282 EXPECT_EQ(this->getValue(i), this->Map[this->getKey(i)]);
288 std::map<typename TypeParam::key_type, unsigned> visitedIndex;
290 // Insert 100 numbers into the map
295 this->Map[this->getKey(i)] = this->getValue(i);
299 for (typename TypeParam::iterator it = this->Map.begin();
300 it != this->Map.end(); ++it)
311 typename TypeParam::iterator it = this->Map.begin();
339 DenseMap<unsigned, unsigned, TestDenseMapInfo> map;
340 map[0] = 1;
341 map[1] = 2;
342 map[2] = 3;
345 EXPECT_EQ(3u, map.size());
348 EXPECT_EQ(1u, map.count(1));
349 EXPECT_EQ(1u, map.find(0)->second);
350 EXPECT_EQ(2u, map.find(1)->second);
351 EXPECT_EQ(3u, map.find(2)->second);
352 EXPECT_TRUE(map.find(3) == map.end());
355 EXPECT_EQ(1u, map.find_as("a")->second);
356 EXPECT_EQ(2u, map.find_as("b")->second);
357 EXPECT_EQ(3u, map.find_as("c")->second);
358 EXPECT_TRUE(map.find_as("d") == map.end());
370 // Test that filling a small dense map with exactly the number of elements in
371 // the map grows to have enough space for an empty bucket.
373 SmallDenseMap<unsigned, unsigned, 32, ContiguousDenseMapInfo> map;
375 // If we just filled the map with 32 elements we'd grow because of not enough
378 map[i] = i + 1;
380 map.erase(i);
382 map[i] = i + 1;
385 EXPECT_EQ(22u, map.size());
388 // SmallDenseMap which led to a map with num elements == small capacity not
389 // having an empty bucket any more. Finding an element not in the map would
391 EXPECT_TRUE(map.find(32) == map.end());