Skip to content

Commit

Permalink
Extend test coverage for Enumerable.Any (#57550)
Browse files Browse the repository at this point in the history
Co-authored-by: Maledong <[email protected]>
  • Loading branch information
SEWeiTung and Maledong authored Aug 18, 2021
1 parent 69de57b commit 63f6461
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/libraries/System.Linq/tests/AnyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ public void Any(IEnumerable<int> source, bool expected)
Assert.Equal(expected, source.Any());
}

public static IEnumerable<object[]> TestDataForGroupBy()
{
yield return new object[] { Array.Empty<int>().GroupBy(num => num), false };
yield return new object[] { new int[2] { 1, 2 }.GroupBy(num => num), true };
yield return new object[] { new int[5] { 1, 2, 1, 3, 2 }.GroupBy(n => n, (k, v) => v), true };
}

[Theory, MemberData(nameof(TestDataForGroupBy))]
public void Any_GroupBy(IEnumerable<object> values, bool expectedValue)
{
// Provide test coverage for `Any` calls over nonempty `IListSource` implementations.
Assert.Equal(expectedValue, values.Any());
}

public static IEnumerable<object[]> TestDataWithPredicate()
{
yield return new object[] { new int[0], null, false };
Expand Down

0 comments on commit 63f6461

Please sign in to comment.