I'm trying to merge following System.Linq tests to ZLinq compatibility tests.
dotnet/runtime@087c690
But following edge case tests are failed on ZLinq.
(Currently it also failed with SystemLinq. Because these fix is not released yet)
- AppendOverflowCountWithICollection()
- AppendPrependNOverflowCountWithICollection()
- PrependOverflowCountWithICollection()
It seems following method needed to be modified. (with checked?)
|
if (source.TryGetNonEnumeratedCount(out count) && count < int.MaxValue) |
|
{ |
|
count++; |
|
return true; |
|
} |
|
count = 0; |
|
return false; |
|
} |
|
if (source.TryGetNonEnumeratedCount(out count) && count < int.MaxValue) |
|
{ |
|
count++; |
|
return true; |
|
} |
TestCode
public class UnitTests
{
[Fact]
public void EdgeCaseTest()
{
// Arrange
var source = new MockCollection<int>(int.MaxValue); // Use custom ICollection based collection.
// Act
var results = source.AsValueEnumerable().Append(1).Prepend(1);
// Assert
var count = results.Count(); // It should be failed by OverflowException.
Assert.Equal(2, count); // 2 returned instead. it seems source.Count is not used.
}
}
public sealed class MockCollection<T> : ICollection<T>
{
private readonly int _count;
public MockCollection(int count) => _count = count;
public int Count => _count;
public bool IsReadOnly => true;
public void Add(T item) => throw new NotSupportedException();
public void Clear() => throw new NotSupportedException();
public bool Contains(T item) => false;
public void CopyTo(T[] array, int arrayIndex) { }
public bool Remove(T item) => throw new NotSupportedException();
public IEnumerator<T> GetEnumerator() => Enumerable.Empty<T>().GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
I'm trying to merge following System.Linq tests to ZLinq compatibility tests.
dotnet/runtime@087c690
But following edge case tests are failed on ZLinq.
(Currently it also failed with SystemLinq. Because these fix is not released yet)
It seems following method needed to be modified. (with
checked?)ZLinq/src/ZLinq/Linq/Prepend.cs
Lines 36 to 43 in c6d15be
ZLinq/src/ZLinq/Linq/Append.cs
Lines 35 to 39 in c6d15be
TestCode