From 8ef4f3d54de1328a1d9753f4317a5d7692a72ae8 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 21 May 2017 10:26:10 +1000 Subject: 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. --- test/unit/testContractionState.cxx | 1 + test/unit/testPartitioning.cxx | 1 + test/unit/testRunStyles.cxx | 1 + test/unit/testSparseVector.cxx | 9 +++++---- test/unit/testSplitVector.cxx | 13 +++++++++++-- 5 files changed, 19 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/unit/testContractionState.cxx b/test/unit/testContractionState.cxx index 989aa409d..8b401dcb6 100644 --- a/test/unit/testContractionState.cxx +++ b/test/unit/testContractionState.cxx @@ -3,6 +3,7 @@ #include #include +#include #include #include diff --git a/test/unit/testPartitioning.cxx b/test/unit/testPartitioning.cxx index 008c140d8..925cc9a32 100644 --- a/test/unit/testPartitioning.cxx +++ b/test/unit/testPartitioning.cxx @@ -3,6 +3,7 @@ #include #include +#include #include #include diff --git a/test/unit/testRunStyles.cxx b/test/unit/testRunStyles.cxx index 72840322c..e33cedb2e 100644 --- a/test/unit/testRunStyles.cxx +++ b/test/unit/testRunStyles.cxx @@ -3,6 +3,7 @@ #include #include +#include #include #include diff --git a/test/unit/testSparseVector.cxx b/test/unit/testSparseVector.cxx index ad0110ae0..16498397a 100644 --- a/test/unit/testSparseVector.cxx +++ b/test/unit/testSparseVector.cxx @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -45,9 +46,9 @@ TEST_CASE("SparseVector") { SECTION("InsertSpace") { st.InsertSpace(0, 5); REQUIRE(1 == st.Elements()); - REQUIRE(static_cast(NULL) == st.ValueAt(0)); - REQUIRE(static_cast(NULL) == st.ValueAt(1)); - REQUIRE(static_cast(NULL) == st.ValueAt(4)); + REQUIRE(static_cast(nullptr) == st.ValueAt(0)); + REQUIRE(static_cast(nullptr) == st.ValueAt(1)); + REQUIRE(static_cast(nullptr) == st.ValueAt(4)); st.Check(); } @@ -119,7 +120,7 @@ TEST_CASE("SparseVector") { st.SetValueAt(4, "5"); REQUIRE(2 == st.Elements()); REQUIRE("----5" == Representation(st)); - st.SetValueAt(4, NULL); + st.SetValueAt(4, nullptr); REQUIRE(1 == st.Elements()); REQUIRE("-----" == Representation(st)); st.Check(); 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 #include +#include #include #include @@ -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