Skip to content

Commit 804e65a

Browse files
more tests
1 parent f46d4a0 commit 804e65a

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

include/osp/graph_implementations/eigen_matrix_adapter/eigen_sparse_iterator.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class EigenCSRRange {
7373
}
7474

7575
bool operator==(const Iterator &other) const {return it_ == other.it_;}
76-
bool operator!=(const Iterator &other) const { return it_ != other.it_;}
76+
bool operator!=(const Iterator &other) const { return not (*this == other);}
7777
};
7878

7979
EigenCSRRange(const Graph &graph, EigenIdxType idx) : graph_(graph), index_(idx) {}
@@ -133,7 +133,7 @@ class EigenCSCRange {
133133
}
134134

135135
bool operator==(const Iterator &other) const {return it_ == other.it_;}
136-
bool operator!=(const Iterator &other) const { return it_ != other.it_;}
136+
bool operator!=(const Iterator &other) const { return not (*this == other);}
137137
};
138138

139139
EigenCSCRange(const Graph &graph, EigenIdxType idx) : graph_(graph), index_(idx) {}

tests/sparse_matrix_impl.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,22 @@ BOOST_AUTO_TEST_CASE(TestSparseMatrixAdapter2) {
248248
auto chldren = graph.Children(vert);
249249
auto chldren2 = graph2.Children(vert);
250250
auto it = chldren.begin();
251+
auto it_other = chldren.begin();
252+
const auto begin = chldren.begin();
251253
auto it2 = chldren2.begin();
252254
auto end = chldren.end();
253255
auto end2 = chldren2.end();
254256

255257
std::size_t cntr = 0;
256258
while ((it != end) && (it2 != end2)) {
257259
BOOST_CHECK_EQUAL(*it, *it2);
260+
BOOST_CHECK(it == it_other);
261+
BOOST_CHECK(cntr == 0U || it != begin);
262+
BOOST_CHECK(cntr == 0U || (not (it == begin)));
258263

259264
++cntr;
260265
++it;
266+
++it_other;
261267
++it2;
262268
}
263269
BOOST_CHECK_EQUAL(cntr, graph.OutDegree(vert));
@@ -271,13 +277,17 @@ BOOST_AUTO_TEST_CASE(TestSparseMatrixAdapter2) {
271277
auto parents = graph.Parents(vert);
272278
auto parents2 = graph2.Parents(vert);
273279
auto it = parents.begin();
280+
auto it_other = parents.begin();
281+
const auto begin = parents.begin();
274282
auto it2 = parents2.begin();
275283
auto end = parents.end();
276284
auto end2 = parents2.end();
277285

278286
std::size_t cntr = 0;
279287
while ((it != end) && (it2 != end2)) {
280288
BOOST_CHECK_EQUAL(*it, *it2);
289+
BOOST_CHECK(cntr == 0U || it != begin);
290+
BOOST_CHECK(cntr == 0U || (not (it == begin)));
281291

282292
++cntr;
283293
++it;

0 commit comments

Comments
 (0)