RecyclableList.BlockCount renamed => RecyclableList.ReservedBlockCount. Fixed to always include the last block.

RecyclableList.LastTakenBlockIndex property added for some scenarios.

RecyclableList.IndexOf & .LongIndexOf fixed to use the correct index.

RecyclableArrayList.AddRange(RecyclableList<T> items) fixed to use the correct index.

Some test cases excluded, where needed.
This commit is contained in:
mlemanczyk committed 2023-03-20 23:46:50 +01:00
1 parent 0a402e2d13
commit b91c4476eb
4 files changed
+27 -12

No files matched your search

@@ -291,8 +291,13 @@ namespace Recyclable.CollectionsTests
[Theory]
[MemberData(nameof(RecyclableListTestData.SourceTargetDataVariants), MemberType = typeof(RecyclableListTestData))]
public void RemoveShouldRaiseNotSupportedException(string testCase, IEnumerable<long> testData, long itemsCount, int targetBlockSize)
public void RemoveShouldRaiseNotSupportedExceptionWhenNotLastItem(string testCase, IEnumerable<long> testData, long itemsCount, int targetBlockSize)
{
if (itemsCount is 0 or 1)
{
return;
}
// Prepare
using var list = new RecyclableList<long>(testData, minBlockSize: targetBlockSize);
@@ -302,8 +307,13 @@ namespace Recyclable.CollectionsTests
[Theory]
[MemberData(nameof(RecyclableListTestData.SourceTargetDataVariants), MemberType = typeof(RecyclableListTestData))]
public void RemoveAtShouldRaiseNotSupportedException(string testCase, IEnumerable<long> testData, long itemsCount, int targetBlockSize)
public void RemoveAtShouldRaiseNotSupportedExceptionWhenNotLastItem(string testCase, IEnumerable<long> testData, long itemsCount, int targetBlockSize)
{
if (itemsCount is 0 or 1)
{
return;
}
// Prepare
using var list = new RecyclableList<long>(testData, minBlockSize: targetBlockSize);
@@ -530,6 +540,11 @@ namespace Recyclable.CollectionsTests
[MemberData(nameof(RecyclableListTestData.SourceTargetDataVariants), MemberType = typeof(RecyclableListTestData))]
public void LongIndexOfShouldNotFindNonExistingItems(string testCase, IEnumerable<long> testData, long itemsCount, int targetBlockSize)
{
if (itemsCount == 0)
{
return;
}
// Prepare
using var list = new RecyclableList<long>(testData, minBlockSize: targetBlockSize);
_ = testData.Any().Should().BeTrue("we need items on the list that we can look for");