Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions llvm/unittests/ADT/DenseMapTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,16 @@ TYPED_TEST(DenseMapTest, ConstIteratorTest) {
EXPECT_TRUE(cit == cit2);
}

// TYPED_TEST below cycles through different types. We define UniversalSmallSet
// here so that we'll use SmallSet or SmallPtrSet depending on whether the
// element type is a pointer.
template <typename T, unsigned N>
using UniversalSmallSet =
std::conditional_t<std::is_pointer_v<T>, SmallPtrSet<T, N>, SmallSet<T, N>>;

TYPED_TEST(DenseMapTest, KeysValuesIterator) {
SmallSet<typename TypeParam::key_type, 10> Keys;
SmallSet<typename TypeParam::mapped_type, 10> Values;
UniversalSmallSet<typename TypeParam::key_type, 10> Keys;
UniversalSmallSet<typename TypeParam::mapped_type, 10> Values;
for (int I = 0; I < 10; ++I) {
auto K = this->getKey(I);
auto V = this->getValue(I);
Expand All @@ -398,8 +405,8 @@ TYPED_TEST(DenseMapTest, KeysValuesIterator) {
this->Map[K] = V;
}

SmallSet<typename TypeParam::key_type, 10> ActualKeys;
SmallSet<typename TypeParam::mapped_type, 10> ActualValues;
UniversalSmallSet<typename TypeParam::key_type, 10> ActualKeys;
UniversalSmallSet<typename TypeParam::mapped_type, 10> ActualValues;
for (auto K : this->Map.keys())
ActualKeys.insert(K);
for (auto V : this->Map.values())
Expand All @@ -410,8 +417,8 @@ TYPED_TEST(DenseMapTest, KeysValuesIterator) {
}

TYPED_TEST(DenseMapTest, ConstKeysValuesIterator) {
SmallSet<typename TypeParam::key_type, 10> Keys;
SmallSet<typename TypeParam::mapped_type, 10> Values;
UniversalSmallSet<typename TypeParam::key_type, 10> Keys;
UniversalSmallSet<typename TypeParam::mapped_type, 10> Values;
for (int I = 0; I < 10; ++I) {
auto K = this->getKey(I);
auto V = this->getValue(I);
Expand All @@ -421,8 +428,8 @@ TYPED_TEST(DenseMapTest, ConstKeysValuesIterator) {
}

const TypeParam &ConstMap = this->Map;
SmallSet<typename TypeParam::key_type, 10> ActualKeys;
SmallSet<typename TypeParam::mapped_type, 10> ActualValues;
UniversalSmallSet<typename TypeParam::key_type, 10> ActualKeys;
UniversalSmallSet<typename TypeParam::mapped_type, 10> ActualValues;
for (auto K : ConstMap.keys())
ActualKeys.insert(K);
for (auto V : ConstMap.values())
Expand Down