// The `bottom` element is the empty map.
static MapLattice bottom() { return MapLattice(); }
- void insert(const std::pair<const key_type, mapped_type> &P) { C.insert(P); }
+ std::pair<iterator, bool>
+ insert(const std::pair<const key_type, mapped_type> &P) {
+ return C.insert(P);
+ }
- void insert(std::pair<const key_type, mapped_type> &&P) {
- C.insert(std::move(P));
+ std::pair<iterator, bool> insert(std::pair<const key_type, mapped_type> &&P) {
+ return C.insert(std::move(P));
}
unsigned size() const { return C.size(); }
static constexpr int Key2 = 1;
namespace {
+using ::testing::_;
using ::testing::Pair;
using ::testing::UnorderedElementsAre;
TEST(MapLatticeTest, InsertWorks) {
MapLattice<int, BooleanLattice> Lattice;
- Lattice.insert({Key1, BooleanLattice(false)});
- Lattice.insert({Key2, BooleanLattice(false)});
+ EXPECT_THAT(Lattice.insert({Key1, BooleanLattice(false)}), Pair(_, true));
+ EXPECT_THAT(Lattice.insert({Key2, BooleanLattice(false)}), Pair(_, true));
+
+ // Insertion fails on collision.
+ EXPECT_THAT(Lattice.insert({Key1, BooleanLattice(false)}), Pair(_, false));
+ EXPECT_THAT(Lattice.insert({Key2, BooleanLattice(false)}), Pair(_, false));
EXPECT_THAT(Lattice, UnorderedElementsAre(Pair(Key1, BooleanLattice(false)),
Pair(Key2, BooleanLattice(false))));