// Unit Tests for Scintilla internal data structures #include #include #include "Platform.h" #include "SplitVector.h" #include "Partitioning.h" #include "catch.hpp" const int growSize = 4; const int lengthTestArray = 8; static const int testArray[lengthTestArray] = {3, 4, 5, 6, 7, 8, 9, 10}; // Test SplitVectorWithRangeAdd. TEST_CASE("SplitVectorWithRangeAdd") { SplitVectorWithRangeAdd svwra(growSize); SECTION("IsEmptyInitially") { REQUIRE(0 == svwra.Length()); } SECTION("IncrementExceptEnds") { svwra.InsertFromArray(0, testArray, 0, lengthTestArray); svwra.RangeAddDelta(1, lengthTestArray-1, 1); for (int i=0; i0; i--) { part.InsertText(i,2); } REQUIRE(21 == part.Partitions()); for (int i=1; i<20; i++) { REQUIRE((i*4 - 2) == part.PositionFromPartition(i)); REQUIRE(i == part.PartitionFromPosition(i*4 - 2)); } part.InsertText(19,2); REQUIRE(3 == part.PartitionFromPosition(10)); part.InsertText(0,2); part.InsertText(0,-2); part.RemovePartition(1); REQUIRE(0 == part.PositionFromPartition(0)); REQUIRE(6 == part.PositionFromPartition(1)); REQUIRE(10 == part.PositionFromPartition(2)); part.RemovePartition(10); REQUIRE(46 == part.PositionFromPartition(10)); REQUIRE(10 == part.PartitionFromPosition(46)); REQUIRE(50 == part.PositionFromPartition(11)); REQUIRE(11 == part.PartitionFromPosition(50)); } }