42#include <gtest/gtest.h>
59 EXPECT_EQ(bimap.
left_at(1),
"one");
60 EXPECT_EQ(bimap.
left_at(2),
"two");
61 EXPECT_EQ(bimap.
left_at(3),
"three");
65 EXPECT_EQ(bimap.
right_at(
"three"), 3);
74 EXPECT_NE(it, bimap.
left.
end());
75 EXPECT_EQ(it->second,
"one");
78 EXPECT_EQ(it, bimap.
left.
end());
88 EXPECT_EQ(it->second, 1);
98 EXPECT_THROW(bimap.
left_at(2), std::out_of_range);
99 EXPECT_THROW(bimap.
right_at(
"two"), std::out_of_range);
103 auto bimap = make_bimap<int, std::string>({{1,
"one"}, {2,
"two"}, {3,
"three"}});
105 EXPECT_EQ(bimap.left_at(1),
"one");
106 EXPECT_EQ(bimap.left_at(2),
"two");
107 EXPECT_EQ(bimap.left_at(3),
"three");
109 EXPECT_EQ(bimap.right_at(
"one"), 1);
110 EXPECT_EQ(bimap.right_at(
"two"), 2);
111 EXPECT_EQ(bimap.right_at(
"three"), 3);
120 EXPECT_NE(left_it, bimap.
left_end());
121 EXPECT_EQ(left_it->second,
"one");
125 EXPECT_EQ(right_it->second, 2);
128 EXPECT_EQ(left_it, bimap.
left_end());
136 bimap.
insert(
"key1",
"value1");
137 bimap.
insert(
"key2",
"value2");
139 EXPECT_EQ(bimap.
left_at(
"key1"),
"value1");
140 EXPECT_EQ(bimap.
right_at(
"value2"),
"key2");
TEST_F(BiMapTest, BasicInsertion)
Simple bidirectional map with lookup in both directions.
void insert(const Left &left, const Right &right)
Insert or overwrite a left/right association.
right_map::iterator right_find(const Right &key)
Find an entry by right key.
right_view right
Right view accessor.
const Left & right_at(const Right &key) const
Get mapped left value by right key (throws if missing).
left_view left
Left view accessor.
const Right & left_at(const Left &key) const
Get mapped right value by left key (throws if missing).
right_map::iterator right_end()
End iterator for right map.
left_map::iterator left_find(const Left &key)
Find an entry by left key.
left_map::iterator left_end()
End iterator for left map.
left_map::iterator end() const
End iterator for the left map.
left_map::iterator find(const Left &key) const
Find iterator for key in the left map.
right_map::iterator find(const Right &key) const
Find iterator for key in the right map.
right_map::iterator end() const
End iterator for the right map.