|
10 | 10 | #include "CountCopyAndMove.h"
|
11 | 11 | #include "llvm/ADT/DenseMapInfo.h"
|
12 | 12 | #include "llvm/ADT/DenseMapInfoVariant.h"
|
| 13 | +#include "llvm/ADT/SmallSet.h" |
13 | 14 | #include "llvm/ADT/StringRef.h"
|
14 | 15 | #include "gmock/gmock.h"
|
15 | 16 | #include "gtest/gtest.h"
|
@@ -359,6 +360,51 @@ TYPED_TEST(DenseMapTest, ConstIteratorTest) {
|
359 | 360 | EXPECT_TRUE(cit == cit2);
|
360 | 361 | }
|
361 | 362 |
|
| 363 | +TYPED_TEST(DenseMapTest, KeysValuesIterator) { |
| 364 | + SmallSet<typename TypeParam::key_type, 10> Keys; |
| 365 | + SmallSet<typename TypeParam::mapped_type, 10> Values; |
| 366 | + for (int I = 0; I < 10; ++I) { |
| 367 | + auto K = this->getKey(I); |
| 368 | + auto V = this->getValue(I); |
| 369 | + Keys.insert(K); |
| 370 | + Values.insert(V); |
| 371 | + this->Map[K] = V; |
| 372 | + } |
| 373 | + |
| 374 | + SmallSet<typename TypeParam::key_type, 10> ActualKeys; |
| 375 | + SmallSet<typename TypeParam::mapped_type, 10> ActualValues; |
| 376 | + for (auto K : this->Map.keys()) |
| 377 | + ActualKeys.insert(K); |
| 378 | + for (auto V : this->Map.values()) |
| 379 | + ActualValues.insert(V); |
| 380 | + |
| 381 | + EXPECT_EQ(Keys, ActualKeys); |
| 382 | + EXPECT_EQ(Values, ActualValues); |
| 383 | +} |
| 384 | + |
| 385 | +TYPED_TEST(DenseMapTest, ConstKeysValuesIterator) { |
| 386 | + SmallSet<typename TypeParam::key_type, 10> Keys; |
| 387 | + SmallSet<typename TypeParam::mapped_type, 10> Values; |
| 388 | + for (int I = 0; I < 10; ++I) { |
| 389 | + auto K = this->getKey(I); |
| 390 | + auto V = this->getValue(I); |
| 391 | + Keys.insert(K); |
| 392 | + Values.insert(V); |
| 393 | + this->Map[K] = V; |
| 394 | + } |
| 395 | + |
| 396 | + const TypeParam &ConstMap = this->Map; |
| 397 | + SmallSet<typename TypeParam::key_type, 10> ActualKeys; |
| 398 | + SmallSet<typename TypeParam::mapped_type, 10> ActualValues; |
| 399 | + for (auto K : ConstMap.keys()) |
| 400 | + ActualKeys.insert(K); |
| 401 | + for (auto V : ConstMap.values()) |
| 402 | + ActualValues.insert(V); |
| 403 | + |
| 404 | + EXPECT_EQ(Keys, ActualKeys); |
| 405 | + EXPECT_EQ(Values, ActualValues); |
| 406 | +} |
| 407 | + |
362 | 408 | // Test initializer list construction.
|
363 | 409 | TEST(DenseMapCustomTest, InitializerList) {
|
364 | 410 | DenseMap<int, int> M({{0, 0}, {0, 1}, {1, 2}});
|
|
0 commit comments