Skip to content

Commit

Permalink
Test copy and copy assignment constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
c-bebop committed Oct 31, 2024
1 parent 0bdabaf commit 7129f11
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/matrix_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,36 @@ TEST_CASE("Matrix") {
CHECK(nv.exists(14));
}

SECTION("NeighborView, copy constructor") {
Matrix<EdgeData> m(std::move(edges));
// N(89) = 13, 31
Matrix<EdgeData>::NeighborView nv = m.neighbors(89);

Matrix<EdgeData>::NeighborView nv_copy{nv};

CHECK(nv_copy.source() == nv.source());
CHECK(nv_copy.degree() == nv.degree());
CHECK(nv_copy.exists(13) == nv.exists(13));
CHECK(nv_copy.exists(31) == nv.exists(31));
CHECK(nv_copy.exists(86) == nv.exists(86));
}

SECTION("NeighborView, copy assignment") {
Matrix<EdgeData> m(std::move(edges));
// N(89) = 13, 31
Matrix<EdgeData>::NeighborView nv = m.neighbors(89);
Matrix<EdgeData>::NeighborView nv_other = m.neighbors(1);
REQUIRE(nv_other.degree() > 1);

nv_other = nv;

CHECK(nv_other.source() == nv.source());
CHECK(nv_other.degree() == nv.degree());
CHECK(nv_other.exists(13) == nv.exists(13));
CHECK(nv_other.exists(31) == nv.exists(31));
CHECK(nv_other.exists(86) == nv.exists(86));
}

SECTION("change target vertex of edge") {
Matrix<EdgeData> m(std::move(edges));
constexpr Vertex source = 89;
Expand Down

0 comments on commit 7129f11

Please sign in to comment.