sparse_map::insert_or_assign and noexcept fixes

This commit is contained in:
2019-04-10 01:37:37 +07:00
parent a4a0ab7560
commit 007f1b228c
2 changed files with 75 additions and 42 deletions

View File

@@ -280,6 +280,25 @@ TEST_CASE("detail") {
REQUIRE(s.unordered_erase(position_c(1,2)));
REQUIRE(s.get(position_c(3,4)).x == 3);
}
{
struct obj_t {
int x;
obj_t(int nx) : x(nx) {}
};
sparse_map<unsigned, obj_t> m;
REQUIRE(m.insert_or_assign(42, obj_t(42)));
REQUIRE(m.has(42));
REQUIRE(m.get(42).x == 42);
REQUIRE_FALSE(m.insert_or_assign(42, obj_t(21)));
REQUIRE(m.has(42));
REQUIRE(m.get(42).x == 21);
REQUIRE(m.size() == 1);
REQUIRE(m.insert_or_assign(84, obj_t(84)));
REQUIRE(m.has(84));
REQUIRE(m.get(84).x == 84);
REQUIRE(m.size() == 2);
}
}
}