mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-13 00:11:56 +00:00
[ADT] Add missing const_iterator DenseSet::find() const
Summary: Probably overlooked. Reviewers: eugenis, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24689 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283377 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e249e2a925
commit
7326421de8
@ -135,6 +135,9 @@ public:
|
||||
const_iterator end() const { return ConstIterator(TheMap.end()); }
|
||||
|
||||
iterator find(const ValueT &V) { return Iterator(TheMap.find(V)); }
|
||||
const_iterator find(const ValueT &V) const {
|
||||
return ConstIterator(TheMap.find(V));
|
||||
}
|
||||
|
||||
/// Alternative version of find() which allows a different, and possibly less
|
||||
/// expensive, key type.
|
||||
|
@ -7,19 +7,16 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "llvm/ADT/DenseSet.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <type_traits>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
// Test fixture
|
||||
class DenseSetTest : public testing::Test {
|
||||
};
|
||||
|
||||
// Test hashing with a set of only two entries.
|
||||
TEST_F(DenseSetTest, DoubleEntrySetTest) {
|
||||
TEST(DenseSetTest, DoubleEntrySetTest) {
|
||||
llvm::DenseSet<unsigned> set(2);
|
||||
set.insert(0);
|
||||
set.insert(1);
|
||||
@ -42,12 +39,29 @@ struct TestDenseSetInfo {
|
||||
}
|
||||
};
|
||||
|
||||
TEST(DenseSetCustomTest, FindAsTest) {
|
||||
DenseSet<unsigned, TestDenseSetInfo> set;
|
||||
set.insert(0);
|
||||
set.insert(1);
|
||||
set.insert(2);
|
||||
// Test fixture
|
||||
template <typename T> class DenseSetTest : public testing::Test {
|
||||
protected:
|
||||
T Set = GetTestSet();
|
||||
|
||||
private:
|
||||
static T GetTestSet() {
|
||||
typename std::remove_const<T>::type Set;
|
||||
Set.insert(0);
|
||||
Set.insert(1);
|
||||
Set.insert(2);
|
||||
return Set;
|
||||
}
|
||||
};
|
||||
|
||||
// Register these types for testing.
|
||||
typedef ::testing::Types<DenseSet<unsigned, TestDenseSetInfo>,
|
||||
const DenseSet<unsigned, TestDenseSetInfo>>
|
||||
DenseSetTestTypes;
|
||||
TYPED_TEST_CASE(DenseSetTest, DenseSetTestTypes);
|
||||
|
||||
TYPED_TEST(DenseSetTest, FindAsTest) {
|
||||
auto &set = this->Set;
|
||||
// Size tests
|
||||
EXPECT_EQ(3u, set.size());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user