| 123456789101112131415161718192021222324 |
- #include "iterator/indexed_iterator.hpp"
- #include <vector>
- #include <gmock/gmock.h>
- using idx_iterator =
- iterator::indexed_iterator<std::vector<int>::const_iterator>;
- TEST(IndexedIteratorTest, TreatsVectorIteratorAsMapIdxToValue) {
- std::vector<int> const vec{5, 3, 2, 8, 9, 11, 2, 4};
- idx_iterator it{vec.begin()}, end{vec.end()};
- for (; it != end; ++it) {
- EXPECT_THAT((*it).second, vec[(*it).first]);
- }
- }
- TEST(IndexedIteratorTest, ContainsReferencesToContainersElements) {
- std::vector<int> const vec{5, 3, 2, 8, 9, 11, 2, 4};
- idx_iterator it{vec.begin()}, end{vec.end()};
- for (; it != end; ++it) {
- EXPECT_THAT(&(*it).second, &vec[(*it).first]);
- }
- }
|