Skip to content

Commit

Permalink
Add test to ensure "Batch" doesn't reuse internal array (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
leandromoh authored Jun 16, 2021
1 parent ee23824 commit cae4bcc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions MoreLinq.Test/BatchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ public void BatchSequenceYieldsListsOfBatches()
reader.ReadEnd();
}

[Test]
public void BatchSequencesAreIndependentInstances()
{
var result = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }.Batch(4);

using var reader = result.Read();
var first = reader.Read();
var second = reader.Read();
var third = reader.Read();
reader.ReadEnd();

first.AssertSequenceEqual(1, 2, 3, 4);
second.AssertSequenceEqual(5, 6, 7, 8);
third.AssertSequenceEqual(9);
}

[Test]
public void BatchIsLazy()
{
Expand Down

0 comments on commit cae4bcc

Please sign in to comment.