Exemple #1
0
    public void BlinqShouldEqualLinqNativeArrayElementAtOrDefault([ArrayValues] int[] sourceArr)
    {
        var index    = 10;
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.ElementAtOrDefault(source, index));
        var actual   = ExceptionAndValue(() => Blinq.ElementAtOrDefault(source, index));

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
Exemple #2
0
    public void BlinqShouldEqualLinqNativeSequenceRunElementAtOrDefault([ArrayValues] int[] sourceArr)
    {
        var index = 10;

        using (var source = new NativeArray <int>(sourceArr, Allocator.Persistent))
        {
            var seq      = Blinq.ToValueSequence(in source);
            var expected = ExceptionAndValue(() => Linq.ElementAtOrDefault(seq, index));
            if (expected.exception != null)
            {
                return;
            }
            var actual = ExceptionAndValue(() => Blinq.RunElementAtOrDefault(seq, index));
            AssertAreEqual(expected, actual);
        }
    }
Exemple #3
0
 public static TSource ElementAtOrDefault <TSource>(this IEnumerable <TSource> source, int index) =>
 LinqEnumerable.ElementAtOrDefault(source, index);