container:
* review dense_hash_map_iterator::operator[] * review dense_hash_set_iterator::operator[] * code coverage
This commit is contained in:
@@ -98,7 +98,7 @@ public:
|
||||
}
|
||||
|
||||
[[nodiscard]] reference operator[](const difference_type value) const {
|
||||
return it->element;
|
||||
return it[value].element;
|
||||
}
|
||||
|
||||
[[nodiscard]] pointer operator->() const {
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
}
|
||||
|
||||
[[nodiscard]] reference operator[](const difference_type value) const {
|
||||
return it->element;
|
||||
return it[value].element;
|
||||
}
|
||||
|
||||
[[nodiscard]] pointer operator->() const {
|
||||
|
||||
@@ -215,6 +215,12 @@ TEST(DenseHashMap, Iterator) {
|
||||
|
||||
ASSERT_GT(end, begin);
|
||||
ASSERT_GE(end, map.end());
|
||||
|
||||
map.emplace(42, 3);
|
||||
begin = map.begin();
|
||||
|
||||
ASSERT_EQ(begin[0u].first, 3);
|
||||
ASSERT_EQ(begin[1u].second, 3);
|
||||
}
|
||||
|
||||
TEST(DenseHashMap, ConstIterator) {
|
||||
@@ -262,6 +268,12 @@ TEST(DenseHashMap, ConstIterator) {
|
||||
|
||||
ASSERT_GT(cend, cbegin);
|
||||
ASSERT_GE(cend, map.cend());
|
||||
|
||||
map.emplace(42, 3);
|
||||
cbegin = map.cbegin();
|
||||
|
||||
ASSERT_EQ(cbegin[0u].first, 3);
|
||||
ASSERT_EQ(cbegin[1u].second, 3);
|
||||
}
|
||||
|
||||
TEST(DenseHashMap, IteratorConversion) {
|
||||
|
||||
@@ -207,6 +207,12 @@ TEST(DenseHashSet, Iterator) {
|
||||
|
||||
ASSERT_GT(end, begin);
|
||||
ASSERT_GE(end, set.end());
|
||||
|
||||
set.emplace(42);
|
||||
begin = set.begin();
|
||||
|
||||
ASSERT_EQ(begin[0u], 3);
|
||||
ASSERT_EQ(begin[1u], 42);
|
||||
}
|
||||
|
||||
TEST(DenseHashSet, ConstIterator) {
|
||||
@@ -254,6 +260,12 @@ TEST(DenseHashSet, ConstIterator) {
|
||||
|
||||
ASSERT_GT(cend, cbegin);
|
||||
ASSERT_GE(cend, set.cend());
|
||||
|
||||
set.emplace(42);
|
||||
cbegin = set.cbegin();
|
||||
|
||||
ASSERT_EQ(cbegin[0u], 3);
|
||||
ASSERT_EQ(cbegin[1u], 42);
|
||||
}
|
||||
|
||||
TEST(DenseHashSet, IteratorConversion) {
|
||||
|
||||
Reference in New Issue
Block a user