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
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