RecyclableList modified to respect the removal of blocks.

RecyclableList.IndexOf fixed to work in various combinations.

RecyclableList tests extended.
This commit is contained in:
mlemanczyk committed 2023-03-20 20:29:50 +01:00
1 parent 070549de9e
commit b21b80e222
2 files changed
+51 -21

No files matched your search

@@ -77,8 +77,13 @@ namespace Recyclable.CollectionsTests
[Theory]
[MemberData(nameof(RecyclableListTestData.SourceTargetDataVariants), MemberType = typeof(RecyclableListTestData))]
public void InitializeSortClearShouldSucceed(string testCase, IEnumerable<long> testData, long itemsCount, int targetBlockSize)
public void InitializeSortClearAddRangeRemoveShouldSucceed(string testCase, IEnumerable<long> testData, long itemsCount, int targetBlockSize)
{
if (itemsCount == 0)
{
return;
}
// Act
using RecyclableList<long> list = new(testData, minBlockSize: targetBlockSize);
list.QuickSort();
@@ -86,13 +91,26 @@ namespace Recyclable.CollectionsTests
// Validate
_ = list.LongCount.Should().Be(itemsCount);
_ = list.Should().Equal(testData);
_ = testData.Should().AllSatisfy(expected => list.Contains(expected));
// Act
list.Clear();
// Validate
_ = list.LongCount.Should().Be(0);
_ = list.Should().BeEmpty();
// Act
list.AddRange(testData);
// Validate
_ = list.LongCount.Should().Be(itemsCount);
_ = list.Should().ContainInConsecutiveOrder(testData);
// Act
foreach (var item in testData.Reverse())
{
_ = list.Remove(item).Should().BeTrue();
}
}
[Theory]