RecyclableArrayList.AddRange added. Smaller perf improvements.
This commit is contained in:
1 parent
880abd605e
commit
012fc3b21f
8 files changed
+134
-25
No files matched your search
@@ -6,7 +6,7 @@ namespace Recyclable.CollectionsTests
|
||||
public class RecyclableArrayListTests
|
||||
{
|
||||
private readonly static IEnumerable<int> _testData = Enumerable.Range(1, 20);
|
||||
|
||||
|
||||
[Fact]
|
||||
public void AddCountShouldSucceed()
|
||||
{
|
||||
@@ -28,6 +28,40 @@ namespace Recyclable.CollectionsTests
|
||||
.And.BeEquivalentTo(testData);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddRangeShouldAddItemsInCorrectOrderWhenSourceIsArray()
|
||||
{
|
||||
// Prepare
|
||||
var testData = _testData.ToArray();
|
||||
var list = new RecyclableArrayList<int>();
|
||||
|
||||
// Act
|
||||
list.AddRange(testData);
|
||||
|
||||
// Validate
|
||||
_ = list.Capacity.Should().Be(20, "when capacity == 0, then we allocate as much memory as needed, only");
|
||||
_ = list.Should().HaveCount(testData.Length)
|
||||
.And.ContainInConsecutiveOrder(testData)
|
||||
.And.BeEquivalentTo(testData);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddRangeShouldAddItemsInCorrectOrderWhenSourceIsList()
|
||||
{
|
||||
// Prepare
|
||||
var testData = _testData.ToList();
|
||||
var list = new RecyclableArrayList<int>();
|
||||
|
||||
// Act
|
||||
list.AddRange(testData);
|
||||
|
||||
// Validate
|
||||
_ = list.Capacity.Should().Be(20, "when capacity == 0, then we allocate as much memory as needed, only");
|
||||
_ = list.Should().HaveCount(testData.Count)
|
||||
.And.ContainInConsecutiveOrder(testData)
|
||||
.And.BeEquivalentTo(testData);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InsertAtTheBeginningShouldMoveItems()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user