mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:59:56 +00:00
[llvm] Add contains(KeyType) -> bool methods to StringSet
Matches C++20 API addition. Differential Revision: https://reviews.llvm.org/D83449
This commit is contained in:
parent
479337797c
commit
8ab112dbf4
@ -45,6 +45,9 @@ public:
|
||||
insert(const StringMapEntry<ValueTy> &mapEntry) {
|
||||
return insert(mapEntry.getKey());
|
||||
}
|
||||
|
||||
/// Check if the set contains the given \c key.
|
||||
bool contains(StringRef key) const { return Base::FindKey(key) != -1; }
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
@ -53,4 +53,23 @@ TEST_F(StringSetTest, EmptyString) {
|
||||
EXPECT_EQ(Count, 1UL);
|
||||
}
|
||||
|
||||
TEST_F(StringSetTest, Contains) {
|
||||
StringSet<> Set;
|
||||
EXPECT_FALSE(Set.contains(""));
|
||||
EXPECT_FALSE(Set.contains("test"));
|
||||
|
||||
Set.insert("");
|
||||
Set.insert("test");
|
||||
EXPECT_TRUE(Set.contains(""));
|
||||
EXPECT_TRUE(Set.contains("test"));
|
||||
|
||||
Set.insert("test");
|
||||
EXPECT_TRUE(Set.contains(""));
|
||||
EXPECT_TRUE(Set.contains("test"));
|
||||
|
||||
Set.erase("test");
|
||||
EXPECT_TRUE(Set.contains(""));
|
||||
EXPECT_FALSE(Set.contains("test"));
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
Loading…
Reference in New Issue
Block a user