diff options
-rw-r--r-- | src/SparseVector.h | 2 | ||||
-rw-r--r-- | test/unit/testSparseVector.cxx | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/SparseVector.h b/src/SparseVector.h index 31636165a..31815c789 100644 --- a/src/SparseVector.h +++ b/src/SparseVector.h @@ -77,7 +77,7 @@ public: const Sci::Position startPartition = starts->PositionFromPartition(partition); if (value == T()) { // Setting the empty value is equivalent to deleting the position - if (position == 0) { + if (position == 0 || position == Length()) { ClearValue(partition); } else if (position == startPartition) { // Currently an element at this position, so remove diff --git a/test/unit/testSparseVector.cxx b/test/unit/testSparseVector.cxx index 0bc8f9093..5756b8de0 100644 --- a/test/unit/testSparseVector.cxx +++ b/test/unit/testSparseVector.cxx @@ -179,6 +179,10 @@ TEST_CASE("SparseVector") { REQUIRE(1 == st.Elements()); REQUIRE("------" == Representation(st)); st.Check(); + st.SetValueAt(5, nullptr); + REQUIRE(1 == st.Elements()); + REQUIRE("------" == Representation(st)); + st.Check(); } SECTION("CheckDeletionLeavesOrdered") { |