Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dsm/dsm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

static constexpr uint8_t DSM_VERSION_MAJOR = 2;
static constexpr uint8_t DSM_VERSION_MINOR = 3;
static constexpr uint8_t DSM_VERSION_PATCH = 22;
static constexpr uint8_t DSM_VERSION_PATCH = 23;

static auto const DSM_VERSION =
std::format("{}.{}.{}", DSM_VERSION_MAJOR, DSM_VERSION_MINOR, DSM_VERSION_PATCH);
Expand Down
6 changes: 4 additions & 2 deletions src/dsm/sources/AdjacencyMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@

void AdjacencyMatrix::insert(Id row, Id col) {
if (row > m_rowOffsets.size() - 2) {
for (auto i = 0ul; i < row - m_rowOffsets.size() + 2; ++i) {
m_rowOffsets.push_back(m_rowOffsets.back() + 1);
auto n = row - m_rowOffsets.size() + 2;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 10.4 rule Note

MISRA 10.4 rule
for (auto i = 0ul; i < n - 1; ++i) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 7.3 rule Note

MISRA 7.3 rule

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.1 rule Note

MISRA 12.1 rule

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 10.4 rule Note

MISRA 10.4 rule
m_rowOffsets.push_back(m_rowOffsets.back());
}
m_rowOffsets.push_back(m_rowOffsets.back() + 1);
m_nRows = row + 1;
} else {
std::for_each(
Expand Down
39 changes: 39 additions & 0 deletions test/Test_AdjacencyMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,42 @@ TEST_CASE("Test construction from edge map") {
CHECK_EQ(adj, adj2);
}
}

TEST_CASE("Test insertion of random values") {
AdjacencyMatrix adj;
adj.insert(4, 2);
auto offsets = test::offsets(adj);
auto indices = test::indices(adj);
CHECK_EQ(offsets.size(), 6);
std::for_each(
offsets.begin(), offsets.begin() + 5, [](auto value) { CHECK(value == 0); });
CHECK_EQ(offsets[5], 1);
CHECK_EQ(indices.size(), 1);
CHECK_EQ(indices[0], 2);

adj.insert(63, 268);
offsets = test::offsets(adj);
indices = test::indices(adj);
CHECK(offsets.size() == 65);
std::for_each(
offsets.begin() + 5, offsets.begin() + 63, [](auto value) { CHECK(value == 1); });
CHECK_EQ(offsets[64], 2);
CHECK_EQ(indices.size(), 2);
CHECK_EQ(indices[1], 268);

adj.insert(2, 3);
offsets = test::offsets(adj);
indices = test::indices(adj);
CHECK_EQ(offsets.size(), 65);
CHECK_EQ(offsets[0], 0);
CHECK_EQ(offsets[2], 0);
CHECK_EQ(offsets[3], 1);
CHECK_EQ(offsets[4], 1);
CHECK_EQ(offsets[5], 2);
CHECK_EQ(offsets[63], 2);
CHECK_EQ(offsets[64], 3);
CHECK_EQ(indices.size(), 3);
CHECK_EQ(indices[0], 3);
CHECK_EQ(indices[1], 2);
CHECK_EQ(indices[2], 268);
}
Loading