Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new SourceKind: Collection and List and use it for EndsWith tests. #960

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
In EndsWithTest, convert some tests as a case of more generic tests.
Orace committed Jan 30, 2023
commit 295849d5a728b77a84428c7d655d511d4bfeecf7
26 changes: 6 additions & 20 deletions MoreLinq.Test/EndsWithTest.cs
Original file line number Diff line number Diff line change
@@ -24,6 +24,9 @@ namespace MoreLinq.Test
[TestFixture]
public class EndsWithTest
{
[TestCase(new int[0], new int[0], ExpectedResult = true)]
[TestCase(new int[0], new[] { 1, 2, 3 }, ExpectedResult = false)]
[TestCase(new[] { 1, 2, 3 }, new int[0], ExpectedResult = true)]
[TestCase(new[] { 1, 2, 3 }, new[] { 2, 3 }, ExpectedResult = true)]
[TestCase(new[] { 1, 2, 3 }, new[] { 1, 2, 3 }, ExpectedResult = true)]
[TestCase(new[] { 1, 2, 3 }, new[] { 0, 1, 2, 3 }, ExpectedResult = false)]
@@ -40,6 +43,9 @@ public bool EndsWithWithChars(IEnumerable<char> first, IEnumerable<char> second)
return first.EndsWith(second);
}

[TestCase("", "", ExpectedResult = true)]
[TestCase("", "1", ExpectedResult = false)]
[TestCase("1", "", ExpectedResult = true)]
[TestCase("123", "23", ExpectedResult = true)]
[TestCase("123", "123", ExpectedResult = true)]
[TestCase("123", "0123", ExpectedResult = false)]
@@ -49,26 +55,6 @@ public bool EndsWithWithStrings(string first, string second)
return MoreEnumerable.EndsWith(first, second);
}

[Test]
public void EndsWithReturnsTrueIfBothEmpty()
{
Assert.That(new int[0].EndsWith(new int[0]), Is.True);
}

[Test]
public void EndsWithReturnsFalseIfOnlyFirstIsEmpty()
{
Assert.That(new int[0].EndsWith(new[] { 1, 2, 3 }), Is.False);
}

[TestCase("", "", ExpectedResult = true)]
[TestCase("1", "", ExpectedResult = true)]
public bool EndsWithReturnsTrueIfSecondIsEmpty(string first, string second)
{
// Conflict with String.EndsWith(), which has precedence in this case
return MoreEnumerable.EndsWith(first, second);
}

[Test]
public void EndsWithDisposesBothSequenceEnumerators()
{