From 7153448eb8dfe267f96eb55aee683172f15cc283 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 1 Dec 2019 19:53:48 +1100 Subject: Backport: Fix a bug with deleting the first element in SparseVector that left an extra empty partition. Add extra checking to Partitioning and turn on checking for UnitTester. Backport of changeset 7777:12fb0335514e. --- test/unit/UnitTester.vcxproj | 8 ++++---- test/unit/testSparseVector.cxx | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'test/unit') diff --git a/test/unit/UnitTester.vcxproj b/test/unit/UnitTester.vcxproj index 0f62f90a5..c80270618 100644 --- a/test/unit/UnitTester.vcxproj +++ b/test/unit/UnitTester.vcxproj @@ -87,7 +87,7 @@ Level3 Disabled - _CRT_SECURE_NO_WARNINGS=1;_SCL_SECURE_NO_WARNINGS=1;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS=1;_HAS_AUTO_PTR_ETC=1;_SCL_SECURE_NO_WARNINGS=1;CHECK_CORRECTNESS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) ..\..\include\;..\..\src\;..\..\lexlib\ @@ -101,7 +101,7 @@ Level3 Disabled - _CRT_SECURE_NO_WARNINGS=1;_SCL_SECURE_NO_WARNINGS=1;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS=1;_HAS_AUTO_PTR_ETC=1;_SCL_SECURE_NO_WARNINGS=1;CHECK_CORRECTNESS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) ..\..\include\;..\..\src\;..\..\lexlib\ @@ -117,7 +117,7 @@ MaxSpeed true true - _CRT_SECURE_NO_WARNINGS=1;_SCL_SECURE_NO_WARNINGS=1;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS=1;_HAS_AUTO_PTR_ETC=1;_SCL_SECURE_NO_WARNINGS=1;CHECK_CORRECTNESS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) ..\..\include\;..\..\src\;..\..\lexlib\ @@ -135,7 +135,7 @@ MaxSpeed true true - _CRT_SECURE_NO_WARNINGS=1;_SCL_SECURE_NO_WARNINGS=1;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS=1;_HAS_AUTO_PTR_ETC=1;_SCL_SECURE_NO_WARNINGS=1;CHECK_CORRECTNESS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) ..\..\include\;..\..\src\;..\..\lexlib\ diff --git a/test/unit/testSparseVector.cxx b/test/unit/testSparseVector.cxx index ce3b9706b..df7b412ce 100644 --- a/test/unit/testSparseVector.cxx +++ b/test/unit/testSparseVector.cxx @@ -164,6 +164,22 @@ TEST_CASE("SparseVector") { st.Check(); } + SECTION("CheckDeletionLeavesOrdered") { + REQUIRE(1 == st.Elements()); + st.InsertSpace(0, 1); + st.SetValueAt(0, UniqueStringCopy("1")); + REQUIRE("1" == Representation(st)); + REQUIRE(1 == st.Elements()); + st.InsertSpace(1, 1); + st.SetValueAt(1, UniqueStringCopy("2")); + REQUIRE("12" == Representation(st)); + st.DeletePosition(0); + REQUIRE("2" == Representation(st)); + REQUIRE(1 == st.Elements()); + st.DeletePosition(0); + REQUIRE("" == Representation(st)); + } + SECTION("DeleteAll") { REQUIRE(1 == st.Elements()); st.InsertSpace(0, 10); -- cgit v1.2.3