Skip to content

Commit

Permalink
Updated test to use SourceKind and added a missing test scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmoryNode committed Nov 6, 2024
1 parent 292a1eb commit 453b0ed
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions MoreLinq.Test/SkipLastWhileTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ public void PredicateBecomesTruePartWay(SourceKind sourceKind)
.AssertSequenceEqual(0, 1, 2);
}

[Test]
public void NeverEvaluatesPredicateWhenSourceIsEmpty()
[TestCase(SourceKind.Sequence)]
// [TestCase(SourceKind.BreakingList)]
// [TestCase(SourceKind.BreakingReadOnlyList)]
public void NeverEvaluatesPredicateWhenSourceIsEmpty(SourceKind sourceKind)
{
using var sequence = TestingSequence.Of<int>();

Assert.That(sequence.SkipLastWhile(BreakingFunc.Of<int, bool>()), Is.Empty);
Assert.That(sequence
.ToSourceKind(sourceKind)
.SkipLastWhile(BreakingFunc.Of<int, bool>()), Is.Empty);
}

[TestCase(SourceKind.Sequence)]
Expand All @@ -92,5 +96,17 @@ public void OptimizedForCollections(SourceKind sourceKind)
sequence.SkipLastWhile(x => x > 7)
.AssertSequenceEqual(1, 2, 3, 4, 5, 6, 7);
}

[TestCase(SourceKind.Sequence)]
// [TestCase(SourceKind.BreakingList)]
// [TestCase(SourceKind.BreakingReadOnlyList)]
public void KeepsNonTrailingItemsThatMatchPredicate(SourceKind sourceKind)
{
using var sequence = TestingSequence.Of(1, 2, 0, 0, 3, 4, 0, 0);

sequence.ToSourceKind(sourceKind)
.SkipLastWhile(x => x == 0)
.AssertSequenceEqual(1, 2, 0, 0, 3, 4);
}
}
}

0 comments on commit 453b0ed

Please sign in to comment.