23 namespace container_internal {
27 using ::testing::Pointee;
28 using ::testing::UnorderedElementsAre;
30 using SetTypes = ::testing::Types<
31 node_hash_set<int, StatefulTestingHash, StatefulTestingEqual, Alloc<int>>,
32 node_hash_set<std::string, StatefulTestingHash, StatefulTestingEqual,
34 node_hash_set<Enum, StatefulTestingHash, StatefulTestingEqual, Alloc<Enum>>,
35 node_hash_set<
EnumClass, StatefulTestingHash, StatefulTestingEqual,
38 INSTANTIATE_TYPED_TEST_SUITE_P(NodeHashSet, ConstructorTest, SetTypes);
39 INSTANTIATE_TYPED_TEST_SUITE_P(NodeHashSet, LookupTest, SetTypes);
40 INSTANTIATE_TYPED_TEST_SUITE_P(NodeHashSet, MembersTest, SetTypes);
41 INSTANTIATE_TYPED_TEST_SUITE_P(NodeHashSet, ModifiersTest, SetTypes);
43 TEST(NodeHashSet, MoveableNotCopyableCompiles) {
44 node_hash_set<std::unique_ptr<void*>> t;
45 node_hash_set<std::unique_ptr<void*>> u;
49 TEST(NodeHashSet, MergeExtractInsert) {
51 size_t operator()(
const std::unique_ptr<int>& p)
const {
return *p; }
54 bool operator()(
const std::unique_ptr<int>&
a,
55 const std::unique_ptr<int>&
b)
const {
60 set1.
insert(absl::make_unique<int>(7));
61 set1.
insert(absl::make_unique<int>(17));
63 set2.
insert(absl::make_unique<int>(7));
64 set2.
insert(absl::make_unique<int>(19));
66 EXPECT_THAT(set1, UnorderedElementsAre(Pointee(7), Pointee(17)));
67 EXPECT_THAT(set2, UnorderedElementsAre(Pointee(7), Pointee(19)));
71 EXPECT_THAT(set1, UnorderedElementsAre(Pointee(7), Pointee(17), Pointee(19)));
72 EXPECT_THAT(set2, UnorderedElementsAre(Pointee(7)));
74 auto node = set1.
extract(absl::make_unique<int>(7));
76 EXPECT_THAT(node.value(), Pointee(7));
77 EXPECT_THAT(set1, UnorderedElementsAre(Pointee(17), Pointee(19)));
81 EXPECT_FALSE(insert_result.inserted);
82 EXPECT_TRUE(insert_result.node);
83 EXPECT_THAT(insert_result.node.value(), Pointee(7));
84 EXPECT_EQ(**insert_result.position, 7);
85 EXPECT_NE(insert_result.position->get(), insert_result.node.value().get());
86 EXPECT_THAT(set2, UnorderedElementsAre(Pointee(7)));
88 node = set1.
extract(absl::make_unique<int>(17));
90 EXPECT_THAT(node.value(), Pointee(17));
91 EXPECT_THAT(set1, UnorderedElementsAre(Pointee(19)));
93 node.value() = absl::make_unique<int>(23);
97 EXPECT_TRUE(insert_result.inserted);
98 EXPECT_FALSE(insert_result.node);
99 EXPECT_EQ(**insert_result.position, 23);
100 EXPECT_THAT(set2, UnorderedElementsAre(Pointee(7), Pointee(23)));
TEST(NotificationTest, SanityTest)
node_type extract(const_iterator position)
void merge(raw_hash_set< absl::container_internal::NodeHashSetPolicy< T >, H, E, Alloc > &src)
std::pair< iterator, bool > insert(T &&value)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
absl::hash_internal::Hash< T > Hash