Skip to content

Commit

Permalink
Append
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz committed Dec 29, 2024
1 parent aa6237d commit 08ef966
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions MoreLinq.Test/AppendTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AppendTest
[Test]
public void AppendWithNonEmptyHeadSequence()
{
var head = new[] { "first", "second" };
using var head = TestingSequence.Of("first", "second");
var tail = "third";
var whole = head.Append(tail);
whole.AssertSequenceEqual("first", "second", "third");
Expand All @@ -37,7 +37,7 @@ public void AppendWithNonEmptyHeadSequence()
[Test]
public void AppendWithEmptyHeadSequence()
{
string[] head = [];
using var head = TestingSequence.Of<string>();
var tail = "first";
var whole = head.Append(tail);
whole.AssertSequenceEqual("first");
Expand All @@ -46,7 +46,7 @@ public void AppendWithEmptyHeadSequence()
[Test]
public void AppendWithNullTail()
{
var head = new[] { "first", "second" };
using var head = TestingSequence.Of("first", "second");
string? tail = null;
var whole = head.Append(tail);
whole.AssertSequenceEqual("first", "second", null);
Expand Down Expand Up @@ -82,12 +82,15 @@ into e
[Test]
public void AppendWithSharedSource()
{
var first = new[] { 1 }.Append(2);
var second = first.Append(3).Append(4);
var third = first.Append(4).Append(8);
using var a = new[] { 1 }.AsTestingSequence(maxEnumerations: 2);
using var b = a.Append(2).AsTestingSequence(maxEnumerations: 2);
using var c = b.Append(3).AsTestingSequence();
using var d = c.Append(4).AsTestingSequence();
using var e = b.Append(4).AsTestingSequence();
using var f = e.Append(8).AsTestingSequence();

second.AssertSequenceEqual(1, 2, 3, 4);
third.AssertSequenceEqual(1, 2, 4, 8);
d.AssertSequenceEqual(1, 2, 3, 4);
f.AssertSequenceEqual(1, 2, 4, 8);
}
}
}

0 comments on commit 08ef966

Please sign in to comment.