RecyclableList.Contains reworked for performance improvements. 69% vs List.Contains
This commit is contained in:
1 parent
91abf1a614
commit
10ae744875
4 files changed
+245
-59
No files matched your search
@@ -85,6 +85,53 @@ namespace Recyclable.CollectionsTests
|
||||
_ = list.LongCount.Should().Be(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ContainsShouldFindAllItems()
|
||||
{
|
||||
// Prepare
|
||||
var testData = _testData;
|
||||
using var list = NewRecyclableList;
|
||||
_ = testData.Any().Should().BeTrue("we need items on the list that we can look for");
|
||||
|
||||
// Act
|
||||
foreach (var item in testData)
|
||||
{
|
||||
// Validate
|
||||
_ = list.Contains(item).Should().BeTrue();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ContainsShouldNotFindNonExistingItems()
|
||||
{
|
||||
// Prepare
|
||||
var testData = _testData;
|
||||
using var list = NewRecyclableList;
|
||||
_ = testData.Any().Should().BeTrue("we need items on the list that we can look for");
|
||||
|
||||
// Act
|
||||
foreach (var item in testData)
|
||||
{
|
||||
// Validate
|
||||
_ = list.Contains(-item).Should().BeFalse();
|
||||
}
|
||||
|
||||
// Validate
|
||||
_ = list.Contains(0).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ContainsShouldNotFindAnythingWhenListEmpty()
|
||||
{
|
||||
// Prepare
|
||||
using var list = new RecyclableList<int>();
|
||||
|
||||
// Validate
|
||||
_ = list.Contains(0).Should().BeFalse();
|
||||
_ = list.Contains(1).Should().BeFalse();
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void CopyToShouldCopyAllItems()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user