+TEST(ConcurrentHashMap, MapMovableKeysTest) {
+ struct Movable {
+ int i_;
+ Movable(int i) {
+ i_ = i;
+ }
+ Movable(const Movable&) = delete;
+ Movable(Movable&& o) {
+ i_ = o.i_;
+ o.i_ = 0;
+ }
+ bool operator==(const Movable& o) const {
+ return i_ == o.i_;
+ }
+ };
+ struct Hasher {
+ size_t operator()(const Movable&) const {
+ return 0;
+ }
+ };
+ ConcurrentHashMap<Movable, Movable, Hasher> foomap(2);
+ EXPECT_TRUE(foomap.insert(std::make_pair(Movable(10), Movable(1))).second);
+ EXPECT_TRUE(foomap.assign(Movable(10), Movable(2)));
+ EXPECT_TRUE(foomap.insert(Movable(11), Movable(1)).second);
+ EXPECT_TRUE(foomap.emplace(Movable(12), Movable(1)).second);
+ EXPECT_TRUE(foomap.insert_or_assign(Movable(10), Movable(3)).second);
+ EXPECT_TRUE(foomap.assign_if_equal(Movable(10), Movable(3), Movable(4)));
+ EXPECT_FALSE(foomap.try_emplace(Movable(10), Movable(3)).second);
+ EXPECT_TRUE(foomap.try_emplace(Movable(13), Movable(3)).second);
+}
+