public void range_true_boxed() { Assert.Equal(10, SpanEnumerable.Range(1, 30) .Select(v => v % 3 == 0) .Box() .CountTrue()); }
public void range_true_boxed() { Assert.True(SpanEnumerable.Range(1, 30) .Select(v => v % 3 == 0) .Box() .AnyTrue()); }
public void range_none_true_box() { Assert.False(SpanEnumerable.Range(1, 30) .Select(v => v < 0) .Box() .AnyTrue()); }
public void range_where_box() { Assert.Equal(15, SpanEnumerable.Range(1, 30) .Where(p => p <= 15) .Box() .Count()); }
public void range_where_boxed() { Assert.True(SpanEnumerable.Range(1, 30) .Where(p => p <= 15) .Box() .Any()); }
public void range_all_true_boxed() { Assert.True(SpanEnumerable.Range(1, 30) .Select(v => v >= 0) .Box() .AllTrue()); }
public void range_where_empty_boxed() { Assert.False(SpanEnumerable.Range(1, 30) .Where(p => p <= 0) .Box() .Any()); }
public void aggregate1_range_boxed() { Assert.Equal(32, SpanEnumerable.Range(-1, 6).Select(i => 1 << Math.Max(0, i)) .Box().Aggregate( (a, n) => { Assert.Equal(a, n); return(a + n); })); }
public void aggregate2_range_boxed() { Assert.Equal(32, SpanEnumerable.Range(0, 5).Select(i => 1 << i) .Box().Aggregate(1, (a, n) => { Assert.Equal(a, n); return(a + n); })); }
public void copy_into() { Span <int> values = stackalloc int[30]; SpanEnumerable.Range(1, 30).CopyInto(values); for (var i = 0; i < 30; ++i) { Assert.Equal(i + 1, values[i]); } }
public void slice_copy_into() { Span <int> values = stackalloc int[10]; SpanEnumerable.Range(1, 30).Slice(5, 10).CopyInto(values); for (var i = 5; i < 15; ++i) { Assert.Equal(i + 1, values[i - 5]); } }
public void where_odd_copy_into() { Span <int> values = stackalloc int[15]; SpanEnumerable.Range(1, 30).Where(v => v % 2 != 0).CopyInto(values); for (var i = 0; i < 15; ++i) { Assert.Equal(2 * i + 1, values[i]); } }
public void take_copy_into_boxed() { Span <int> values = stackalloc int[25]; SpanEnumerable.Range(1, 30).Slice(5).Box().CopyInto(values); for (var i = 5; i < 30; ++i) { Assert.Equal(i + 1, values[i - 5]); } }
public void select_copy_into() { Span <int> values = stackalloc int[30]; SpanEnumerable.Range(1, 30).Select(i => i * 2).CopyInto(values); for (var i = 0; i < 30; ++i) { Assert.Equal((i + 1) * 2, values[i]); } }
public void aggregate3_range() { Assert.Equal(33, SpanEnumerable.Range(0, 5).Select(i => 1 << i) .Aggregate(1, (a, n) => { Assert.Equal(a, n); return(a + n); }, a => a + 1)); }
public void range_boxed() { var l = new List <int>(); foreach (var e in SpanEnumerable.Range(1, 10).Box()) { l.Add(e); } Assert.Equal( new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, l.ToArray()); }
public void range_boxed() { Span <int> result = stackalloc int[6]; result = SpanEnumerable.Range(1, 6).Box().ReverseInto(result); Assert.Equal(6, result.Length); for (var i = 0; i < result.Length; ++i) { Assert.Equal(6 - i, result[i]); } }
public void range_odd_empty_boxed() { try { _ = SpanEnumerable.Range(4, 1).Box().Single(v => v % 2 != 0); Assert.True(false); } catch (InvalidOperationException e) { Assert.Equal( "The input sequence is empty.", e.Message); } }
public void range_odd_two() { try { _ = SpanEnumerable.Range(5, 3).SingleOrDefault(v => v % 2 != 0); Assert.True(false); } catch (InvalidOperationException e) { Assert.Equal( "The input sequence contains more than one element.", e.Message); } }
public void range_two_boxed() { try { _ = SpanEnumerable.Range(5, 2).Box().Single(); Assert.True(false); } catch (InvalidOperationException e) { Assert.Equal( "The input sequence contains more than one element.", e.Message); } }
public void range_empty_boxed() { try { SpanEnumerable.Range(1, 0).Box().Last(); Assert.True(false); } catch (InvalidOperationException e) { Assert.Equal( "The input sequence is empty.", e.Message); } }
public void range_empty() { try { _ = SpanEnumerable.Range(5, 0).Single(); Assert.True(false); } catch (InvalidOperationException e) { Assert.Equal( "The input sequence is empty.", e.Message); } }
public void range_odd() { Assert.Equal(5, SpanEnumerable.Range(4, 3).SingleOrDefault(v => v % 2 != 0)); }
public void range_odd_empty_boxed() { Assert.Equal(0, SpanEnumerable.Range(4, 1).Box() .SingleOrDefault(v => v % 2 != 0)); }
public void range_empty_boxed() { Assert.Equal(0, SpanEnumerable.Range(5, 0).SingleOrDefault()); }
public void range_empty() { Assert.False(SpanEnumerable.Range(1, 0).Any()); }
public void range() { Assert.True(SpanEnumerable.Range(1, 30).Any()); }
public void range_none() { Assert.False(SpanEnumerable.Range(1, 29).Any(v => v > 30)); }
public void range_odd() { Assert.True(SpanEnumerable.Range(1, 29).Any(v => v % 2 != 0)); }
public void range_boxed() { Assert.True(SpanEnumerable.Range(1, 30).Box().Any()); }