aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/unit/testSparseVector.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2022-07-20 11:19:40 +1000
committerNeil <nyamatongwe@gmail.com>2022-07-20 11:19:40 +1000
commite12f8f179666ed70d03c99039565ba63c45f7c7a (patch)
tree8a3fe00257883c12710d6ab63e6fcc3797167d80 /test/unit/testSparseVector.cxx
parent5d0ebf7f0e4a815121d5a10f2134a5bec52d7ba0 (diff)
downloadscintilla-mirror-e12f8f179666ed70d03c99039565ba63c45f7c7a.tar.gz
Implement PositionNext to iterate. Simpler than IndexAfter for client code which
is not interested in SparseVector indices.
Diffstat (limited to 'test/unit/testSparseVector.cxx')
-rw-r--r--test/unit/testSparseVector.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/unit/testSparseVector.cxx b/test/unit/testSparseVector.cxx
index 5b50d24e4..763fa027c 100644
--- a/test/unit/testSparseVector.cxx
+++ b/test/unit/testSparseVector.cxx
@@ -383,6 +383,20 @@ TEST_CASE("SparseTextInt") {
REQUIRE(5 == st.PositionOfElement(2));
REQUIRE(2 == st.IndexAfter(4));
}
+
+ SECTION("PositionNext") {
+ st.InsertSpace(0, 5);
+ REQUIRE(1 == st.Elements());
+ REQUIRE(5 == st.PositionNext(-1));
+ REQUIRE(5 == st.PositionNext(0));
+ REQUIRE(6 == st.PositionNext(5));
+ st.SetValueAt(3, 3);
+ REQUIRE(2 == st.Elements());
+ REQUIRE(3 == st.PositionNext(-1));
+ REQUIRE(3 == st.PositionNext(0));
+ REQUIRE(5 == st.PositionNext(3));
+ REQUIRE(6 == st.PositionNext(5));
+ }
}
TEST_CASE("SparseTextString") {