aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/unit/testSplitVector.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2017-05-21 10:26:10 +1000
committerNeil <nyamatongwe@gmail.com>2017-05-21 10:26:10 +1000
commit8ef4f3d54de1328a1d9753f4317a5d7692a72ae8 (patch)
treed0fb1e0c6cbd0a0256066ccb9e1541d3adbdf41c /test/unit/testSplitVector.cxx
parent632801dae9d844bd73891a314e99161add3f47fc (diff)
downloadscintilla-mirror-8ef4f3d54de1328a1d9753f4317a5d7692a72ae8.tar.gz
Make SplitVector work with move-only types like unique_ptr.
Provide InsertEmpty and both const and non-const reference returning operator[]. Add and fix comments.
Diffstat (limited to 'test/unit/testSplitVector.cxx')
-rw-r--r--test/unit/testSplitVector.cxx13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/unit/testSplitVector.cxx b/test/unit/testSplitVector.cxx
index 3af51c45e..e01810d33 100644
--- a/test/unit/testSplitVector.cxx
+++ b/test/unit/testSplitVector.cxx
@@ -3,6 +3,7 @@
#include <cstring>
#include <stdexcept>
+#include <vector>
#include <algorithm>
#include <memory>
@@ -280,11 +281,19 @@ TEST_CASE("SplitVector") {
}
SECTION("BufferPointer") {
+ // Low-level access to the data
sv.InsertFromArray(0, testArray, 0, lengthTestArray);
+ sv.Insert(0, 99); // This moves the gap so that BufferPointer() must also move
+ REQUIRE(1 == sv.GapPosition());
+ const int lengthAfterInsertion = 1 + lengthTestArray;
+ REQUIRE(lengthAfterInsertion == (sv.Length()));
int *retrievePointer = sv.BufferPointer();
- for (int i=0; i<sv.Length(); i++) {
- REQUIRE((i+3) == retrievePointer[i]);
+ for (int i=1; i<sv.Length(); i++) {
+ REQUIRE((i+3-1) == retrievePointer[i]);
}
+ REQUIRE(lengthAfterInsertion == sv.Length());
+ // Gap was moved to end.
+ REQUIRE(lengthAfterInsertion == sv.GapPosition());
}
SECTION("DeleteBackAndForth") {