28 namespace container_internal {
33 using ::testing::Pointee;
34 using ::testing::UnorderedElementsAre;
35 using ::testing::UnorderedElementsAreArray;
42 ::testing::Types<Set<int>, Set<std::string>, Set<Enum>, Set<EnumClass>>;
44 INSTANTIATE_TYPED_TEST_SUITE_P(FlatHashSet, ConstructorTest, SetTypes);
45 INSTANTIATE_TYPED_TEST_SUITE_P(FlatHashSet, LookupTest, SetTypes);
46 INSTANTIATE_TYPED_TEST_SUITE_P(FlatHashSet, MembersTest, SetTypes);
47 INSTANTIATE_TYPED_TEST_SUITE_P(FlatHashSet, ModifiersTest, SetTypes);
49 TEST(FlatHashSet, EmplaceString) {
50 std::vector<std::string>
v = {
"a",
"b"};
52 EXPECT_THAT(hs, UnorderedElementsAreArray(v));
55 TEST(FlatHashSet, BitfieldArgument) {
72 TEST(FlatHashSet, MergeExtractInsert) {
74 size_t operator()(
const std::unique_ptr<int>& p)
const {
return *p; }
77 bool operator()(
const std::unique_ptr<int>&
a,
78 const std::unique_ptr<int>&
b)
const {
83 set1.
insert(absl::make_unique<int>(7));
84 set1.
insert(absl::make_unique<int>(17));
86 set2.
insert(absl::make_unique<int>(7));
87 set2.
insert(absl::make_unique<int>(19));
89 EXPECT_THAT(set1, UnorderedElementsAre(Pointee(7), Pointee(17)));
90 EXPECT_THAT(set2, UnorderedElementsAre(Pointee(7), Pointee(19)));
94 EXPECT_THAT(set1, UnorderedElementsAre(Pointee(7), Pointee(17), Pointee(19)));
95 EXPECT_THAT(set2, UnorderedElementsAre(Pointee(7)));
97 auto node = set1.
extract(absl::make_unique<int>(7));
99 EXPECT_THAT(node.value(), Pointee(7));
100 EXPECT_THAT(set1, UnorderedElementsAre(Pointee(17), Pointee(19)));
104 EXPECT_FALSE(insert_result.inserted);
105 EXPECT_TRUE(insert_result.node);
106 EXPECT_THAT(insert_result.node.value(), Pointee(7));
107 EXPECT_EQ(**insert_result.position, 7);
108 EXPECT_NE(insert_result.position->get(), insert_result.node.value().get());
109 EXPECT_THAT(set2, UnorderedElementsAre(Pointee(7)));
111 node = set1.
extract(absl::make_unique<int>(17));
113 EXPECT_THAT(node.value(), Pointee(17));
114 EXPECT_THAT(set1, UnorderedElementsAre(Pointee(19)));
116 node.value() = absl::make_unique<int>(23);
120 EXPECT_TRUE(insert_result.inserted);
121 EXPECT_FALSE(insert_result.node);
122 EXPECT_EQ(**insert_result.position, 23);
123 EXPECT_THAT(set2, UnorderedElementsAre(Pointee(7), Pointee(23)));
size_t count(const key_arg< K > &key) const
TEST(NotificationTest, SanityTest)
void prefetch(const key_arg< K > &key) const
node_type extract(const_iterator position)
bool contains(const key_arg< K > &key) const
void merge(raw_hash_set< absl::container_internal::FlatHashSetPolicy< T >, H, E, Allocator > &src)
size_type erase(const key_arg< K > &key)
std::pair< iterator, bool > insert(T &&value)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
iterator find(const key_arg< K > &key, size_t hash)
std::pair< iterator, iterator > equal_range(const key_arg< K > &key)
absl::hash_internal::Hash< T > Hash