From c0c411daf8adbbeeb3a92a57d6e1538e58a49587 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 2 May 2020 09:01:54 +1000 Subject: Backport: InsertEmpty now returns a pointer to the newly added elements to allow caller to efficiently set those elements. Backport of changeset 8225:de663ebc1bc6. --- test/unit/testSplitVector.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/unit/testSplitVector.cxx') diff --git a/test/unit/testSplitVector.cxx b/test/unit/testSplitVector.cxx index 2d9d3607f..2a47c1ae5 100644 --- a/test/unit/testSplitVector.cxx +++ b/test/unit/testSplitVector.cxx @@ -167,6 +167,27 @@ TEST_CASE("SplitVector") { } } + SECTION("InsertEmpty") { + sv.InsertEmpty(0, 0); + REQUIRE(0 == sv.Length()); + int *pi = sv.InsertEmpty(0, 2); + REQUIRE(2 == sv.Length()); + REQUIRE(0 == sv.ValueAt(0)); + REQUIRE(0 == sv.ValueAt(1)); + pi[0] = 4; + pi[1] = 5; + REQUIRE(4 == sv.ValueAt(0)); + REQUIRE(5 == sv.ValueAt(1)); + pi = sv.InsertEmpty(1, 2); + pi[0] = 6; + pi[1] = 7; + REQUIRE(4 == sv.Length()); + REQUIRE(4 == sv.ValueAt(0)); + REQUIRE(6 == sv.ValueAt(1)); + REQUIRE(7 == sv.ValueAt(2)); + REQUIRE(5 == sv.ValueAt(3)); + } + SECTION("SetValue") { sv.InsertValue(0, 10, 0); sv.SetValueAt(5, 3); -- cgit v1.2.3